Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

如何在lnmp环境里,部署多个php项目?

我有2个php项目,想放在同一个lnmp环境里


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

如果你说两个项目是通过两个不同的域名来访问的话,直接参考以下conf文件内容

第一段:

server {
    listen       80 ;
    server_name  www.host1.cc; #监听的hostname
    root   /var/www/www_host1_cc/; #第一个项目的根目录

    location / {
        root   /var/www/www_host1_cc/;
        index  index.php index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    location ~ .*.(php|php5)?(/.*)*$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        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$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info;
            include    fastcgi_params;
    }
}

第二段:
(此处参考第一段,仅需要修改对应的server_name 和 root)

然后将域名解析到服务器的IP地址即可。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...