-
下载地址
http://nginx.org/en/download.html (推荐Stable version(稳定版)) -
安装环境
yum install gcc-c++ pcre* openssl* -y
- 创建解压目录并解压
[root@localhost package]# ls
apache-zookeeper-3.6.2-bin.tar.gz kafka_2.12-2.7.0.tgz redis-6.2.1.tar.gz
jdk-8u281-linux-x64.tar.gz nginx-1.18.0.tar.gz
[root@localhost package]# mkdir /snt/soft/nginx
[root@localhost package]# tar -zxvf nginx-1.18.0.tar.gz -C /snt/soft/nginx
- 编译安装
[root@localhost package]# cd /snt/soft/nginx/nginx-1.18.0
[root@localhost nginx-1.18.0]# ./configure --prefix=/usr/local/nginx
[root@localhost nginx-1.18.0]# make
[root@localhost nginx-1.18.0]# make install
- 启动nginx
[root@localhost nginx-1.18.0]# cd /usr/local/nginx/sbin
[root@localhost sbin]# ./nginx
- 测试
访问:127.0.0.1(ip地址)
命令参考
验证nginx配置文件是否正确
进入nginx安装目录sbin下,输入命令./nginx -t
看到如下显示
nginx.conf syntax is ok
nginx.conf test is successful
说明配置文件正确!
Nginx命令
进入nginx可执行目录sbin下,输入命令
重启:./nginx -s reload
停止:./nginx -s stop
开启:./nginx -s start
- 添加环境变量
vim /etc/profile
PATH=$PATH:/snt/soft/nginx/nginx-install/sbin (nginx安装路径)
export PATH
保存退出后使用source生效配置文件
source /etc/profile
报错处理
https://blog.youkuaiyun.com/yu_pan_love_cat/article/details/103035513
- 参考
https://www.cnblogs.com/httpc/p/13410033.html
https://www.cnblogs.com/catlee/p/10290497.html