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管理虚拟主机 虚拟主机使用的是特殊的软硬件技术,它把一台运行在因特网上的服务器主机分成一台台“虚拟”的主机,每台虚拟主 ...
随机推荐
- 怎么使用linux命令重启服务器
一下的命令都可以重启Linux服务器: 1.shutdown -r now 2.reboot 3.startx
- php 抽奖概率 随机数
<?php $prize_arr = array( '0' => array('id' => 1, 'title' => 'iphone5s', 'v' => 5), ' ...
- HTML 5 <embed> 标签
定义和用法 <embed> 标签定义嵌入的内容,比如插件. 实例 <embed src="helloworld.swf" />
- [机器学习]-[数据预处理]-中心化 缩放 KNN(二)
上次我们使用精度评估得到的成绩是 61%,成绩并不理想,再使 recall 和 f1 看下成绩如何? 首先我们先了解一下 召回率和 f1. 真实结果 预测结果 预测结果 正例 反例 正例 TP 真 ...
- React源码解析:ReactElement
ReactElement算是React源码中比较简单的部分了,直接看源码: var ReactElement = function(type, key, ref, self, source, owne ...
- U8g2库I2C总线再次突破性调试成功
这次采用U8X8的方式,不再采用u8g2,因为后者一直报内存问题.所以采用了不占内存的u8x8模式 同时u8g2库文件的示例代码也是很牛逼的, 里面还有message box 非常的可爱运行效果也非常 ...
- python3 第十四章 - 数据类型之Dictionary(字典)
在python中字典是另一种可变容器模型,且可存储任意类型对象. 字典的每个键值(key=>value)对用冒号(:)分割,每个对之间用逗号(,)分割,整个字典包括在花括号({})中 ,格式如下 ...
- Windows核心编程&作业
1. 作业内核对象 允许将进程组合在一起并创建一个"沙箱"来限制进程能够做什么.我们可以将作业内核对象想象成一个进程容器(即使只有一个进程也具有相当的重要性) 限制包括可以分配的最 ...
- Java NIO 之 Selector
Selector是SelectableChannel的多路选择器,配合SelectableChannel实现非阻塞IO. 详见代码 /** * Selector 是 SelectableChannel ...
- Codeforce C. Bus
C. Bus time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...