Apache Web Server Installation and Configuration with PHP support
This guide will gudie you through a basic setup of Apache with PHP support to host user websites and virtual user sites.
(Important: Read agreement at bottom of document before continuing)

  1. Switch to root.

    $ su
    Password:

  2. Install the Web Server group which installs Apache, php, and other packages.

    # yum groupinstall 'Web Server'


  3. Configure Apache configuration file.

    # gedit /etc/httpd/conf/httpd.conf

    OR

    # nano /etc/httpd/conf/httpd.conf


  4. Find the following lines and replace them with appropriate settings. Check the examples given.

    My hostname is: lintush.m2t.com. When done, save and close the file.

    line

    Replace with

    ServerAdmin root@localhost

    ServerAdmin jesse@m2t.com
    #ServerName www.example.com:80
    ServerName lintush.m2t.com
    UserDir disable
    #UserDir disable
    #UserDir public_html
    UserDir public_html
    Find this section


    #<Directory /home/*/public_html>
    # AllowOverride FileInfo AuthConfig Limit
    # Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    # <Limit GET POST OPTIONS>
    # Order allow,deny
    # Allow from all
    # </Limit>
    # <LimitExcept GET POST OPTIONS>
    # Order deny,allow
    # Deny from all
    # </LimitExcept>
    #</Directory>
    Replace with


    <Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    <Limit GET POST OPTIONS>
    Order allow,deny
    Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
    Order deny,allow
    Deny from all
    </LimitExcept>
    </Directory>

    Line
    DirectoryIndex index.html index.html.var

    Replace with
    DirectoryIndex index.html index.php index.htm index.html.var

    #NameVirtualHost *:80
    NameVirtualHost *:80

  5. Start Apache.

    # service httpd start

  6. After Apache starts, open up firefox and type http://localhost in the address window. You should get a test page like the one below:



  1. Lets enter some content for the main web server web page..

    $ cd /var/www/html

  2. Create the file index.php.

    $ nano index.php

  1. Enter data below into editor. Save the file and exit.

    <?php


    echo "<H1>Welcome to Apache & PHP</H1>";
    echo "<HR>";
    echo "<H2>Hello, world!</H2>";
    echo "<HR>";
    echo "<H3>Apache and php are now working.</H3>";


    php?>

  2. Lets test it out. Open up firefox and type http://localhost in the address box. You're message should display in the browser window without the HTML tags. If the message doesn't look like the message in the browser window below than php is not working.





  3. Close firefox and create a user called web with access rights of 711.

    # adduser web
    # chmod 711 /home/web

  4. Change password for user 'web' to '123456'

    # passwd web
    Changing password for user web.
    New UNIX password:
    BAD PASSWORD: it is too simplistic/systematic
    Retype new UNIX password:

    passwd: all authentication tokens updated successfully.
    #


  1. Switch to user 'web'.

    # su -l web
    $

  2. Make the directory 'public_html' and go in it.

    $ mkdir public_html
    $ cd public_html

  3. Create the file index.php.

    $ nano index.php

  4. Enter data below into editor. Save the file and exit.

    <?php


    phpinfo();


    php?>


  5. Exit user account.

    $ exit
    #

  6. Now lets check if the user setup and php work. Open up firefox and try it with user web, http://localhost/~web, if you get the php configuration page shown below then apache is confgured correctly to support users personal websites under the public_html folder and php support works. If you get access denied then the permissions for the user home directory are most likely set to 700. They must be set to 711.



    Done!






Agreement

This guide is provided as is with no warranty, garantee, or liability of any kind. Use it at your own risk. I am not responsible for any damages arising from the use of this guide. If you agree to these terms than you will use the guide with the understanding that you will not hold me responsible for any damages, whatever their nature, resulting from the use of this guide.





Comments






Message posted on Monday, December 3, 2007 at 09:35:29 pm By: Jesse
Hello Fedora Community,

Here is a small how-to on Apache. I hope it helps someone out.





Post your Comments






Enter your message:

Your name:

Date: Friday-November-21-2008 02:20:43 am
(Actual time will vary at the time the message is posted.)

You can also leave a picture to go with your message.(optional)
All image types supported.
Picture to upload:

Message: