This is a short guide to installing a basic LAMP(Linux, Apache, MySQL, PHP) development environment on Ubuntu 12.04 Precise Pangolin.
First install lamp:
Open a terminal and run the following:
sudo apt-get install lamp-server^
After the lamp server installation you will need write permissions to the /var/www directory. Follow these steps to configure permissions.
Add your user to the www-data group
sudo usermod -a -G www-data <your user name>
now add the /var/www folder to the www-data group
sudo chgrp -R www-data /var/www
now give write permissions to the www-data group
sudo chmod -R g+w /var/www
now log out and log back in to see the changes reflected in nautilus.
Some extra things to install
The following are not essential but they are things I almost always need as part of a LAMP install so I have included instructions on installing them.
Curl:
sudo apt-get install php5-curl
Mod rewrite:
sudo a2enmod rewrite
GD2 Graphics Lib:
sudo apt-get install php5-gd
And that's it, how easy was that? Ubuntu rocks!
First install lamp:
Open a terminal and run the following:
sudo apt-get install lamp-server^
After the lamp server installation you will need write permissions to the /var/www directory. Follow these steps to configure permissions.
Add your user to the www-data group
sudo usermod -a -G www-data <your user name>
now add the /var/www folder to the www-data group
sudo chgrp -R www-data /var/www
now give write permissions to the www-data group
sudo chmod -R g+w /var/www
now log out and log back in to see the changes reflected in nautilus.
Some extra things to install
The following are not essential but they are things I almost always need as part of a LAMP install so I have included instructions on installing them.
Curl:
sudo apt-get install php5-curl
Mod rewrite:
sudo a2enmod rewrite
GD2 Graphics Lib:
sudo apt-get install php5-gd
And that's it, how easy was that? Ubuntu rocks!
Nice and to the point, thank you!
ReplyDeletebefore doing all these steps, how can I tell if any of the components of LAMP are already installed in my system? I believe I already installed PHP using the GUI, and I don't remember if I did the same with apache. I wonder if I can install tomcat and struts in Ubuntu? Anyhow, thanks for this post!
ReplyDeleteat the terminal run:
Deletephp -version
apache2 -version
mysql --version
If they are installed version information will be printed, if they are not it will say something about command not found.
Alternatively you can just run the installation commands and it will tell you if it is already installed, if they are the installation will just continue to the next step and will skip installing that component.
Such a nice post - Thanks a lot!
ReplyDeleteHey i am new to ubuntu. I recently installed ubuntu 12.04 and installed LAMP but while allowing permission to file system "sudo chgrp -R www-data /var/www" isn't working, any idea? please help.
ReplyDeletewhat error message are you getting?
Deletewhere to change the dir for www? for example, i want that my server goes to /home/my/public_html/
ReplyDeleteupdate the config file for the site, assuming you are running one site and it is the default edit:
Deletesudo gedit /etc/apache2/sites-enabled/000-default
otherwise create a new site file with the appropriate paths
& how to run phpmyadmin?
ReplyDeleteDon't use it, i just use the command line client for mysql, i'm sure google will tell you
Deleteif you must http://www.webrichsoftware.com/?p=16 has the steps for the phpmyadmin addin
ReplyDeleteWhen I give the Command "sudo apt-get install lamp-server^" then an error message given,that is:
ReplyDeleteE: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
How I overcome this problem ?? Plz tell me..
You have something else running that is using the package manager, either synaptic, Ubuntu Software Centre or Update Manager. Just close whatever is already working with your packages, if you don't know what it is just reboot. The second line of error message is essentially telling you this.
DeleteOr failing that just google it, there are literally tens of thousands of pages discussing this error.
here is a link: http://justfuckinggoogleit.com/
Are you sure GD is as simple as installing php5-gd? I ask as on my server although 'php5 -i | grep gd' from the command line reports it's there phpinfo() from apache shows no trace of it and I'm getting a vibe from Googling about that there may be an issue with the security of the GD library which may have led the package maintainers to restrict access to it from Apache. Really bad news if so.
ReplyDeleteHeh, just removed and re-installed the package and it burst into life. Go figure.
ReplyDeleteNice post! clear and concise... Time saver
ReplyDeleteMany thanks!
Hi James
ReplyDeleteThank you very much for a clear concise guide.
Much appreciated.
Hi,
ReplyDeleteThanks for pointing out all steps clearly. I am getting a problem though, whenever I copy paste files under www folder I have to run file permission and usergroup commands again or it just throw error that file is not accessible. Is there any workaround to do this automatically?
Thanks!
I have a question the php project prepared for Ubuntu should be able to run on windows platform.
ReplyDeletephp developer india
Since, Lamp Development platform is made up of components, which come from open source
ReplyDeleteFantastic post, simple and easy! Thanks. Don't suppose you have another such post on how to set up subdomains (for development) on the apache server?
ReplyDeleteThank you for the clear, concise post. Top work!
ReplyDelete