How to Install LAMP (Linux, Apache, MySQL, PHP) on Ubuntu (8.04 / 8.10)

This is for the newbies in the world of Ubuntu. Use the following steps to install LAMP (Linux, Apache, MySQL and PHP) in Ubuntu.

  • Open up the Terminal (Applications > Accessories > Terminal).
  • Run the following command to install Apache
    $sudo apt-get install apache2
  • To test Apache open up any web browser and then enter the following into the web address:
    http://localhost/
  • Now run the following command in the terminal to install PHP
    $sudo apt-get install php5 libapache2-mod-php5
  • In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:
    $sudo /etc/init.d/apache2 restart
  • In order to test PHP, in the terminal copy/paste the following line:
    $sudo gedit /var/www/testphp.php
  • Copy/Paste this line into the phptest file: <?php phpinfo(); ?>
  • Save and close the file.
  • http://localhost/testphp.php
  • Once again open up the amazing Terminal and then copy/paste this line:
    $sudo apt-get install mysql-server
  • This is where things may start to get tricky. Begin by typing the following into Terminal:
    $mysql -u root -p
  • Following that copy/paste this line:
    $mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
  • We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste the following line into Terminal:
    $sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
  • After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:
    $sudo gedit /etc/php5/apache2/php.ini
  • Now we are going to have to uncomment the following line by taking out the semicolon (;). ;extension=mysql.so To look like this: extension=mysql.so

Now just restart Apache and you are all set!

$sudo /etc/init.d/apache2 restart

We are ready to start code in PHP using MySQL for database and Apache as HTTP server in Ubuntu!!!

Read More

How to install or add PHP GD support in Ubuntu

PHP is mainly a server side language which renders the code at server and throws the output to the client end through Apache or any other HTTP server. So, being a newbie we often suffer from GD support in Ubuntu. This are the following steps to install or add PHP GD support in Ubuntu.

$ apt-get install php5-gd

OR

$ sudo apt-get install php5-gd
$ /etc/init.d/apache2 restart

Now PHP GD support is ready to work.

Read More

How to set a cron job using PHP in webmin

I have a CentOS server to test my all projects. According to clients requirement webmin is installed as admin panel. Today I had tried to use a cron PHP script in that server and succeeded. This is how I have setup the cron job.

In the webmin panel ther is a menu group named ‘Cluster';
So from that menu group -> Cluster Cron Job.
Then I have added a new cron job.
1. Selected user ‘apache’.
2. in the command box:

/usr/bin/php -q /full/path/to/the/cronjob.php

3. Then selected the time which I want the cron job should be done.

Wow… It’s working. Please feel free to ask if you need any further help regarding this.

Read More