RedHat Linux 5 安装httpd 报错解决实例

[root@linuxidc.com ~]# rpm -ivh /media/Server/httpd-2.2.3-31.el5.i386.rpm
warning: /media/Server/httpd-2.2.3-31.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
libapr-1.so.0 is needed by httpd-2.2.3-31.el5.i386
libaprutil-1.so.0 is needed by httpd-2.2.3-31.el5.i386
此时报错,libapr-1.so.0在apr-1.2.7-11.el5_3.1.i386.rpm中,libaprutil-1.so.0在apr-util-1.2.7-7.el5_3.2.i386.rpm,安装这两个包
root@linuxidc.com ~]# rpm -ivh /media/Server/apr-1.2.7-11.el5_3.1.i386.rpm
root@linuxidc.com ~]# rpm -ivh /media/Server/apr-util-1.2.7-7.el5_3.2.i386.rpm
warning: /media/Server/apr-util-1.2.7-7.el5_3.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
libpq.so.4 is needed by apr-util-1.2.7-7.el5_3.2.i386.rpm
又报错,libpq.so.4在包postgresql-libs-8.1.11-1.el5_1.1.i386.rpm
root@linuxidc.com ~]# rpm -ivh /media/Server/postgresql-libs-8.1.11-1.el5_1.1.i386.rpm
再重新安装apr-util这个包,最后再装httpd-2.2.3就OK了。

如果要启用SSL的话,需要再安装个软件包mod_ssl-2.2.3-31.el5.i386.rpm
[root@dfa ~]# rpm -ivh /media/Server/mod_ssl-2.2.3-31.el5.i386.rpm
warning: /media/Server/mod_ssl-2.2.3-31.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
        libdistcache.so.1 is needed by mod_ssl-2.2.3-31.el5.i386
        libnal.so.1 is needed by mod_ssl-2.2.3-31.el5.i386
可以看到报错了, 依赖libdistcache.so.1和libnal.so.1安装下面的包可解决
[root@linuxidc.com ~]# rpm -ivh /media/Server/distcache-1.4.5-14.1.i386.rpm
再安装就不会报错了
[root@linuxidc.com ~]# rpm -ivh /media/Server/mod_ssl-2.2.3-31.el5.i386.rpm
warning: /media/Server/mod_ssl-2.2.3-31.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:mod_ssl                ########################################### [100%]
重启服务并查看443端口是否监听
[root@linuxidc.com ~]# service httpd restart
Stopping httpd:                                            [ OK ]
Starting httpd:                                            [ OK ]
[root@linuxidc.com ~]# netstat -ntpl | grep 443
tcp        0      0 :::80                       :::*                        LISTEN      4432/httpd         
tcp        0      0 :::443                      :::*                        LISTEN      4432/httpd         
至此已完成对Apache对SSL的支持,在浏览器中输入https://IP应该能正常访问。

证书的创建
cd /etc/pki/tls/certs/
make server.key
make server.crt
mv server.key ../private/
vi /etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/pki/tls/certs/server.crt
SSLCertificateKeyFile /etc/pki/tls/private/server.key


虚拟主机:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/
</VirtualHost>
<VirtualHost *:80>
ServerName
DocumentRoot /var/www/html/1
</VirtualHost>
<VirtualHost *:80>
ServerName
DocumentRoot /var/www/html/2
</VirtualHost>

对用htaccess实现用户认证
<Directory "/var/www/html/2">
Options FollowSymLinks
AllowOverride None
AuthType Basic
AuthName test
AuthUserFile /etc/httpd/conf/aufile
Require valid-user
</Directory>
htpasswd -c /etc/httpd/conf/aufile pp         #创建文件aufile并新增用户pp
htpasswd /etc/httpd/conf/aufile oo            #在原文件中新增用户oo

AddDefaultCharset GB2312                 #设置默认编码为GB2312,不建议使用,注释掉后,浏览器会自动检测

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wygygf.html