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管理虚拟主机 虚拟主机使用的是特殊的软硬件技术,它把一台运行在因特网上的服务器主机分成一台台“虚拟”的主机,每台虚拟主 ...
随机推荐
- 我的flashfxp左右界面怎么变成这样了?
如下图,flashfxp不是说左边是本地的文件夹,右边是服务器上的文件夹的吗?我不懂刚刚怎么搞了一下,变成两边都是服务器上的文件夹了,哪位大神,指点下,谢谢!!! 921050734 | 浏览 168 ...
- arclistsg文档独立模型标签
[标签名称] arclistsg [标签简介] 单表独立模型的文档列表调用标记 [功能说明] 用于调用单表模型的内容,在V5.3系统以上版本中加入了单表模型的概念,脱离了以前的主从表的数据表关联结构, ...
- 深入理解:Linear Regression及其正则方法
这是最近看到的一个平时一直忽略但深入研究后发现这里面的门道还是很多,Linear Regression及其正则方法(主要是Lasso,Ridge, Elastic Net)这一套理论的建立花了很长一段 ...
- 【问题解决】java中为什么不建议使用DataInputStream 的readLine()方法
常用方法 int read(byte[] b) 从包含的输入流中读取一定数量的字节,并将它们存储到缓冲区数组 b 中. int read(byte[] b, int off, int len) 从包含 ...
- Android-第三天
今天开始做一个提交的页面,本来是用LinearLayout,但是这种布局要使用到多组LinearLayout,于是采用表格布局+相对布局的方式. <TableLayout> <Tab ...
- 解决myeclipse10.1导出War包出错:Security Alert:Integrity check error
解决myeclipse10.1导出War包出错:Security Alert:Integrity check error 解决myeclipse10.1不能导出war包报 ============== ...
- Linux系统shell编程自学_第一章基础
第一章 基础shell的优势在于处理操作系统底层的业务,Python,php的优势在于开发运维工具,web界面的管理工具以及web业务开发.处理一键安装.优化.报警脚本shell又叫命令解释器,它能识 ...
- 比较Maven和Ant
从今天开始,整理maven一系列. Maven 它是什么? 如何回答这个问题要看你怎么看这个问题. 绝大部分Maven用户都称Maven是一个"构建工具":一个用来把源代码构建成可 ...
- Spark 读写hive 表
spark 读写hive表主要是通过sparkssSession 读表的时候,很简单,直接像写sql一样sparkSession.sql("select * from xx") 就 ...
- 通俗易懂的分析如何用Python实现一只小爬虫,爬取拉勾网的职位信息
源代码:https://github.com/nnngu/LagouSpider 效果预览 思路 1.首先我们打开拉勾网,并搜索"java",显示出来的职位信息就是我们的目标. 2 ...