Tag: Install PHP5 Ubuntu
Setting Up A LAMP Server
by Phildawg on Jun.16, 2009, under Computers
LAMP is a term used to describe certain web servers. It stands for Linux, Apache, MySQL, PHP. This is mainly going to be a point of reference for myself. I recently set this up on my macbook so I could install wordpress and learn a bit how themes are made. I didn’t want to play around directly with my actual Phildawg site and screw something up. This way I have a blank template, or even a copy of my current site, to play around with. This also came up recently when I found out my friend James is starting to do some side work designing sites for people. Currently he uses live sites on the internet while he is building. This just isn’t practical. So here is what I did/am doing.
Lets start with the L. Grab a copy of your favorite linux distro. Right now I am working with Ubuntu 9.04 but there are many different flavors available. You can download an iso to burn to a cd or you can order a CD via snail mail. Installing Linux has gotten insanely easy these past few years and I may do a post later on about how to do just that. For now, it should be easy enough to just boot to the CD and follow the on screen prompts. (I’m assuming you are doing this on a seperate machine and do not need to go into dual booting or need to save anything currently on the machine. This will be a dedicated machine in your house)
So you have linux installed and updated. Great. Its actually pretty easy from here. Moving along to the A, its time to install apache. Open up a terminal window (In Ubuntu click applications in the top right, select applications, and click on terminal) and type in the following command:
sudo apt-get install apache2
After pressing return it goes out and installs it. You may need to type ‘Y’ to start the install. Once you return to an empty command line you are done. Easy as that. One simple line.
Now lets get MySQL and PHP. PHP is used by wordpress which is what I am using for this site. In your terminal window type in the following commands and follow the prompts:
sudo apt-get install mysql-server
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
Congrats. You have everything installed. The only config file I needed to edit was an apache config file so that PHP would work properly. Open up the config file by typing in the following command:
sudo gedit /etc/apache2/apache2.conf
and at the bottom add in the following line without the quotes. “AddType application/x-httpd-php .html”. Save the file and close it. Then restart the apache server with the following command:
sudo /etc/init.d/apache2 restart
If you get an error saying that apache could not determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName then you need to create a file to fix this. In the terminal again, type in the following:
sudo gedit /etc/apache2/conf.d/fqnd
You should get a blank window that pops up. Type in “ServerName localhost” (without the quotes) and save the file. Close the window and restart apache again. Personally it didn’t really affect my wordpress install but its nice to not have errors.
That’s pretty much it. You have a webserver to play around with now. The only weird thing I came across is that my installation of Firefox didn’t know what to do when it encountered a php file. It kept prompting me to save the file instead of starting my wordpress setup. To fix this just clear the browser cache. In Firefox click on edit and choose preferences. On the privacy tab click on clear now in the private data section.
Couple other things to note, for wordpress you will need to create a database to use. From the commandline, get into mysql by typing:
mysql -u root
It should change your prompt to “msql>”. If you already setup a password for root during the setup you will need to use the command
mysql -u root -p
and then put in your password at the prompt. If you haven’t changed the root password from the default yet I recommend you do that first by typing in
SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’yourpassword’);
Only change the text yourpassword and leave the single quotes. Remember this password so you can create the various databases for your sites. Now to create a database type in the following:
CREATE DATABASE databasename
Your database is now created and you can type “\q” (minus the “”) to get back to the terminal prompt. If you are done you can type exit or just close the window.
Hopefully later this week I’ll find some time to go through installing wordpress on your new LAMP server and setting up some forwarding so you can access your test sites from outside of your home. This is going to be ideal for my friend James because he can then do all of his developement on a server in his own home but still give him a way to show the clients the progress he has made without dragging them into his house. There will be a special thanks to @erimar77 from Eric-Martin.com for helping me out with the port forwarding and the site I use to make this happen. But I’ll leave it at this for now. You’ll just have to check back for the next steps.