Configure httpd2009/06/14 |
[1] | Here is an example to configure Apache. This example shows that users can open to the public their Web site and can execute CGI in any directories. ( SSI is disabled because it's not used so often ) |
[root@www1 ~]# vi /etc/httpd/conf/httpd.conf # line 44: change ServerTokens Prod # line 74: change to ON KeepAlive On # line 248: webmaster's address ServerAdmin root@srv.world # line 262: server's name ServerName www1.srv.world:80 # line 317: change (disable Indexes) Options FollowSymLinks ExecCGI # line 324: change AllowOverride All # line 352: make it comment # UserDir disable# line 359: uncomment UserDir public_html # line 367 - 378 : uncomment <Directory /home/*/public_html> AllowOverride All # change Options ExecCGI # enable CGI <Limit GET POST OPTIONS> Order allow,deny Allow from all </Limit> <LimitExcept GET POST OPTIONS> Order deny,allow Deny from all </LimitExcept> </Directory> # line 388: add file name that it can access only with directory's name DirectoryIndex index.html index.cgi index.php # line 521: change ServerSignature Off # line 744: make it comment # AddDefaultCharset UTF-8# line 781: make valid and add file-type that apache looks them CGI AddHandler cgi-script .cgi .pl [root@www1 ~]# /etc/rc.d/init.d/httpd start Starting httpd: [ OK ] [root@www1 ~]# chkconfig httpd on |
[2] | Make HTML test page and Make sure apache is working. It's OK if following page is shown. |
[root@www1 ~]# cd /var/www/html [root@www1 html]# vi index.html
<html>
<body> <div style="width:100%;font-size:40px;font-weight:bold;text-align:center"> Test Page </div> </body> </html> |
[3] | Make CGI test page and Make sure apache is working. It's OK if following page is shown. |
[root@www1 ~]# cd /var/www/html [root@www1 html]# vi index.cgi
#!/usr/local/bin/perl print "Content-type: text/html\n\n"; print <<"EOM"; <html> <body> <div style="width:100%;font-size:40px;font-weight:bold;text-align:center"> CGI Test Page </div> </body> </html> EOM exit; [root@www1 html]# chmod 705 index.cgi |
[4] | Make PHP test page and Make sure apache is working. It's OK if following page is shown. |
[root@www1 ~]# cd /var/www/html [root@www1 html]# vi index.php
<html>
<body> <div style="width:100%;font-size:40px;font-weight:bold;text-align:center"> <?php print Date("Y/m/d"); ?> </div> </body> </html> |
Sponsored Link |