关于网站添加SLL证书后,在Apache服务器在启动时。
启动命令:service httpd restart
偶然会出现如下报错
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
字面理解是443端口被占用;
注:443是https的端口
原因分析:443占用,不能再监听一个443端口了。
解决办法:
1. 临时办法
执行命令:netstat -tulnp|grep 443
杀掉443占用的进程。
注意:多数情况下也会有执行命令:netstat -tulnp|grep 443。没有任何进程的情况。这个就要去看下httpd.conf文件的配置了;
2.永久办法:
2.1、将Listen 443注释掉
2.2、如果没有NameVirtualHost *:443,则添加一行;
如例:
#Listen 443
#配置虚拟机端口号
NameVirtualHost *:443
<VirtualHost *:443>
ServerName www.xxx.com
#配置SSL证书
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite AES128-SHA:HIGH:!aNULL:!MD5:TLS1.1:TLS1.2:-RC4+RSA
DocumentRoot "/var/www/html/app/src/htdocs_www"
SSLCertificateFile /etc/httpd/conf/cer/2_www.xxx.com.crt
SSLCertificateKeyFile /etc/httpd/conf/cer/3_www.xxx.com.key
SSLCertificateChainFile /etc/httpd/conf/cer/1_root_bundle.crt
#重定向
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/reg/(\d+)/$ /reg$1.php [L]
RewriteRule ^/logout/$ /logout.php [L]
RewriteRule ^/forget/$ /forget_password.php [L]
RewriteRule ^/pdf/(\w+)/(\w+)/$ /pdf.php?type=$1&id_code=$2 [L]
RewriteRule ^/product/(.*)$ /product_list.php?$1 [L]
RewriteRule ^/detail/(\w+)/$ /product_detail.php?id_code=$1 [L]
RewriteRule ^/property/(\w+)/$ /product_ad.php?section_id_code=$1 [L]
RewriteRule ^/about/(\w+)/(.*)$ /about.php?flag=$1&$2 [L]
RewriteRule ^/login/weixinlogin/$ /weixin_login.php [L]
RewriteRule ^/login/weixin_code_callback/?(.*)$ /weixin_logincallback.php?$1 [L]
RewriteRule ^/login/qqlogin/$ /qq_login.php [L]
RewriteRule ^/login/qq_code_callback/?(.*)$ /qq_logincallback.php?$1 [L]
RewriteRule ^/doc/(\w+)/(.*)$ /documents.php?flag=$1&$2 [L]
RewriteRule ^/app/(.*)$ /app.php?$1 [L]
RewriteRule ^/home/(.*)$ /home.php?sub=$1 [L]
RewriteRule ^(.*)\.htm(.*)$ $1.php$2 [L]
</IfModule>
</VirtualHost>