linux - 如何在lnmp环境里,部署多个php项目?
天蓬老师
天蓬老师 2017-04-11 10:35:56
[PHP讨论组]

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

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全部回复(3)
迷茫

如果你说两个项目是通过两个不同的域名来访问的话,直接参考以下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地址即可。

PHP中文网

很简单啊 。
配置nginx vhost就行了。

巴扎黑

使用docker

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号