nginx安装教程(详解)编译安装

nginx安装教程(编译安装)

1、安装编译环境

yum -y install gcc gcc-c++ make ncurses ncurses-devel

2、安装pcre软件包(使nginx支持http rewrite模块)

yum install -y pcre pcre-devel

3、安装openssl-devel(使nginx支持ssl)

yum install -y openssl openssl-devel 

4、安装zlib

yum install -y zlib zlib-devel

5、创建用户nginx

useradd nginx 

6、安装nginx

yum -y install wget

7、官网复制下载链接

nginx安装教程(详解)编译安装_第1张图片

8、使用wget下载

wget https://nginx.org/download/nginx-1.22.0.tar.gz

9、解压

[root@salve-2 ~]# ls
anaconda-ks.cfg  nginx-1.22.0.tar.gz
[root@salve-2 ~]# tar xf nginx-1.22.0.tar.gz 
[root@salve-2 ~]# ls
anaconda-ks.cfg  nginx-1.22.0  nginx-1.22.0.tar.gz
[root@salve-2 ~]# 

10、安装编译

[root@salve-2 ~]# cd nginx-1.22.0
[root@salve-2 nginx-1.22.0]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[root@salve-2 nginx-1.22.0]# ./configure --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log 
[root@salve-2 nginx-1.22.0]# make && make install

11、启动

启动:
[root@salve-2 nginx-1.22.0]# cd /usr/local/nginx/sbin/
[root@salve-2 sbin]# ls
nginx
[root@localhost sbin]# ./nginx

12、nginx相关服务

启动nginx服务
[root@localhost ~]# /usr/local/nginx/sbin/nginx

通过 nginx 命令控制 nginx 服务

nginx -c /path/nginx.conf  	     # 以特定目录下的配置文件启动nginx:
nginx -s reload            	 	 # 修改配置后重新加载生效
nginx -s reopen   			 	 # 重新打开日志文件
nginx -s stop  				 	 # 快速停止nginx
nginx -s quit  				  	 # 完整有序的停止nginx
nginx -t    					 # 测试当前配置文件是否正确
nginx -t -c /usr/lcoal/nginx/conf/nginx.conf  # 测试特定的nginx配置文件是否正确

nginx编译完成!

你可能感兴趣的:(#,nginx安装,nginx,服务器,运维)