1、找到nginx的配置文件默认位置
cd /usr/local/webserver/nginx/conf/
在nginx的主配置文件下添加配置:**/nginx/nginx.conf
的配置
#下面是server虚拟主机的配置
include /usr/local/webserver/nginx/conf/conf.d/*.conf;
2、创建多个配置文件夹 conf.d
mkdir conf.d
3、创建独立域名或二级域名的配置文件
cd conf.d
3.1 创建默认域名的配置文件
mkdir default.conf
配置信息,星号替换为自己的域名
server
{
listen 80;#监听端口
server_name www.***.com; #域名
index index.html index.htm index.php;
root /usr/local/webserver/nginx/html; # 站点目录
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
{
expires 30d;
# access_log off;
}
location ~ .*\.(js|css)?$
{
expires 15d;
# access_log off;
}
access_log off;
}
3.2 git.conf
创建git.conf 配置文件
vi git.conf
配置信息,星号替换为自己的域名
server {
listen 80;
server_name git.***.com; # 二级域名地址
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://0.0.0.0:8000; # ip可访问的端口
}
}