上季我们讲到虚拟主机的实现、还有apache的basic访问控制,本季我们将学习CGI的支持,php的支持,jsp的支持
重新启动下你的apache,看看还能不能正常工作
最好把这个访问控制取消了,大家知道怎么取消么?
在目录权限里面,把Authconfig 参数改成none
然后重新启动服务
现在进去就不需要密码了
基于IP的虚拟主机,就是在一个服务器上有多个IP,访问不同的IP,访问到不同的网站,配置相当简单。
给网卡增加一个IP地址
我们这种方法是临时的增加一个IP地址,如果想要这个IP地址在网卡重新启动以后还要有效,就需要修改配置文件,我们先重新启动网卡试试
刚才建立的虚拟网卡就消失了,下面我们来配置一个长期有效的虚拟网卡
进入 /etc/sysconfig/network-scripts/网络设备的配置文件目录
然后用vim修改eth0:0
我修改了3个地方
1、DEVICE名字
2、IP地址
3、删除了MAC地址
1、DEVICE名字
2、IP地址
3、删除了MAC地址
然后保存退出,重新启动网卡
现在虚拟网卡就一直有效了,用xp ping下看能不能ping通虚拟网卡
OK,下面我们开始修改配置文件,让服务器支持基于IP的虚拟主机
注释这行#NameVirtualHost 192.168.8.188:80
然后修改virtualhost的IP地址
下面对应相对的目录和域名
Documentroot 是用户目录
servername 是域名
保存退出后,重新启动服务器
##################Michael分割线######################
下一个功能,支持Cgi
1、安装perl包
yum install perl*
[root@masterdns ~]# yum install perl*
Loading "security" plugin Loading "rhnplugin" plugin Loading "installonlyn" plugin This system is not registered with RHN. RHN support will be disabled. Setting up Install Process Setting up repositories rhel-Server 100% |=========================| 1.1 kB 00:00 rhel-VT 100% |=========================| 1.1 kB 00:00 Reading repository metadata in from local files primary.xml.gz 100% |=========================| 753 kB 00:00 ################################################## 2158/2158 primary.xml.gz 100% |=========================| 9.5 kB 00:00 ################################################## 31/31 Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Downloading header for perl-IO-Socket-INET6 to pack into transaction set. perl-IO-Socket-INET6-2.51 100% |=========================| 2.7 kB 00:00 ---> Package perl-IO-Socket-INET6.noarch 0:2.51-2.fc6 set to be updated ---> Downloading header for perl-Archive-Tar to pack into transaction set. perl-Archive-Tar-1.30-1.f 100% |=========================| 5.0 kB 00:00 ---> Package perl-Archive-Tar.noarch 0:1.30-1.fc6 set to be updated ---> Downloading header for perl-Convert-ASN1 to pack into transaction set. perl-Convert-ASN1-0.20-1. 100% |=========================| 4.3 kB 00:00 ---> Package perl-Convert-ASN1.noarch 0:0.20-1.1 set to be updated ---> Downloading header for perl-Net-Telnet to pack into transaction set. perl-Net-Telnet-3.03-5.no 100% |=========================| 3.5 kB 00:00 ---> Package perl-Net-Telnet.noarch 0:3.03-5 set to be updated ---> Downloading header for perl-SGMLSpm to pack into transaction set. perl-SGMLSpm-1.03ii-16.2. 100% |=========================| 4.0 kB 00:00 ---> Package perl-SGMLSpm.noarch 0:1.03ii-16.2.1 set to be updated ---> Downloading header for perl-Mozilla-LDAP to pack into transaction set. perl-Mozilla-LDAP-1.5.2-4 100% |=========================| 6.5 kB 00:00 ---> Package perl-Mozilla-LDAP.i386 0:1.5.2-4.el5 set to be updated ---> Downloading header for perl-NKF to pack into transaction set. perl-NKF-2.07-1.1.fc6.i38 100% |=========================| 6.0 kB 00:00 ---> Package perl-NKF.i386 0:2.07-1.1.fc6 set to be updated ---> Downloading header for perl-XML-Grove to pack into transaction set. perl-XML-Grove-0.46alpha- 100% |=========================| 8.7 kB 00:00 ---> Package perl-XML-Grove.noarch 0:0.46alpha-29.1.1 set to be updated ---> Downloading header for perl-LDAP to pack into transaction set. perl-LDAP-0.33-3.fc6.noar 100% |=========================| 16 kB 00:00 ---> Package perl-LDAP.noarch 1:0.33-3.fc6 set to be updated ---> Downloading header for perl-BSD-Resource to pack into transaction set. perl-BSD-Resource-1.28-1. 100% |=========================| 7.1 kB 00:00 ---> Package perl-BSD-Resource.i386 0:1.28-1.fc6.1 set to be updated ---> Downloading header for perl-Date-Calc to pack into transaction set. perl-Date-Calc-5.4-1.2.2. 100% |=========================| 9.8 kB 00:00 ---> Package perl-Date-Calc.i386 0:5.4-1.2.2.1 set to be updated ---> Downloading header for perl-Crypt-SSLeay to pack into transaction set. perl-Crypt-SSLeay-0.51-11 100% |=========================| 6.9 kB 00:00 ---> Package perl-Crypt-SSLeay.i386 0:0.51-11.el5 set to be updated ---> Downloading header for perl-Socket6 to pack into transaction set. perl-Socket6-0.19-3.fc6.i 100% |=========================| 3.3 kB 00:00 ---> Package perl-Socket6.i386 0:0.19-3.fc6 set to be updated ---> Downloading header for perl-Digest-HMAC to pack into transaction set. perl-Digest-HMAC-1.01-15. 100% |=========================| 3.7 kB 00:00 ---> Package perl-Digest-HMAC.noarch 0:1.01-15 set to be updated ---> Downloading header for perl-XML-Twig to pack into transaction set. perl-XML-Twig-3.26-1.fc6. 100% |=========================| 5.8 kB 00:00 ---> Package perl-XML-Twig.noarch 0:3.26-1.fc6 set to be updated ---> Downloading header for perl-Carp-Clan to pack into transaction set. perl-Carp-Clan-5.3-1.2.1. 100% |=========================| 3.2 kB 00:00 ---> Package perl-Carp-Clan.noarch 0:5.3-1.2.1 set to be updated ---> Downloading header for perl-Digest-SHA1 to pack into transaction set. perl-Digest-SHA1-2.11-1.2 100% |=========================| 5.2 kB 00:00 ---> Package perl-Digest-SHA1.i386 0:2.11-1.2.1 set to be updated ---> Downloading header for perl-XML-Parser to pack into transaction set. perl-XML-Parser-2.34-6.1. 100% |=========================| 9.4 kB 00:00 ---> Package perl-XML-Parser.i386 0:2.34-6.1.2.2.1 set to be updated ---> Downloading header for perl-IO-Zlib to pack into transaction set. perl-IO-Zlib-1.04-4.2.1.n 100% |=========================| 4.1 kB 00:00 ---> Package perl-IO-Zlib.noarch 0:1.04-4.2.1 set to be updated ---> Downloading header for perl-TimeDate to pack into transaction set. perl-TimeDate-1.16-5.el5. 100% |=========================| 7.8 kB 00:00 ---> Package perl-TimeDate.noarch 1:1.16-5.el5 set to be updated ---> Downloading header for perl-DBI to pack into transaction set. perl-DBI-1.52-1.fc6.i386. 100% |=========================| 16 kB 00:00 ---> Package perl-DBI.i386 0:1.52-1.fc6 set to be updated ---> Downloading header for perl-DBD-Pg to pack into transaction set. perl-DBD-Pg-1.49-1.fc6.i3 100% |=========================| 6.3 kB 00:00 ---> Package perl-DBD-Pg.i386 0:1.49-1.fc6 set to be updated ---> Downloading header for perl-Net-IP to pack into transaction set. perl-Net-IP-1.25-2.fc6.no 100% |=========================| 4.8 kB 00:00 ---> Package perl-Net-IP.noarch 0:1.25-2.fc6 set to be updated ---> Downloading header for perl-XML-SAX to pack into transaction set. perl-XML-SAX-0.14-5.noarc 100% |=========================| 7.1 kB 00:00 ---> Package perl-XML-SAX.noarch 0:0.14-5 set to be updated ---> Downloading header for perl-XML-Simple to pack into transaction set. perl-XML-Simple-2.14-4.fc 100% |=========================| 4.6 kB 00:00 ---> Package perl-XML-Simple.noarch 0:2.14-4.fc6 set to be updated ---> Downloading header for perl-IO-Socket-SSL to pack into transaction set. perl-IO-Socket-SSL-1.01-1 100% |=========================| 6.4 kB 00:00 ---> Package perl-IO-Socket-SSL.noarch 0:1.01-1.fc6 set to be updated ---> Downloading header for perl-XML-LibXML-Common to pack into transaction set. perl-XML-LibXML-Common-0. 100% |=========================| 4.4 kB 00:00 ---> Package perl-XML-LibXML-Common.i386 0:0.13-8.2.2 set to be updated ---> Downloading header for perl-XML-Dumper to pack into transaction set. perl-XML-Dumper-0.81-2.fc 100% |=========================| 4.1 kB 00:00 ---> Package perl-XML-Dumper.noarch 0:0.81-2.fc6 set to be updated ---> Downloading header for perl-DateManip to pack into transaction set. perl-DateManip-5.44-1.2.1 100% |=========================| 3.4 kB 00:00 ---> Package perl-DateManip.noarch 0:5.44-1.2.1 set to be updated ---> Downloading header for perl-XML-LibXML to pack into transaction set. perl-XML-LibXML-1.58-5.i3 100% |=========================| 12 kB 00:00 ---> Package perl-XML-LibXML.i386 0:1.58-5 set to be updated ---> Downloading header for perl-XML-NamespaceSupport to pack into transaction set. perl-XML-NamespaceSupport 100% |=========================| 3.0 kB 00:00 ---> Package perl-XML-NamespaceSupport.noarch 0:1.09-1.2.1 set to be updated ---> Downloading header for perl-suidperl to pack into transaction set. perl-suidperl-5.8.8-10.i3 100% |=========================| 23 kB 00:00 ---> Package perl-suidperl.i386 4:5.8.8-10 set to be updated ---> Downloading header for perl-Net-DNS to pack into transaction set. perl-Net-DNS-0.59-3.el5.i 100% |=========================| 19 kB 00:00 ---> Package perl-Net-DNS.i386 0:0.59-3.el5 set to be updated ---> Downloading header for perl-DBD-MySQL to pack into transaction set. perl-DBD-MySQL-3.0007-1.f 100% |=========================| 8.5 kB 00:00 ---> Package perl-DBD-MySQL.i386 0:3.0007-1.fc6 set to be updated ---> Downloading header for perl-Bit-Vector to pack into transaction set. perl-Bit-Vector-6.4-2.2.2 100% |=========================| 6.9 kB 00:00 ---> Package perl-Bit-Vector.i386 0:6.4-2.2.2.1 set to be updated ---> Downloading header for perl-IO-String to pack into transaction set. perl-IO-String-1.08-1.1.1 100% |=========================| 3.5 kB 00:00 ---> Package perl-IO-String.noarch 0:1.08-1.1.1 set to be updated ---> Downloading header for perl-libxml-perl to pack into transaction set. perl-libxml-perl-0.08-1.2 100% |=========================| 8.7 kB 00:00 ---> Package perl-libxml-perl.noarch 0:0.08-1.2.1 set to be updated ---> Downloading header for perl-Net-SSLeay to pack into transaction set. perl-Net-SSLeay-1.30-4.fc 100% |=========================| 16 kB 00:00 ---> Package perl-Net-SSLeay.i386 0:1.30-4.fc6 set to be updated --> Running transaction check --> Processing Dependency: libmysqlclient.so.15 for package: perl-DBD-MySQL --> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15) for package: perl-DBD-MySQL --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. ---> Downloading header for mysql to pack into transaction set. mysql-5.0.22-2.1.0.1.i386 100% |=========================| 36 kB 00:00 ---> Package mysql.i386 0:5.0.22-2.1.0.1 set to be updated --> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size ============================================================================= Installing: perl-Archive-Tar noarch 1.30-1.fc6 rhel-Server 47 k perl-BSD-Resource i386 1.28-1.fc6.1 rhel-Server 29 k perl-Bit-Vector i386 6.4-2.2.2.1 rhel-Server 179 k perl-Carp-Clan noarch 5.3-1.2.1 rhel-Server 22 k perl-Convert-ASN1 noarch 0.20-1.1 rhel-Server 41 k perl-Crypt-SSLeay i386 0.51-11.el5 rhel-Server 45 k perl-DBD-MySQL i386 3.0007-1.fc6 rhel-Server 147 k perl-DBD-Pg i386 1.49-1.fc6 rhel-Server 114 k perl-DBI i386 1.52-1.fc6 rhel-Server 605 k perl-Date-Calc i386 5.4-1.2.2.1 rhel-Server 270 k perl-DateManip noarch 5.44-1.2.1 rhel-Server 143 k perl-Digest-HMAC noarch 1.01-15 rhel-Server 12 k perl-Digest-SHA1 i386 2.11-1.2.1 rhel-Server 49 k perl-IO-Socket-INET6 noarch 2.51-2.fc6 rhel-Server 13 k perl-IO-Socket-SSL noarch 1.01-1.fc6 rhel-Server 49 k perl-IO-String noarch 1.08-1.1.1 rhel-Server 13 k perl-IO-Zlib noarch 1.04-4.2.1 rhel-Server 15 k perl-LDAP noarch 1:0.33-3.fc6 rhel-Server 316 k perl-Mozilla-LDAP i386 1.5.2-4.el5 rhel-Server 180 k perl-NKF i386 2.07-1.1.fc6 rhel-Server 118 k perl-Net-DNS i386 0.59-3.el5 rhel-Server 215 k perl-Net-IP noarch 1.25-2.fc6 rhel-Server 31 k perl-Net-SSLeay i386 1.30-4.fc6 rhel-Server 195 k perl-Net-Telnet noarch 3.03-5 rhel-Server 56 k perl-SGMLSpm noarch 1.03ii-16.2.1 rhel-Server 17 k perl-Socket6 i386 0.19-3.fc6 rhel-Server 22 k perl-TimeDate noarch 1:1.16-5.el5 rhel-Server 32 k perl-XML-Dumper noarch 0.81-2.fc6 rhel-Server 23 k perl-XML-Grove noarch 0.46alpha-29.1.1 rhel-Server 67 k perl-XML-LibXML i386 1.58-5 rhel-Server 231 k perl-XML-LibXML-Common i386 0.13-8.2.2 rhel-Server 16 k perl-XML-NamespaceSupport noarch 1.09-1.2.1 rhel-Server 15 k perl-XML-Parser i386 2.34-6.1.2.2.1 rhel-Server 209 k perl-XML-SAX noarch 0.14-5 rhel-Server 75 k perl-XML-Simple noarch 2.14-4.fc6 rhel-Server 68 k perl-XML-Twig noarch 3.26-1.fc6 rhel-Server 192 k perl-libxml-perl noarch 0.08-1.2.1 rhel-Server 90 k perl-suidperl i386 4:5.8.8-10 rhel-Server 57 k Installing for dependencies: mysql i386 5.0.22-2.1.0.1 rhel-Server 3.0 M
Transaction Summary
============================================================================= Install 39 Package(s) Update 0 Package(s) Remove 0 Package(s)
Total download size: 7.0 M
Is this ok [y/N]: y Downloading Packages: (1/39): perl-IO-Socket-IN 100% |=========================| 13 kB 00:00 (2/39): perl-Archive-Tar- 100% |=========================| 47 kB 00:00 (3/39): perl-Convert-ASN1 100% |=========================| 41 kB 00:00 (4/39): perl-Net-Telnet-3 100% |=========================| 56 kB 00:00 (5/39): perl-SGMLSpm-1.03 100% |=========================| 17 kB 00:00 (6/39): perl-Mozilla-LDAP 100% |=========================| 180 kB 00:00 (7/39): perl-NKF-2.07-1.1 100% |=========================| 118 kB 00:00 (8/39): perl-XML-Grove-0. 100% |=========================| 67 kB 00:00 (9/39): perl-LDAP-0.33-3. 100% |=========================| 316 kB 00:00 (10/39): perl-BSD-Resourc 100% |=========================| 29 kB 00:00 (11/39): perl-Date-Calc-5 100% |=========================| 270 kB 00:00 (12/39): perl-Crypt-SSLea 100% |=========================| 45 kB 00:00 (13/39): perl-Socket6-0.1 100% |=========================| 22 kB 00:00 (14/39): perl-Digest-HMAC 100% |=========================| 12 kB 00:00 (15/39): perl-XML-Twig-3. 100% |=========================| 192 kB 00:00 (16/39): perl-Carp-Clan-5 100% |=========================| 22 kB 00:00 (17/39): mysql-5.0.22-2.1 100% |=========================| 3.0 MB 00:00 (18/39): perl-Digest-SHA1 100% |=========================| 49 kB 00:00 (19/39): perl-XML-Parser- 100% |=========================| 209 kB 00:00 (20/39): perl-IO-Zlib-1.0 100% |=========================| 15 kB 00:00 (21/39): perl-TimeDate-1. 100% |=========================| 32 kB 00:00 (22/39): perl-DBI-1.52-1. 100% |=========================| 605 kB 00:00 (23/39): perl-DBD-Pg-1.49 100% |=========================| 114 kB 00:00 (24/39): perl-Net-IP-1.25 100% |=========================| 31 kB 00:00 (25/39): perl-XML-SAX-0.1 100% |=========================| 75 kB 00:00 (26/39): perl-XML-Simple- 100% |=========================| 68 kB 00:00 (27/39): perl-IO-Socket-S 100% |=========================| 49 kB 00:00 (28/39): perl-XML-LibXML- 100% |=========================| 16 kB 00:00 (29/39): perl-XML-Dumper- 100% |=========================| 23 kB 00:00 (30/39): perl-DateManip-5 100% |=========================| 143 kB 00:00 (31/39): perl-XML-LibXML- 100% |=========================| 231 kB 00:00 (32/39): perl-XML-Namespa 100% |=========================| 15 kB 00:00 (33/39): perl-suidperl-5. 100% |=========================| 57 kB 00:00 (34/39): perl-Net-DNS-0.5 100% |=========================| 215 kB 00:00 (35/39): perl-DBD-MySQL-3 100% |=========================| 147 kB 00:00 (36/39): perl-Bit-Vector- 100% |=========================| 179 kB 00:00 (37/39): perl-IO-String-1 100% |=========================| 13 kB 00:00 (38/39): perl-libxml-perl 100% |=========================| 90 kB 00:00 (39/39): perl-Net-SSLeay- 100% |=========================| 195 kB 00:00 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: perl-XML-Parser ####################### [ 1/39] Installing: perl-DBI ####################### [ 2/39] Installing: perl-XML-NamespaceSupport ####################### [ 3/39] Installing: perl-XML-SAX ####################### [ 4/39] Installing: perl-Carp-Clan ####################### [ 5/39] Installing: mysql ####################### [ 6/39] Installing: perl-libxml-perl ####################### [ 7/39] Installing: perl-Net-SSLeay ####################### [ 8/39] Installing: perl-IO-Socket-SSL ####################### [ 9/39] Installing: perl-XML-LibXML-Common ####################### [10/39] Installing: perl-Net-IP ####################### [11/39] Installing: perl-IO-Zlib ####################### [12/39] Installing: perl-Digest-SHA1 ####################### [13/39] Installing: perl-Digest-HMAC ####################### [14/39] Installing: perl-Socket6 ####################### [15/39] Installing: perl-Convert-ASN1 ####################### [16/39] Installing: perl-IO-Socket-INET6 ####################### [17/39] Installing: perl-Archive-Tar ####################### [18/39] Installing: perl-Net-Telnet ####################### [19/39] Installing: perl-SGMLSpm ####################### [20/39] Installing: perl-Mozilla-LDAP ####################### [21/39] Installing: perl-NKF ####################### [22/39] Installing: perl-XML-Grove ####################### [23/39] Installing: perl-LDAP ####################### [24/39] Installing: perl-BSD-Resource ####################### [25/39] Installing: perl-Date-Calc ####################### [26/39] Installing: perl-Crypt-SSLeay ####################### [27/39] Installing: perl-XML-Twig ####################### [28/39] Installing: perl-TimeDate ####################### [29/39] Installing: perl-DBD-Pg ####################### [30/39] Installing: perl-XML-Simple ####################### [31/39] Installing: perl-XML-Dumper ####################### [32/39] Installing: perl-DateManip ####################### [33/39] Installing: perl-XML-LibXML ####################### [34/39] could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.8/XML/SAX Installing: perl-suidperl ####################### [35/39] Installing: perl-Net-DNS ####################### [36/39] Installing: perl-DBD-MySQL ####################### [37/39] Installing: perl-Bit-Vector ####################### [38/39] Installing: perl-IO-String ####################### [39/39]
Installed: perl-Archive-Tar.noarch 0:1.30-1.fc6 perl-BSD-Resource.i386 0:1.28-1.fc6.1 perl-Bit-Vector.i386 0:6.4-2.2.2.1 perl-Carp-Clan.noarch 0:5.3-1.2.1 perl-Convert-ASN1.noarch 0:0.20-1.1 perl-Crypt-SSLeay.i386 0:0.51-11.el5 perl-DBD-MySQL.i386 0:3.0007-1.fc6 perl-DBD-Pg.i386 0:1.49-1.fc6 perl-DBI.i386 0:1.52-1.fc6 perl-Date-Calc.i386 0:5.4-1.2.2.1 perl-DateManip.noarch 0:5.44-1.2.1 perl-Digest-HMAC.noarch 0:1.01-15 perl-Digest-SHA1.i386 0:2.11-1.2.1 perl-IO-Socket-INET6.noarch 0:2.51-2.fc6 perl-IO-Socket-SSL.noarch 0:1.01-1.fc6 perl-IO-String.noarch 0:1.08-1.1.1 perl-IO-Zlib.noarch 0:1.04-4.2.1 perl-LDAP.noarch 1:0.33-3.fc6 perl-Mozilla-LDAP.i386 0:1.5.2-4.el5 perl-NKF.i386 0:2.07-1.1.fc6 perl-Net-DNS.i386 0:0.59-3.el5 perl-Net-IP.noarch 0:1.25-2.fc6 perl-Net-SSLeay.i386 0:1.30-4.fc6 perl-Net-Telnet.noarch 0:3.03-5 perl-SGMLSpm.noarch 0:1.03ii-16.2.1 perl-Socket6.i386 0:0.19-3.fc6 perl-TimeDate.noarch 1:1.16-5.el5 perl-XML-Dumper.noarch 0:0.81-2.fc6 perl-XML-Grove.noarch 0:0.46alpha-29.1.1 perl-XML-LibXML.i386 0:1.58-5 perl-XML-LibXML-Common.i386 0:0.13-8.2.2 perl-XML-NamespaceSupport.noarch 0:1.09-1.2.1 perl-XML-Parser.i386 0:2.34-6.1.2.2.1 perl-XML-SAX.noarch 0:0.14-5 perl-XML-Simple.noarch 0:2.14-4.fc6 perl-XML-Twig.noarch 0:3.26-1.fc6 perl-libxml-perl.noarch 0:0.08-1.2.1 perl-suidperl.i386 4:5.8.8-10
Dependency Installed: mysql.i386 0:5.0.22-2.1.0.1 Complete! [root@masterdns ~]# |
2、修改配置文件
搜索关键字,找到这行
取消前面的注释,让apache支持cgi
然后找到需要支持cgi的目录权限设置位置
修改Options项的值是ALL,或者添加EXECCGI值,EXECCGI没有空格
然后重新启动apache
进入我们刚才设置的目录,我们写个简单的perl
如果CGI正常工作了,这个的输入效果是Welcome to CGI Website!,如果把代码都显示出来就证明没成功
3、给网站执行权限
然后给这个文件所有人有执行权限
OK了
还有一种方法,就是使用CGI别名的方式,就不用修改AddHandler, 我们也来试试吧
注释掉这行
#AddHandler cgi-script .cgi
不能访问了
找到这个位置
我们模仿他的写法把我们的cgi目录写进去
成功~
##################Michael分割线######################
本文转自redking51CTO博客,原文链接:http://blog.51cto.com/redking/154227,如需转载请自行联系原作者