找到nginx的配置文件 nginx/nginx.conf

第一种方,法直接在nginx.com里面配置

user  www www;

worker_processes auto;

error_log  /home/wwwlogs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile ; events
{
use epoll;
worker_connections ;
multi_accept on;
} http
{
include mime.types;
default_type application/octet-stream; server_names_hash_bucket_size ;
client_header_buffer_size 32k;
large_client_header_buffers 32k;
client_max_body_size 50m; sendfile on;
tcp_nopush on; keepalive_timeout ; tcp_nodelay on; fastcgi_connect_timeout ;
fastcgi_send_timeout ;
fastcgi_read_timeout ;
fastcgi_buffer_size 64k;
fastcgi_buffers 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k; gzip on;
gzip_min_length 1k;
gzip_buffers 16k;
gzip_http_version 1.1;
gzip_comp_level ;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\."; #limit_conn_zone $binary_remote_addr zone=perip:10m;
##If enable limit_conn_zone,add "limit_conn perip 10;" to server section. server_tokens off;
#log format
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log off; server
{
listen ;
#listen [::]: default_server ipv6only=on;
server_name www.beibeigou8.com beibeigou8.com; /**需要设置的域名**/
index index.html index.htm index.php;
root /home/wwwroot/weilang; /**项目地址**/ #error_page /.html;
include enable-php.conf; location /nginx_status
{
stub_status on;
access_log off;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /\.
{
deny all;
} access_log /home/wwwlogs/access.log access; }
include vhost/*.conf;
}

要配置新项目的话,需要重新复制service所有内容,如

server
{
listen ;
#listen [::]: default_server ipv6only=on;
server_name www.beibeigou8.com beibeigou8.com;
index index.html index.htm index.php;
root /home/wwwroot/weilang; #error_page /.html;
include enable-php.conf; location /nginx_status
{
stub_status on;
access_log off;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /\.
{
deny all;
} access_log /home/wwwlogs/access.log access; }
server
{
listen ;
#listen [::]: default_server ipv6only=on;
server_name www.2345.2345.com;
index index.html index.htm index.php;
root /home/wwwroot/2345; #error_page /.html;
include enable-php.conf; location /nginx_status
{
stub_status on;
access_log off;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /\.
{
deny all;
} access_log /home/wwwlogs/access.log access;
}

第二种方法,用includ导入(方便各种域名管理)

user  www www;

worker_processes auto;

error_log  /home/wwwlogs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile ; events
{
use epoll;
worker_connections ;
multi_accept on;
} http
{ server
{ }
include vhost/*.conf;
}

nginx/vhost目录下文件

文件名:www.beibeigou8.com.conf  (直接域名配置)

内容:

server{
listen ;
server_name www.beibeigou8.com;
index index.html index.htm index.php;
root /home/wwwroot/weilang;
#if (!-e $request_filename) {
# rewrite ^/(.*)$ /index.php/$ last;
# break;
#}
#error_page /.html;
#include enable-php.conf; location /nginx_status
{
stub_status on;
access_log off;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /\.
{
deny all;
} location ^~ /phpmyadmin/
{
deny all;
} location ^~ /data/
{
deny all;
} #location ~ ^(.+\.php)(.*)$ {
location ~ .php {
root /home/wwwroot/weilang;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi.conf;
#fastcgi_param SCRIPT_FILENAME $document_root$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 $;
# set $path_info $;
#}
#fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
#fastcgi_param SCRIPT_NAME $real_script_name;
#fastcgi_param PATH_INFO $path_info;
}
access_log /home/wwwlogs/access.log access;
}

文件名:beibeigou8.com.conf (中间有静态跳转)

内容:

server{
listen ;
server_name beibeigou8.com;
index index.html index.htm index.php;
#root /home/wwwroot/weilang;
#if (!-e $request_filename) {
# rewrite ^/(.*)$ /index.php/$ last;
# break;
#}
#error_page /.html;
#include enable-php.conf; rewrite ^/$ http://www.beibeigou8.com/ permanent; location /nginx_status
{
stub_status on;
access_log off;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /\.
{
deny all;
}
#location ~ ^(.+\.php)(.*)$ {
location ~ .php {
root /home/wwwroot/weilang;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$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 $;
set $path_info $;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
access_log /home/wwwlogs/access.log access;
}

linux nginx配置新项目加域名的更多相关文章

  1. linux nginx配置新项目加域名(设置绑定域名)

    转自:linux nginx配置新项目加域名 找到nginx的配置文件 nginx/nginx.conf 第一种方,法直接在nginx.com里面配置 user www www; worker_pro ...

  2. 在Linux上配置xampp后远程访问域名报错

    在Linux上配置xampp后远程访问域名报错: New XAMPP security concept: Access to the requested object is only availabl ...

  3. linux nginx 配置php

    linux nginx 配置php   下载php源码 解压 configure ./configure --prefix=/usr/local/php --enable-fpm --with-mcr ...

  4. Nginx配置多个基于域名的虚拟主机+实验环境搭建+测试

    标签:Linux 域名 Nginx 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://xpleaf.blog.51cto.com/9 ...

  5. 在linux上配置Django项目

    依赖包 [root@web01 ~]# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqli ...

  6. nginx 配置Tp5项目时出现 404 Not Found nginx

    1.首先看了nginx报错日志 报 signal process started signal process started表示还有 产生原因 1.可能你的nginx.conf 内容配置的有问题. ...

  7. Nginx配置Web项目(多页面应用,单页面应用)

    目前前端项目 可分两种: 多页面应用,单页面应用. 单页面应用 入口是一个html文件,页面路由由js控制,动态往html页面插入DOM. 多页面应用 是由多个html文件组成,浏览器访问的是对应服务 ...

  8. nginx 配置多个 https 域名访问

    需要此操作的原因 在服务器上部署了 halo blog 以后,这次需要部署另外一个项目,但是又不想使用 ip + port,因此选择使用 nginx 配置多个域名访问. nginx 配置 server ...

  9. nginx配置一、二级域名、多域名对应(api接口、前端网站、后台管理网站)

    前提:安装好nginx,如果已经启动nginx,先停止,命令: ./usr/local/nginx/sbin/nginx -s stop 修改nginx配置 vi /usr/local/nginx/c ...

随机推荐

  1. loadrunner文本检查点

    将脚本切换回代码界面, 在光标闪烁的上行,添加如下的代码: 添加的代码根据你检查的方式不同而不同, 你可以选择其中之一即可. 代码一: web_reg_find("Text=Payment ...

  2. # Writing your-first Django-app-part 4-simple-form

    简单的表单 处理表单提交-跳转/错误信息 处理表单提交--结果显示 通用view (generic view) 设计:越少代码越好? 1.修改DemoAppPoll/urls.py 2.修改DemoA ...

  3. http连接优化与浏览器允许的并发请求资源数相关资料(整理转载)

    网页性能优化相关资料: https://developer.yahoo.com/performance/rules.html#page-nav 前端技术的逐渐成熟,还衍生了domain hash, c ...

  4. mysql多表查询及其 group by 组内排序

    //多表查询:得到最新的数据后再执行多表查询 SELECT *FROM `students` `st` RIGHT JOIN( //先按时间排序查询,然后分组(GROUP BY ) SELECT * ...

  5. iis部署webservice问题集合

    一.添加网站 具体步骤:打开控制面板,选择管理工具,打开管理工具. 打开管理工具后,打开第二个internet信息服务(iis)管理器. 打开后的界面如下: 右击网站,添加网站后,弹出“添加网站”选项 ...

  6. python 文件 IO 操作

    Python 的底层操作 * 其实Python的文件IO操作方法,和Linux底层的差不多 打开 f = open(filename , "r") 后面的 "r" ...

  7. hadoop rebalance

    之前一直没做过rebalance,以为速度很快,结果大意了,等到磁盘达到90%的时候,才开始做rebalance. 默认的从日志中可以看到总共需要迁移1.89T,但是每次只移动40G大小的量. 然后查 ...

  8. [数据结构]图的DFS和BFS的两种实现方式

    深度优先搜索 深度优先搜索,我们以无向图为例. 图的深度优先搜索(Depth First Search),和树的先序遍历比较类似. 它的思想:假设初始状态是图中所有顶点均未被访问,则从某个顶点v出发, ...

  9. SpringBoot 中 @RequestBody的正确使用方法

    SpringBoot 中 @RequestBody的正确使用方法 最近在接收一个要离职同事的工作,接手的项目是用SpringBoot搭建的,其中看到了这样的写法: @RequestMapping(&q ...

  10. PHP利用CURL_MULTI实现多线程

    PHP中的curl_multi一类函数可以实现同时请求多个url,而不是一个一个依次请求,这就类似一个进程实现了多个线程的功能,因此可以使用PHP利用CURL_MULTI实现完成多线程类的任务,下面就 ...