Home Apache PHP Ubuntu MySQL Linux HTML Win CSS Perl Javascript Rants Retro
 
Print This Page
Date Posted: Sunday 07th of February 2010 | Category: Apache
Set up a basic LAMP server in Ubuntu. Beginners guide to servers.
Set up a basic LAMP server in Ubuntu. Beginners guide to servers.
These are the basics steps to setting up a server in Ubuntu.
This tutorial will show how to set up a basic LAMP server for testing your .php and .html pages locally.

You can even make your webserver live, which will be covered at another time.

Using the terminal enter the following commands.

sudo apt-get install update

Install apache2

sudo apt-get install apache2

Install mysql-server

sudo apt-get install mysql-server

Install php5

sudo apt-get install php5

Install php5-mysql package, which binds mysql to php

sudo apt-get install php5-mysql

Install the GD Library for image manipulation

sudo apt-get install php5-gd

You have now installed a basic LAMP server. How easy was that?

Open up firefox and enter http://localhost in the address bar. If everything goes as planned you should see the Apache welcome screen.

You can now place your webpages in /var/www/ which is the default directory for apache2.

MAKING YOUR SITE LIVE
You need to accept connections on port 80 through your router and enter the ip address of your server.

You also need to set port 80 in your apache ports.conf file.

If everything goes as planned, you should be able to access your home server by typing your main ip address.

STOPPING, STARTING RESTARTING APACHE
To start Apache use the following command:-

sudo /etc/init.d/apache2 start

To restart Apache use the following command:-

sudo /etc/init.d/apache2 restart

To stop Apache use the following command:-

sudo /etc/init.d/apache2 stop

Whenever you make changes to apache.conf file always restart Apache.

ADDITIONAL NOTES
You may want to change the directory of where your webpages are uploaded. By default pages webpages are stored in /var/www ,but I decided to create a public_html directory on my desktop.

I edited the etc/apache2/sites-available/default document using:

sudo gedit /etc/apache2/sites-available/default

I then chmod777 on the public_html folder by using the following command:

chmod 777 /home/ade234uk/Desktop/public_html

You can't get to your IP from your IP. If you want to see your server on your own network then simply add this to the/etc//hosts in the computer you are browsing with.

your_servers_ local_IP_address your_domain_name.
For example it might look like this

192.168.0.200 server.domain.com

Then when ever you use you domain name that computer will point to your severs IP address.

I found this will not work with non standard ports, so you can open up port 80 for your LAN in apache and leave any other port set up if you are using non standard ports.