The lazy way to LAMP

Posted by Nick on May 16th, 2009

Most web developers need a LAMP development server to deploy and test their apps. With Ubuntu – and any other linux – that is very easy. So in Ubuntu you can install a LAMP server just by running this command:

sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql phpmyadmin

This way you have a full working LAMP server. Now if you need additional php extensions just open the Synaptics package manager (System -> Administration -> Synaptics Manager) and search for “php”, this will give you all the available options.

Configuration files

In case you need to play with the configuration you can check the above paths that hold the configuration files for the servers we just installed:




Starting, stoping and restarting servers

Our servers (apache and mysql) by default will start any time you boot so there is no need to start them. But when you change something in the configuration files you need to restart them in order to get the new directives. The way to do that is the following:

sudo /etc/init.d/apache2 restart

sudo /etc/init.d/mysql restart

In the above commands if you replace the “restart” with “stop” or “start” you can stop or start the server.

Making the environment more friendly

The Apache web server by default will run as www-data. This will lead you to many permission problems, and as this is your development machine, you don’t really care about security. The easiest way to work around this is by changing the user that Apache runs. Open the envvars configuration file:

gksu gedit /etc/apache2/envvars

And then replace the www-data (in the APACHE_RUN_USER and APACHE_RUN_GROUP directives)  with your username and group (usually it is the same)

Then you will need to give full access to your user for the doc root path. You can do that by executing this:

sudo chown -R USER:GROUP /var/www/

Again you should replace USER with your username and GROUP with the group that you belong to.

After that you need one more little adjustment to make phpmyadmin work with this new configuration. Execute this:

gksu gedit /var/lib/phpmyadmin/

and copy the $cfg[‘blowfish_secret’] = ‘…. line. You will need to paste it in the end of this file: /etc/phpmyadmin/

Our LAMP server is ready!

Now that you are ready you can start using your LAMP server. Visit http://localhost/ to visit it from your browser or visit http://localhost/phpmyadmin to administer the mySQL server.

Tags: , , , ,

Comments are closed.