Installing Apache 2

Here is an example to configure Apache. I set it that users can open to the public their Web site and can execute CGI in any directories.[root@www ~]#vi /etc/httpd/conf/httpd.conf
ServerTokens
Prod

// line 44: change

KeepAlive

On

// line 74: change to ON

ServerAdmin

root@server-linux.info

// line 250: Admin’s address

ServerName

http://www.server-linux.info:80

// line 264: server’s name

Options FollowSymLinks

ExecCGI

// line 319: change (disable Indexes)

AllowOverride

All

// line 326: change

#

UserDir disable

// line 354: make it comment

UserDir public_html

// line 361: make valid

// line 369 – 380 : remove # and make valid

<Directory /home/*/public_html>
AllowOverride

All

// change

Options

ExecCGI

// CGI enabled

<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>

// line 390: add file name that it can access only with directory’s name

DirectoryIndex index.html

index.cgi index.php

ServerSignature

Off

// line 523: change

#

AddDefaultCharset UTF-8

// line 746: make it comment

// line 777: make valid and add file-type that apache looks them CGI

AddHandler cgi-script .cgi

.pl

[root@www ~]#

/etc/rc.d/init.d/httpd start

Starting httpd:

[ OK ]

[root@www ~]#

chkconfig httpd on
[2]     Make HTML test page and Make sure apache is working. It’s OK if following page is shown.

[root@www ~]#

cd /var/www/html

[root@www 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@www ~]#

cd /var/www/html

[root@www 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@www ~]#

chmod 705 index.cgi

[4]     Make PHP test page and Make sure apache is working. It’s OK if following page is shown.

[root@www ~]#

cd /var/www/html

[root@www 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>

Here is an example to configure Apache. I set it that users can open to the public their Web site and can execute CGI in any directories.[root@www ~]#

vi /etc/httpd/conf/httpd.conf

ServerTokens

Prod

// line 44: change

KeepAlive

On

// line 74: change to ON

ServerAdmin

root@server-linux.info

// line 250: Admin’s address

ServerName

http://www.server-linux.info:80

// line 264: server’s name

Options FollowSymLinks

ExecCGI

// line 319: change (disable Indexes)

AllowOverride

All

// line 326: change

#

UserDir disable

// line 354: make it comment

UserDir public_html

// line 361: make valid

// line 369 – 380 : remove # and make valid

<Directory /home/*/public_html>
AllowOverride

All

// change

Options

ExecCGI

// CGI enabled

<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>

// line 390: add file name that it can access only with directory’s name

DirectoryIndex index.html

index.cgi index.php

ServerSignature

Off

// line 523: change

#

AddDefaultCharset UTF-8

// line 746: make it comment

// line 777: make valid and add file-type that apache looks them CGI

AddHandler cgi-script .cgi

.pl

[root@www ~]#

/etc/rc.d/init.d/httpd start

Starting httpd:

[ OK ]

[root@www ~]#

chkconfig httpd on
[2]     Make HTML test page and Make sure apache is working. It’s OK if following page is shown.

[root@www ~]#

cd /var/www/html

[root@www 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@www ~]#

cd /var/www/html

[root@www 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@www ~]#

chmod 705 index.cgi

[4]     Make PHP test page and Make sure apache is working. It’s OK if following page is shown.

[root@www ~]#

cd /var/www/html

[root@www 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>

Advertisements

Trả lời

Mời bạn điền thông tin vào ô dưới đây hoặc kích vào một biểu tượng để đăng nhập:

WordPress.com Logo

Bạn đang bình luận bằng tài khoản WordPress.com Đăng xuất / Thay đổi )

Twitter picture

Bạn đang bình luận bằng tài khoản Twitter Đăng xuất / Thay đổi )

Facebook photo

Bạn đang bình luận bằng tài khoản Facebook Đăng xuất / Thay đổi )

Google+ photo

Bạn đang bình luận bằng tài khoản Google+ Đăng xuất / Thay đổi )

Connecting to %s

%d bloggers like this: