转自:linux nginx配置新项目加域名

找到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 51200; events
{
use epoll;
worker_connections 51200;
multi_accept on;
} http
{
include mime.types;
default_type application/octet-stream; server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m; sendfile on;
tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k; gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
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 80;
#listen [::]:80 default_server ipv6only=on;
server_name www.beibeigou8.com beibeigou8.com; /**需要设置的域名**/
index index.html index.htm index.php;
root /home/wwwroot/weilang; /**项目地址**/ #error_page 404 /404.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 80;
#listen [::]:80 default_server ipv6only=on;
server_name www.beibeigou8.com beibeigou8.com;
index index.html index.htm index.php;
root /home/wwwroot/weilang; #error_page 404 /404.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 80;
#listen [::]:80 default_server ipv6only=on;
server_name www.2345.2345.com;
index index.html index.htm index.php;
root /home/wwwroot/2345; #error_page 404 /404.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 51200; events
{
use epoll;
worker_connections 51200;
multi_accept on;
} http
{ server
{ }
include vhost/*.conf;
}

nginx/vhost目录下文件

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

内容:

server{
listen 80;
server_name www.beibeigou8.com;
index index.html index.htm index.php;
root /home/wwwroot/weilang;
#if (!-e $request_filename) {
# rewrite ^/(.*)$ /index.php/$1 last;
# break;
#}
#error_page 404 /404.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:9000;
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 $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;
}
access_log /home/wwwlogs/access.log access;
}

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

内容:

server{
listen 80;
server_name beibeigou8.com;
index index.html index.htm index.php;
#root /home/wwwroot/weilang;
#if (!-e $request_filename) {
# rewrite ^/(.*)$ /index.php/$1 last;
# break;
#}
#error_page 404 /404.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:9000;
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 $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;
}
access_log /home/wwwlogs/access.log access;
}

linux nginx配置新项目加域名(设置绑定域名)的更多相关文章

  1. linux nginx配置新项目加域名

    找到nginx的配置文件 nginx/nginx.conf 第一种方,法直接在nginx.com里面配置 user www www; worker_processes auto; error_log ...

  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. 记一次mac下使用mamp集成环境配置lumen项目自定义域名遇到的花样问题

    1.安装好mamp集成环境,自行百度. 2.从公司项目版本库里将项目克隆到本地. 好了,开始配置自定义域名来访问项目,以下是遇到的问题集锦... 1.web服务器使用的nginx,配置完域名访问报40 ...

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

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

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

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

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

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

  8. 在linux上配置Django项目

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

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

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

随机推荐

  1. Http协议中Get和Post的浅谈

    起名困难户,每次写文章最愁的就是不知道该如何起个稍具内涵的名字,如果这篇文章我只是写写Get和Post的区别,我可以起个名字“Get和Post的那点事”,如果打算阐述一下Http协议原理性内容,那该叫 ...

  2. 热修复 DexPosed AOP Xposed MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  3. mongoose系列——几行代码实现CRUD

    1. nodejs 确实好用,mongoose封装了mongodb,代码很简洁. const mongoose = require('mongoose'); mongoose.connect(&quo ...

  4. (转)Unity3D 游戏贴图(法线贴图,漫反射贴图,高光贴图)

    原帖网址http://www.u3dpro.com/read.php?tid=207  感谢jdk900网友的辛苦编写 我们都知道,一个三维场景的画面的好坏,百分之四十取决于模型,百分之六十取决于贴图 ...

  5. PKU-2104-K-th Number

    K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 36045   Accepted: 11522 Ca ...

  6. Using Timers in MFC Applications

    Timer Events in MFC Applications Event timers are always handy to have around and useful in nearly e ...

  7. 命令行下的html转pdf工具wkhtmltopdf

    基于webkit和qt的html转pdf的命令行工具,非常好使 http://code.google.com/p/wkhtmltopdf/ http://www.cnblogs.com/shanyou ...

  8. 使用Nexus管理maven仓库,setting文件理解

    来到新公司对很多陌生的技术一头雾水,以前在工作中没有真正使用过maven,于是强迫自己蛋定下来一个一个的突破,下面是我对maven的setting配置文件的理解,由于是现学的,难免可能会理解偏差,还请 ...

  9. 获取oracle 随机数

    http://www.cnblogs.com/lgzslf/archive/2008/11/29/1343685.html select substr(dbms_random.random,2,2) ...

  10. HTML页面跳转的5种方式

    下面列了五个例子来详细说明,这几个例子的主要功能是:在5秒后,自动跳转到同目录下的hello.html(根据自己需要自行修改)文件. 1) html的实现 <head> <!-- 以 ...