![](https://img.haomeiwen.com/i15336564/0b894551ae988981.png)
环境
Centos 7
安装
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
从官网http://nginx.org/en/download.html 下载最新的包 http://nginx.org/download/nginx-1.16.0.tar.gz
解压并设置编译参数
./configure \
--prefix=/opt/nginx \
--sbin-path=/opt/nginx/sbin/nginx \
--conf-path=/opt/nginx/conf/nginx.conf \
--error-log-path=/opt/nginx/logs/error.log \
--pid-path=/opt/nginx/nginx.pid \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--http-log-path=/opt/nginx/logs/access.log \
--http-client-body-temp-path=/opt/nginx/temp/client \
--http-proxy-temp-path=/opt/nginx/temp/proxy \
--http-fastcgi-temp-path=/opt/nginx/temp/fcgi \
--with-http_stub_status_module
make && make install
执行完成没有出错就说明安装完成了
配置成service
创建nginx.service文件
vim /usr/lib/systemd/system/nginx.service
写入文件内容:
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t -c /opt/nginx/conf/nginx.conf
ExecStart=/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
设置开机启动
systemctl enable nginx.service
操作Nginx
service nginx start
service nginx stop
service nginx restart
service nginx reload
问题解决
配置ssl后启动提示 listen ... ssl的警告,即ssl的开启方式改变了
原来配置是ssl on;
现在去掉这一句,然后在 listen 443后面加 ssl即listen 443 ssl;
网友评论