Nginx 安装配置过程
#yum install nginx
开启服务: #service nginx start
(nginx使用的是80端口,需要确保80端口不被占用)
欢迎页面: /usr/share/nginx/html
配置文件位置: /etc/nginx/
错误日志位置: /var/log/nginx/
反向代理思想:
根据location 匹配规则,当匹配到不同的URL时,选择不同的解析容器。
例如,服务器有如下配置:
Nginx 80端口
Apache 9000端口
Tomcat 8080端口
Apache 有应用 warm
Tomcat 有应用 jokingus
我们希望 路径访问存在 /warm开头时启用 Apache
存在 /jokingus开头时启用tomcat
我们可以再 /etc/nginx/conf.d/default.conf中添加 location 匹配规则即可:
location ^~ /jokingus/
{
index index.jsp;
proxy_pass http://127.0.0.1:8080;
}
location ^~ /warm/
{
index index.php;
proxy_pass http://127.0.0.1:9000;
}