标签:环境变量 rip name 服务器ip Beginner install nginx stat tar.gz
yum install zlib-devel
yum install pcre-devel
yum install gcc
yum install openssl-devel
tar xzvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre --with-http_gunzip_module --with-http_gzip_static_module --with-file-aio
make
make install
echo ‘export PATH="/usr/local/nginx/sbin:$PATH"‘ >> /etc/profile
# 执行后,使当前环境变量立即生效
source /etc/profile
# 直接启动,执行nginx就启动服务了
nginx
# 本次关闭防火墙
systemctl stop firewalld
# 设置下次开机不启动防火墙
systemctl disable firewalld
# 不关闭服务都情况下加载服务
nginx -s reload
nginx -s signal
signal(信号)有以下几种
stop — 快速关闭
quit — 正常退出程序
reload — 重新加载配置文件
reopen — 重新打开日志文件
如需要退出nginx服务
nginx -s quit
下面的方式等效,其中1628为当前运行状态的nginx进程ID,kill向nginx发送QUIT信号
kill -s QUIT 1628
外层指令分为
events
http
events {
}
http {
}
指令内的参数必须以;分号结尾,以{}花括号包裹
http
内部指令又包含server
指令
events {
}
http {
server {
}
}
events {
}
http {
server {
location / {
}
}
}
location / {
root /data/www;
}
location /images/ {
root /data;
}
server {
location / {
root /data/www;
}
location /images/ {
root /data;
}
}
nginx -s reload
server {
listen 8080;
root /data/up1;
location / {
}
}
server {
location / {
proxy_pass http://localhost:8080;
}
location /images/ {
root /data;
}
}
location ~ \.(gif|jpg|png)$ {
root /data/images;
}
server {
location / {
proxy_pass http://localhost:8080/;
}
location ~ \.(gif|jpg|png)$ {
root /data/images;
}
}
server {
location / {
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
}
location ~ \.(gif|jpg|png)$ {
root /data/images;
}
}
更多配置请参考官方文档
标签:环境变量 rip name 服务器ip Beginner install nginx stat tar.gz
原文地址:https://www.cnblogs.com/zengchunyun/p/9346226.html