Nginx 安装笔记+SSL虚拟主机配置
Published on 2015 - 05 - 05
Nginx线上服务器无错安装笔记
1.安装
1.1 下载安装包后 安装依赖
yum -y install gcc gcc-c++ pcre pcre-devel openssl openssl-devel gd gd-devel perl perl-ExtUtils-Embed zlib zlib-devel libtool libtool-devel
1.2 进入目录后运行编译命令
./configure --prefix=/usr/local/nginx --with-ipv6 --with-http_ssl_module --with_httpd-realip_module --with_http_addition_module --with_http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_perl_module --with-mail --with-mail_ssl_module
1.3 开始编译
make && make install
2.启动
启动Nginx
2.1进入Nginx Sbin目录
./nginx
2.2重新加载配置文件
./nginx -s reload
2.3关闭服务
./nginx -s stop
3.SSL配置文件
#HTTPS server
server {
listen 443;
server_name www.rich.com;
ssl on;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
4.自签SSL证书文件
openssl genrsa -out cert.key 2048
openssl req -new -x509 -key cert.key -out cert.pem
#需要输入生成信息
echo "Error,file not found>/usr/local/nginx/html 404.html"