Starting Apache httpd web server apache2
[so:warn] [pid 12841] AH01574: module dav_module is already loaded, skipping
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'Server
Action 'start' failed.
The Apache error log may have more information.
*
* Stopping Apache httpd web server apache2
*
原本是从mods-available复制ssl.conf ,ssl.load 等文件到mods-enables, 结果也是这样。查了一下
sudo a2enmod ssl
这条命令相当于
sudo ln -s /etc/apache2/mods-available/ssl.load /etc/apache2/mods-enabled
sudo ln -s /etc/apache2/mods-available/ssl.conf /etc/apache2/mods-enabled
如果没有a2enmod指令,也可直接在apache2.conf中设置SSL模块加载:
LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
后来从网上找到:
# httpd -t [Fri Jun 08 11:12:19 2012] [warn] module ssl_module is already loaded, skipping Syntax OK |
This happens, because ssl module is enabled in more than 1 place:
# grep ssl_module -rI /etc/httpd/* conf/httpd.conf:LoadModule ssl_module /usr/lib64/httpd/modules/mod_ssl.so conf.d/ssl.conf:LoadModule ssl_module modules/mod_ssl.so
1 2 3 | # grep ssl_module -rI /etc/httpd/* conf/httpd.conf:LoadModule ssl_module /usr/lib64/httpd/modules/mod_ssl.so conf.d/ssl.conf:LoadModule ssl_module modules/mod_ssl.so |
we load all needed modules in one place – /etc/httpd/conf/httpd.conf.
So we can safely comment out in /etc/httpd/conf.d/ssl.conf file.
edit /etc/httpd/conf.d/ssl.conf file
and comment out this line:
#LoadModule ssl_module modules/mod_ssl.so
1 | #LoadModule ssl_module modules/mod_ssl.so |
save file, and problem fixed:
然后我打开一个新的端口:
1, 修改 /etc/apache2/ports.conf 将
NameVirtualHost *:80 Listen 80
改为自己需要的端口
NameVirtualHost *:9000 Listen 9000
2,修改/etc/apache2/sites-available/default 将第一行的
<VirtualHost *:80>
改为自己需要的端口
<VirtualHost *:9000>
ln -s 到 sites-enable
<VirtualHost *:9000>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
#ServerAdmin webmaster@localhost
#ServerName site1.com
DocumentRoot /var/www/test1
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
3,找到证书以key的配置路径在/etc/apache2/sites-enabled/default-ssl ,配置以下三处
SSLCertificateFile /etc/apache2/ssl/httpd.cert
SSLCertificateKeyFile /etc/apache2/ssl/httpd.key
SSLCertificateChainFile /etc/apache2/ssl/cacert.pem (这里cacert.pem和httpd.cert内容完全一样)
生成证书时,配置common name = 本机IP,否则验证时无法使用,命令如下:
openssl req -x509 -nodes -newkey ras:2048 -keyout server.key -out server.crt -days 10950