Monday, May 19, 2008

Fedora8:Apache set up--httpd.conf

/etc/httpd/conf/httpd.conf

Assuming the DNS is set up. My Fedora computer can be resolved as west.test.com.

ServerName west.test.com:80

Where should you place all web pages?
DocumentRoot "/var/www/html"

By default, Apache searches the DocumentRoot directory for index.html.

If you have a default.htm file as your home page, you could create a symbolic link as follows:
[root@west html]#ln -s default.htm index.html

====
Allow a regular user (e.g. developer) to upload web pages by ftp
useradd -d /var/www/html -g users developer

Allow everyone, including the httpd daemon, read the content of /var/www/html.
Set owner and its primary group to developer and users

[root@west ~]#chown -R developer:users /var/www/html
[root@west ~]#chmod 755 /var/www/html
====

CGI Scripts


PERL and PHP languages can be used to create CGI Scripts, which generate new Web page output or update data files, etc.
/etc/httpd/conf/httpd.conf
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

[root@test ~]# mkdir /var/www/cgi-bin/test
[root@test ~]# chcon -h -t httpd_sys_script_exec_t /var/www/cgi-bin/
[root@test ~]# ls -Z /home/www/cgi-bin
drwxr-xr-x root root root:object_r:httpd_sys_script_exec_t test
[root@test ~]# vi /home/www/cgi-bin/test/test.cgi
[root@test ~]# chmod o+x /home/www/cgi-bin/test/test.cgi