Ubuntu配置Nginx虚拟主机和支持ThinkPHP
【Nginx配置虚拟主机】
每一个
server {
listen 80;
server_name www.a.com;
.....
}
就表示一台虚拟域名,
然后对应的,在 /etc/hosts 修改:
vim
/etc/hosts

-------------------------------------------------------------------------------
【/usr/local/server/nginx/conf/nginx.conf】注意提前备份一份
#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 1024;
}
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;
#da kai mu lu , By renxing
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
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 /usr/local/server/nginx/html/qgzs/app;
##定位项目到指定目录
index index.html index.htm index.php;
}
#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
#
##配置nginx支持thinkphp的 PATHINFO 模式
location /usr/local/server/nginx/html/qgzs/app {
index index.php;
if (!-e $request_filename) {
rewrite ^/test/tp/(.*)$ /test/tp/index.php/$1 last;
break;
}
}
location ~ .+\.php($|/) {
set $script $uri;
set $path_info "/";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
root /usr/local/server/nginx/html/qgzs/app;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php?IF_REWRITE=1;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
##END配置
# 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;
# }
#}
}
Ubuntu配置Nginx虚拟主机和支持ThinkPHP的更多相关文章
- 配置Nginx虚拟主机
实验环境 一台最小化安装的CentOS 7.3虚拟机 配置基本环境 1. 安装nginx yum install -y epel-* yum isntall -y nginx vim 2. 建立虚机主 ...
- 在 CentOS7 上配置 nginx 虚拟主机
创建配置文件保存目录,其中 sites-available 用来实际保存配置文件,sites-enabled 用来保存符号链接 : mkdir /etc/nginx/sites-available m ...
- Nginx 虚拟主机下支持Pathinfo并隐藏入口文件的完整配置
server { listen 80; server_name zuqiu.com; # 设置你的域名 index index.html index.htm index.php; root D:/wn ...
- 配置nginx虚拟目录配置文件支持tp的pathinfo
lnmp自带的包不好用, 经测试,在相应的conf文件加入这句话即可: location / { if (!-e $request_filename) { rewrite ^(.*)$ /index. ...
- Nginx 虚拟主机 VirtualHost 配置
Nginx 是一个轻量级高性能的 Web 服务器, 并发处理能力强, 对资源消耗小, 无论是静态服务器还是小网站, Nginx 表现更加出色, 作为 Apache 的补充和替代使用率越来越高. 我在& ...
- Nginx网络架构实战学习笔记(一):Nginx简介、安装、信号控制、nginx虚拟主机配置、日志管理、location 语法、Rewrite语法详解
文章目录 nginx简介 nginx安装 nginx信号控制 nginx虚拟主机配置 日志管理 location 语法 精准匹配的一般匹配 正则匹配 总结 Rewrite语法详解 nginx简介 Ng ...
- nginx虚拟主机配置
nginx虚拟主机配置 虚拟主机的概念虚拟主机,就是把一台物理服务器划分成多个"虚拟"的服务器,每一个虚拟主机都可以有独立的域名和独立的目录nginx虚拟主机的配置nginx的 ...
- Nginx高性能服务器安装、配置、运维 (5) —— Nginx虚拟主机配置
六.Nginx虚拟主机配置 建立基于域名的虚拟主机: (1)建立基于域名的虚拟主机配置文件(以abc.com为例): (2)更改虚拟主机配置文件: 更改配置如下(更改部分即可): server { l ...
- Nginx教程(二) Nginx虚拟主机配置
Nginx教程(二) Nginx虚拟主机配置 1 虚拟主机管理 1.1 Nginx管理虚拟主机 虚拟主机使用的是特殊的软硬件技术,它把一台运行在因特网上的服务器主机分成一台台“虚拟”的主机,每台虚拟主 ...
随机推荐
- 从CUMT校园导航出现的问题看CSS布局设计(一) CSS盒模型
先说说做的这个校园导航系统值得一提的内容: 1. 二级菜单栏 .iframe内嵌窗口(样式设计.用hover做效果) 2. 高德地图API (自定义底图样式.弹跳点.信息窗体.线路导航) 3. DO ...
- MYsql优化where子句
该部分讨论where子句的优化,不仅select之中,相同的优化同样试用与delete 和update语句中的where子句: 1: 移去不必要的括号: ((a AND b) AND c OR ((( ...
- Hibernate 的原生 SQL 查询
Hibernate除了支持HQL查询外,还支持原生SQL查询. 对原生SQL查询执行的控制是通过SQLQuery接口进行的,通过执行Session.createSQLQuery()获取 ...
- C#编译成以管理员身份运行程序
转载自:http://www.cnblogs.com/babycool/p/3569183.html 在使用winform程序获取调用cmd命令提示符时,如果是win7以上的操作系统,会需要必须以管理 ...
- shopnc IM配置过程
im配置windows下,修改chat下和data下的config,安装node,覆盖node下文件即可
- Redis跟Spring整合,sentinel模式
普通模式整合 一.在pom.xml中引入redis的依赖 <dependency> <groupId>org.springframework.data</groupId& ...
- python3 第二十二章 - 函数式编程之Decorator(装饰器)
前面我们说了,在python中,一切皆对象.函数也是一个对象,而且函数对象可以被赋值给变量,通过变量也能调用该函数.如: def sayHello(name): print(name + ' hell ...
- python_如何修改装饰器中参数?
案例: 为分析程序内哪些函数执行时间开销较大,我们需定义一个带timeout参数的装饰器 需求: 统计被装饰函数的运行时间 时间大于timeout时,将此次函数调用记录到log日志中 运行时可以修改t ...
- WebSphere--连接管理器
连接管理器使您可以控制并减少由 Web 应用程序使用的资源.相对于非 Web 应用程序,基于 Web 的应用程序对数据服务器的访问会导致更高的和不可预料的系统开销,这是由于 Web 用户更为频繁的连接 ...
- Ceph,TFS,FastDFS,MogileFS,MooseFS,GlusterFS 对比
系统整体对比 对比说明 /文件系统 TFS FastDFS MogileFS MooseFS GlusterFS Ceph 开发语言 C++ C Perl C C C++ 开源协议 GPL V2 GP ...