Set up a local web development server on Fedora 16 with Apache

The following procedure allows you to run your own webserver on Fedora 16, so that you can develop web scripts and applications and test them locally without an Internet connection. I assume that you’re using Gnome 3. Run the stated commands in a terminal – accessible via alt+F2, enter: gnome-terminal [press enter]

Login as root:

su

Install the Apache webserver:

yum install httpd

Configure Apache to handle requests to your local website:

nano /etc/httpd/conf/httpd.conf

Navigate to the end of that file using your arrow keys, or the page down button, and add the following text at the bottom. Replace the text in {} with whatever suits your setup

<VirtualHost *:80>
DocumentRoot {PATH TO YOUR WEB FILES (THE SPECIFIED FOLDER MUST EXIST), E.G.: /var/www/mysite}
ServerName {ADDRESS TO ACCESS YOUR WEBSITE IN A BROWSER BY, E.G.: local.mysite}
</VirtualHost>

The actual text that you add might look like this:

<VirtualHost *:80>
DocumentRoot /var/www/mysite
ServerName local.mysite
</VirtualHost>

Save and close the file:

ctrl+x [enter]

y [enter]

Configure your hosts file to route requests for your website to Apache:

nano /etc/hosts

Add to the end of this file the following text:

127.0.0.1   {ADDRESS TO ACCESS YOUR WEBSITE IN A BROWSER BY, E.G.: local.mysite}

The actual text that you add might look like this:

127.0.0.1    local.mysite

Save and close the file:

ctrl+x [enter]

y [enter]

Restart Apache:

service httpd restart

Your website should now be accessible in a website via whatever address you specified above, e.g. local.mysite (note not www.local.mysite).

(Optional) Configure file permissions:

If your website is still not accessible, you may have a file permissions issue. You can temporarily disable selinux to see if that is causing the problem. If that doesn’t help, you can use a permissions debugging tool to find problems with your UNIX file permissions.