Creating Virtual Web Servers

When I created this blog I wanted to view the contents locally before uploading online. Viewing the contents in a web browser does not require a web server. Using a web server imitates what online visitors see and is a better test.

I use Slackware on my LAN server. Slackware comes with a default Apache web server. All that is needed is enabling (chmod +x) the /etc/rc.d/rc.httpd script. Then point the web browser to that local URL. When operational a simple It works! web page will appear.

The default web server runs on port 80. To run a local copy of my blog I created a virtual host. I configured the local copy of my blog to run on port 8080.

I modified /etc/httpd/httpd.conf:

    Listen 80
    Listen 8080
    <Directory "/var/www/rtu/">
        AllowOverride All
        Options None
        Require all granted
    </Directory>
    Include /etc/httpd/extra/httpd-vhosts.conf
    

I modified /etc/httpd/extra/httpd-vhosts.conf:

    <VirtualHost *:8080>
        ServerAdmin root@localhost
        DocumentRoot "/var/www/rtu"
        ServerName localhost
        ErrorLog "/var/log/httpd/rtu-error_log"
        CustomLog "/var/log/httpd/rtu-access_log" common
        <Directory "/var/www/rtu">
          Require all granted
        </Directory>
    </VirtualHost>
    

I populated the server's /var/www/rtu directory. In Firefox I created a bookmark to the server's virtual host port 8080. I restarted the httpd service.

I use my own scripts to update the local server and update the online host.

Posted: Category: Tutorial Tagged: General

Next: Net Neutrality

Previous: Broken Kernels