一、Nginx安装——openresty

257 阅读1分钟

Nginx官网:www.nginx.com/

Nginx中文文档:www.nginx.cn/doc/

Nginx安装

1、制作安装shell脚本

cd /usr/local/
vim openresty.sh
yum install -y pcre-devel openssl-devel gcc curl
cd /usr/local/
wget https://openresty.org/download/openresty-1.17.8.2.tar.gz
cd /usr/local/
tar -zxvf openresty-1.17.8.2.tar.gz
cd /usr/local/
mv openresty-1.17.8.2 openresty
cd /usr/local/openresty/
./configure --with-luajit --without-http_redis2_module --with-http_iconv_module
cd /usr/local/openresty/ 
make && make install

2、赋予执行文件权限

chmod +x openresty.sh

3、运行shell脚本

./openresty.sh

4、修改环境变量

vi /etc/profile
exportPATH=/usr/local/openresty/nginx/sbin:$PATH
source/etc/profile

5、运行Nginx

./nginx/sbin/nginx

6、访问页面

image.png

Nginx常用命令

nginx -s reopen 重启Nginx

nginx -s reload 重新加载Nginx配置文件,然后重启Nginx

nginx -s stop 强制停止Nginx服务

nginx -s quit 处理完所有请求后再停止服务(推荐使用)

nginx -t 检测配置文件是否有语法错误,然后退出

nginx -?,-h 打开帮助信息

nginx -v 显示版本信息并退出

nginx -V 显示版本和配置选项信息,然后退出

nginx -t 检测配置文件是否有语法错误,然后退出

nginx -T 检测配置文件是否有语法错误,转储并退出

nginx -q 在检测配置文件期间屏蔽非错误信息,只输出错误信息

nginx -p prefix 设置前缀路径(默认是:/usr/share/nginx/)

nginx -c filename 设置配置文件(默认是:/etc/nginx/nginx.conf)

nginx -g directives 设置配置文件外的全局指令