Home CentOS安装Nginx
Post
Cancel

CentOS安装Nginx

1. 下载Nginx安装包

1
http://nginx.org/download/

2. 解压Nginx压缩包

1
tar zxvf nginx-1.23.4.tar.gz

3. 进入Nginx目录下

1
cd /nginx/nginx-1.23.4

4. 配置安装运行目录

1
./configure --prefix=/usr/local/nginx

5. 出现错误需要安装依赖包

1
2
3
4
5
yum -y install pcre-devel
yum -y install gcc
yum -y install openssl openssl-devel
# 进行重新配置
./configure --prefix=/usr/local/nginx

6. 执行编译安装

1
make && make install

7. 安装完毕,进入Nginx下的sbin目录并启动Nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
cd /usr/local/nginx/sbin
# 启动nginx
./nginx
# 或
./nginx -c /usr/local/nginx/conf/nginx.conf
# 停止nginx
./nginx -s stop
# 停止nginx(等待进程处理完毕进行关闭)
./nginx -s quit
# 重启nginx
./nginx -s reload
# 查看Nginx配置是否正确
nginx -t 
This post is licensed under CC BY 4.0 by the author.