Configuring your LAMP Server

Posted on April 28, 2009 | Category: Networking, Server, Ubuntu


This tutorial will not discuss the ins and outs of installing Ubuntu Server. However, I will tell you how to get it up and running with the Apache configuration, PHP, and general installation of a Content Management System (CMS) using PhpMyAdmin.
The first thing that you need to know, is where all of your files are located.

File & Folder Locations

Also, these are some of the main commands that you will use to get things going

Router and Domain Service Provider

Make sure that you have a static ip from your internet service provider. Otherwise, this really won’t work for you. Visit your domain service provider (e.g. Network Solutions) and the Advanced DNS records section. Enter your static ip address in the ARecords. 
Changes can take hold within 20 minutes to 48 hours, so be patient if things aren’t going your way. Next, let’s work on opening up your router to port 80. Using your web browser, you will need to type in something like 192.168.1.10. This address varies depending on your router brand or model. You will also need to find out your logon and password for access to the router. Once this is complete, bookmark the router address and change the password for router access – seriously! Visit a tab or section in your router title Port Forwarding and add port 80. As you can see in the screenshot, my internal ip uses the 10.X.XX.XXX sequence versus the standard 192.168.1.10. Remeber to put in your internal computer ip, versus your static ip that you obtained from your ISP. 
The last sequence of events told your router to allow information coming from port 80 to your specific computer Save your changes and close out the router page.

Add-Ons

Depending on your configuration and preferences, you may have to install some or all of these. So, go ahead and type in

<p>sudo apt-get install php5-curl curl openssh-server libcurl3 sendmail php5-gd phpmyadmin -y</p>

That should cover all of your problems. To establish a remote connection to your server from another Ubuntu box, make sure to open up port 22 on the UFW firewall by typing in
<p>sudo ufw allow 22</p>

Remember, you will have to do this on your Server and remote machine. While you are at it, allow 80 as well. That will allow Apache to get in and out of your box. Next, on the remote machine terminal, type in ssh -X username@internal_ip
That should get you into your Server’s command line interface.

File Modifications

The first file that you can modify is your /etc/apache2/httpd.conf. Using vi, type in

<p>sudo vi /etc/apache2/httpd.conf</p>

The file should be blank by default. Enter the following line
ServerName your_domain_name.net
Save the file. Alternatively, if you are more comfortable with GUI, you can ssh into your Server box and install programs like gedit. Installing these programs on your server will not cause a GUI install to your Server. The GUI from your remote box will render the program information, while your Server pushes out the data.

Default file

Your default file handles many variables in your Apache configuration. I feel that it is one of the more important files for configuring your box. Ok, so open up the file in your favorite editor by typing in

<p>sudo gedit /etc/apache2/sites-available/defualt</p>

Towards the top of the file, there is a section of code that says

ServerAdmin root@localhost

DocumentRoot /var/www/
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
You need to change the ServerAdmin to your email address, change the “AllowOverride None” to “AllowOverride All”, and then place a dash or hyphen preceeding the Indexes. This last modification is important because it tells Apache that you do not want people to view the content of your file folders.

PHP5

The next task is a fairly simple file modification to the php.ini. Oftentimes, the PHP memory limit and max_upload size needs increasing. Open up

<p>sudo gedit /etc/php5/apache2/php.ini</p>

Find the lines that say “memory_limit = 2M” and change it to say 10. This depends on the type of files that you are processing on your server. If you aren’t using PHP, I do not see a reason to alter this file at all. Next, if you are going to be uploading new files through phpmyadmin, you will most likely need to change this value. Find the line that reads
<p>Maximum allowed size for uploaded files. upload_max_filesize = 2M</p>

Change this to the maximum size of your largest .sql file.

/etc/hosts

Now you need to change your /etc/hosts file by typing in sudo gedit /etc/hosts
At the end of the first uncommented line reading 127.0.0.1, add your domain name to the tune of “domain_name.net” without the http or www prefix.

Restarting Apache

Now that you have made all of these changes, restart apache using sudo /etc/init.d/apache2 restart
If you really want to dispell all doubt, simply restart your Sever box by typing in sudo reboot
You should be off and running. If not, leave a comment, search Google, or visit the Ubuntu Forums.

Similar Articles

Leave a Reply

CAPTCHA Image CAPTCHA Audio
Refresh Image

Design: YGoY TopOfBlogs