nginx 多php项目配置文件,nginx 配置文件配置多个站点
nginx环境下配置多个站点
一、找到nginx的配置文件 一般会在/etc/nginx/nginx.conf
二、修改配置文件我的配置文件如下,其中server 包括的内容是一个对象 一个网站对应一个server 多个网站对应多个server
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 10240;
multi_accept on;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
//第一个站点配置 看关键点(域名+定位到的项目地址)
server {
listen 80;
server_name localhost; //重要 你的域名
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /web/men/public; //定位到的项目地址
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php?.* {
root /web/men/public; //定位到的项目地址
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
location ~ \.php$ {
proxy_pass http://127.0.0.1;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
//第二个站点配置如第一配置一样只是需要改变域名和定位到的项目地址
server {
listen 80;
server_name ruigao.cqgoulian.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /web/ruigao/public;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php?.* {
root /web/ruigao/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
location ~ \.php$ {
proxy_pass http://127.0.0.1;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
}
三、重启nginx 输入命令行 # service nginx restart 提示OK则代表成功 提示警告内容则需要修改问题
四、打开游览器访问不同站点的域名 发现定位到不同的项目地址 成功!
nginx 多php项目配置文件,nginx 配置文件配置多个站点相关推荐
- 01_Nginx安装,nginx下部署项目,nginx.conf配置文件修改,相关文件配置
1.下载Nginx,进入Nginx下载地址:http://nginx.org/ 点击nginx-1.8.0,进入:http://nginx.org/en/download.html,下载文件: ...
- docker安装nginx规范所有项目的反向代理(一个项目一个反向代理的conf配置文件)
背景 centos7安装nginx比较麻烦,还是docker安装比较香. dokcer安装nginx比较简单,而且教程很多,那为什么还要总结? 这篇文章主要是规范化nginx对项目的反向代理,明显的特 ...
- linux更改nginx最大访问数,Linux下nginx服务的配置文件nginx.conf中模块的讲解之配置limit_conn_zone来限制并发连接数以及下载速率...
一.限制并发连接数的配置方法如下: 1.在nginx.conf里的http{}里加上如下代码: # vim /usr/local/nginx/conf/nginx.conf #在其中的36行加入下面的 ...
- nginx php多域名配置文件,配置文件,nginx_nginx多站点配置,无法通过域名访问,使用ip访问会跳转到其中一个站点,配置文件,nginx - phpStudy...
nginx多站点配置,无法通过域名访问,使用ip访问会跳转到其中一个站点 在一台服务器设置了Nginx多站点,但是访问这些站点的域名均无法访问,错误如下图: 通过ip会跳转到其中一个站点,具体表现为: ...
- 关于nginx的linux命令 以及 基本配置文件的配置
文章目录 一.常用 1.1 命令 1.2设置开机自启动 1.3 配置文件结构 1.4 各个字段的含义 1.4.1 server下面 1.4.1 server - location 下面 1.5 常使用 ...
- docker上启动nginx,并配置修改nginx的配置文件 nginx、挂载文件、docker容器中文乱码
Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务.因为其优秀的性能,使得其成为日常开发,线上运营必不可少的软件了.下面就通过 ...
- Nginx配置文件nginx.conf中文详解(转)
######Nginx配置文件nginx.conf中文详解######定义Nginx运行的用户和用户组 user www www;#nginx进程数,建议设置为等于CPU总核心数. worker_pr ...
- Nginx的配置文件nginx.conf详解
Nginx的配置文件nginx.conf配置详解如下: user nginx nginx ; Nginx用户及组:用户 组.window下不指定 worker_processes 8; 工作进程:数目 ...
- etcd nginx 容器_Etcd+Confd实现Nginx配置文件自动管理
一.需求 我们使用Nginx做七层负载均衡,后端是Tomcat.项目采用灰度发布方式,每次项目升级,都要手动先从Nginx下摘掉一组,然后再升级这组,当项目快速迭代时,手动做这些操作显然会增加部署时间 ...
最新文章
- python一行输入多个值用空格隔开_2020-09-22-Python-函数嵌套、filter()函数、一行输入多个整数(空格分隔)、多维列表的输入...
- 数据库oracle 笔试,数据库oracle笔试
- 数据仓库分层ODS DW DM 主题 标签
- 【C++】静态成员 static
- 回调地狱解决方案之Promise
- CDOJ 482 Charitable Exchange bfs
- 聊一聊Jmeter与多接口测试
- Postman和postwoman安装及简介
- linux从服务器获取共享列表失败,linux – 如何获取连接到本地网络中NFS服务器的客户端列表?...
- bilibili开源弹幕库UML类图
- Struts2到底为我们做了什么
- iFunk翼只换不修强出新高度
- 10G家庭光纤网络如何部署?
- 获取 RRD 文件的信息
- 高等数学上:微分中值定理,洛必达法则
- C/C++数据结构舞伴问题
- c语言程序设计新编教程答案钱雪忠,新编C语言程序设计教程
- 记一次 .NET 某电子病历 CPU 爆高分析
- The Brain is wider than the Sky !
- Power2Go 13安装教程
热门文章
- Spark案例:Scala版统计单词个数
- Spring Boot 案例:连接后台数据库实现用户登录
- 大数据学习笔记41:Hive - 用户自定义函数
- PHP案例:数组用法演示
- 4.线性和卷积——相关与卷积、卷积的属性、计算复杂度和可分性_2
- bzoj3572 [HNOI2014]世界树 虚树 +乱dp
- 2017.10.24 上升序列 思考记录
- 2017.9.6 音量调节 思考记录
- oracle path函数,自定义类似 sys_connect_by_path 功能的函数
- 什么叫内部银团_MOS管和IGBT管有什么区别?