已经安装成功,并且支持 PHP 的样子:
源码安装步骤如下:
./configure-prefix=/usr/local/nginx-with-http _ SSL _ module-with-http _ stub _
Make
Make install
YUM安装如下:
Yum install nginx -y
-with-http _ stub _ status _ module:支持nginx状态查询
-with-http _ SSL _ module: https支持
- with-pcre:要支持重写功能,必须开发pcre
配置文件:
YUM安装:/etc/nginx/nginx.conf
源代码安装(基于以前的安装命令):/usr/local/nginx/conf/nginx . conf
一个标准的 HTTP 配置
Server}
Listen 80 default _ server
listen[33363603360]:8 default _ server;
#服务器主机名,可配置为localhost
server _ name your . domain . name;
# web根目录
root/opt/html/www;
# load configuration files for the default server block。
Include/etc/nginx/default.d/*。conf
Location/{
# web根目录
root/opt/html/www;
indedex . PHP index . htmlindex . htm;
}
error _ page 404/404 . html;
Location=/40x.html}
}
error _ page 500 5050503 504/50x . html;
Location=/50x.html}
}
#这是支持PHP的配置,将进行相应修改
Location ~。“PHP $”
root/opt/html/www;
fast CGI _ pass 127 . 0 . 0 . 133609000;
Fastcgi _ index.php
fast CGI _ param script _ filename $ document _ root $ fast CGI _ script _ name;
Include fastcgi _ params
}
}
一个标准的 HTTPS 配置
Server}
listen 443 SSL http 2 default _ server;
listen[33363636033 SSL http 2 default _ server;
#服务器主机名,可配置为localhost
Server _ name localhost
# web根目录
root/opt/html/www;
# SSL配置
SSL _ certificate/opt/cert/nginx/my . PEM;
SSL _ certificate _ key/opt/cert/nginx/my . key;
Ssl _ session _ timeout 5m
#默认ssl_protocls被配置为导致浏览器错误
# ssl _ protocols SSLv2 SSLv3 TLSv1
SSL _ protocols TLS v1 tlsv 1.1 tlsv 1.2 tlsv 1.3;
Ssl_ciphers HIGH:ANULL:MD5
Ssl _ prefer _ server _ ciphers on
Include/etc/nginx/default.d/*。conf
Location/{
root/opt/html/www;
indedex . PHP index . htmlindex . htm;
}
error _ page 404/404 . html;
Location=/40x.html}
}
error _ page 500 5050503 504/50x . html;
Location=/50x.html}
}
Location ~。“PHP $”
root/opt/html/www;
fast CGI _ pass 127 . 0 . 0 . 133609000;
Fastcgi _ index.php
fast CGI _ param script _ filename $ document _ root $ fast CGI _ script _ name;
Include fastcgi _ params
}
}
YUM服务启停的命令
Systemctl start nginx.service
Systemctl stop nginx.service
Systemctl restart nginx.service
Systemctl enable nginx.service
Systemctl disable nginx.service
源码安装服务启停的命令
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx-s stop
发表评论