Linux Web Server Info

Web Server:
  • Apache 2.0.54 is available in Fedora Core 4 because we have done the "everything" installation previously. Go to "Desktop" > "System Settings" > "Security Level". Provide your root password, click "ok" and on the "Firewall Options" tab make sure the checkbox next to "WWW (HTTP)" is checked. On the "SELinux" tab under (expanded) "HTTPD Service" make sure all the checkboxes are checked except "Disable SELinux protection for httpd daemon" unless you wish to disable SELinux for just the web server installation in which case you should check that box. Check the checkbox next to "Relabel on next reboot". (You will have to re-configure your iptables setup after your next boot as described in the Azureus section above as the relabel process overwrites your iptables files.) Click "ok". If you have enabled SELinux in your Fedora Core installation and you wish to serve web pages from your user's home "public_html" directory as well as from your /var/www/html directory or if you wish to run a more complex web server with scripting language support you will probably have to disable SELinux for the httpd daemon in order for your web server to work properly. Although the situation is getting better with each release there are still issues with SELinux and full web server implementations in Linux. In order to do this go to "Desktop" > "System Settings" > "Security Level", provide your root password, click "ok" and on the "SELinux" tab under (expanded) "HTTPD Service" click the checkbox for "Disable SELinux protection for httpd daemon". Also under (expanded) "SELinux Service Protection" click the checkbox for "Disable SELinux protection for mysqld daemon". Check the checkbox next to "Relabel on next reboot". (You will have to re-configure your iptables setup after your next boot as described in the Azureus section above as the relabel process overwrites your iptables files.) Click "ok". Reboot your machine.
  • Subscribe to a service such as https://www.dyndns.org/ or http://www.easydns.com/ to register a new domain name (such as your-name.org) and to have their DNS service map your computer's IP address to your new registered domain name. (The command "ifconfig" at the root prompt will output your IP address.) If you have a "dynamic" (changeable) IP address you can use their dynamic DNS service.
  • If you are using a router you may have to forward ports 80, 8080, and 443 in order for your web server to work through your router's firewall. See http://www.portforward.com/routers.htm for instructions.
  • Open the terminal. Type:
    su -

    Hit enter. Type your root password. Hit enter. Type "ifconfig". Hit enter. This will output the IP address of your machine (the numbers after "inet addr:"). Type:

    gedit /etc/hosts

    Hit enter. In gedit edit your /etc/hosts file to include a line containing your IP address, your domain name, and your short domain name (the characters before the dot). Be sure to include a carriage return after this line. When you are finished your hosts file should look something like this:

    # Do not remove the following line, or various programs
    # that require network functionality will fail.
    127.0.0.1 localhost.localdomain localhost
    67.172.236.37 stantonfinley.org stantonfinley

    Click on the "save" icon in gedit and exit gedit. Type:

    gedit /etc/sysconfig/network

    Hit enter. In gedit edit your /etc/sysconfig/network file and replace "localhost.localdomain" with your domain name. When you are finished your network file should look something like this:

    NETWORKING=yes
    HOSTNAME=stantonfinley.org

    Click on the "save" icon in gedit and exit gedit. Type:

    gedit /etc/httpd/conf/httpd.conf

    Hit enter. In gedit scroll down to the "ServerAdmin" section and enter your email address instead of "root". Scroll down to the "#ServerName" section and uncomment it (take out the "#"). Then enter the registered DNS name of your web site ("whatever.com") or your server's IP address instead of "www.example.com". (If you don't know your IP address type "ifconfig" at the root prompt.) Scroll down and change "UseCanonicalName Off" to "UseCanonicalName On". Scroll down to the "Options" line and change "Options Indexes FollowSymLinks" to "Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews". Change "AllowOverride None" to "AllowOverride Options FileInfo AuthConfig Limit" in case you want to use .htaccess files in any of your web subdirectories. Change "DirectoryIndex index.html index.html.var" to "DirectoryIndex index.html index.html.var index.shtml index.cgi index.php index.phtml index.php3 index.htm home.html welcome.html". Under the "AddType application/x-compress .Z" and "AddType application/x-gzip .gz .tgz" lines add the line: "AddType application/x-httpd-php .php .phps .php3 .phtml .html .htm .shtml .fds". Uncomment the line "#AddHandler cgi-script .cgi" and add ".pl" so that it reads "AddHandler cgi-script .cgi .pl". If you wish to enable support to serve web pages from user's home directories as well comment (add a "#" in front of) "UserDir disable" so that it reads "#UserDir disable" and uncomment "#UserDir public_html" so that it reads "UserDir public_html". Then uncomment and edit the control access stanza for user directories below it so that it looks something like this:

    <Directory /home/*/public_html>
    AllowOverride Options FileInfo AuthConfig Limit
    Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    <Limit GET POST OPTIONS>
    Order allow,deny
    Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
    Order deny,allow
    Allow from all
    </LimitExcept>
    </Directory>

    Click on the "save" icon in gedit to save your httpd.conf file and exit gedit. Close the terminal.

  • Open a terminal as your regular user (not root). Type:
    mkdir public_html

    Hit enter. Type:

    chmod -R 755 public_html

    Hit enter. Close the terminal.

  • Open the terminal. Type:
    su -

    Hit enter. Type your root password. Hit enter. Type:

    cd /home

    Hit enter. Type:

    chmod 711 your_user_name

    (Use the name of the user's home directory you are working with in place of "your_user_name".) Hit enter. Close the terminal.

  • If you have a favicon.ico copy it to /var/www/html while still logged in as root (cp favicon.ico /var/www/html).
  • Go to "Desktop" > "System Settings" > "Server Settings" > "Services". Type in your root password in the dialog box that appears and click on "OK". Scroll down the list and check the check box for "httpd". Click on the "save" icon in the Service Configuration window and then close the window. Do this for runlevel 3 as well as for runlevel 5. Reboot your machine.
  • Open Firefox and type "http://localhost/" in the URL window and hit enter. You should see the default Apache/Fedora Core test page. Type your server's IP address in the URL window and hit enter. You should see the test page again. Type the registered DNS name of your web site ("whatever.com") in the URL window and hit enter. You should see the test page yet again.
  • While still logged in as root copy or move your web site index.html and any other HTTP content you may have to /var/www/html and/or to /home/your_user_name/public_html. Change permissions on these files to be viewable and executable as appropriate on the web (usually "chmod 755 *"). You are now serving web pages from your Fedora Core web server. You will find your server log files in /etc/httpd/logs and you will be able to view them while logged in as root.