赞
踩
我习惯将软件安装在/tools/xxx对应目录下,因此这次安装为/tools/nginx/
#我习惯将源码安装包放到这里面,并且安装到/tools/nginx里面
cd /tools/installbags/
wget http://nginx.org/download/nginx-1.22.0.tar.gz
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
#可以选择自己安装包放置的路径
cd /tools/installbags/
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
#解压压缩包
tar zxvf pcre-8.35.tar.gz
#进入解压目录
cd pcre-8.35/
./configure
#安装
make && make install
#查看pcre版本
pcre-config --version
cd tools
#创建nginx安装目录
mkdir nginx
cd /tools/installbags/
#解压
tar zxvf nginx-1.22.0.tar.gz
#进入解压文件夹
cd nginx-1.22.0
#简易配置(2选1)
./configure --prefix=/tools/nginx
#指定配置(2选1)
./configure --prefix=/tools/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/tools/installbags/pcre-8.35
make && make install
注意,我安装nginx的目录为/tools/nginx/
# 启动。默认监听80端口,启动成功之后可以浏览器访问ip:80,出现4.2中图表示centos服务器上nginx启动成功
/tools/nginx/sbin/nginx
# 重新载入配置文件
/tools/nginx/sbin/nginx -s reload
# 重启 Nginx
/tools/nginx/sbin/nginx -s reopen
# 强制停止 Nginx
/tools/nginx/sbin/nginx -s stop
# 优雅停止 Nginx,在退出前完成已经接受的连接请求
/tools/nginx/sbin/nginx -s quit
# 检查nginx.conf文件正确性
/tools/nginx/sbin/nginx -t
[root@VM-12-16-centos ~]# /tools/nginx/sbin/nginx -t
nginx: the configuration file /tools/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /tools/nginx/conf/nginx.conf test is successful
# 进入系统服务脚本目录
cd /usr/lib/systemd/system
# 创建ngxin服务相关脚本
touch nginx.service
(注意我的目录是tools/nginx,根据需要进行更改)
[Unit] Description=nginx - web server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/tools/nginx/logs/nginx.pid ExecStartPre=/tools/nginx/sbin/nginx -t -c /tools/nginx/conf/nginx.conf ExecStart=/tools/nginx/sbin/nginx -c /tools/nginx/conf/nginx.conf ExecReload=/tools/nginx/sbin/nginx -s reload ExecStop=/tools/nginx/sbin/nginx -s stop ExecQuit=/tools/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target
systemctl daemon-reload
systemctl start nginx.service
systemctl enable nginx.service
systemctl status nginx.service
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。