1. 重庆云诚科技 > 数码百科 >

(php网站项目)PHP项目部署

导读Thinkphp5项目在nginx服务器部署贡献用户名:【乱可爱一把+】 ,现在由重庆云诚科技小编为你讲解与【php网站项目】的相关内容!贡献者回答1,切换到nginx的配置目录,找到nginx.conf文件...

今天我们来聊聊[php网站项目],以下2关于PHP项目部署的观点希望能帮助到您找到想要的结果。

Thinkphp5项目在nginx服务器部署

贡献用户名:【乱可爱一把+】 ,现在由重庆云诚科技小编为你讲解与【php网站项目】的相关内容!

贡献者回答1,切换到nginx的配置目录,找到nginx.conf文件

    cd   /usr/local/nginx/conf

    vim  nginx.conf

2,如果是单项目部署的话,只需要在nginx.conf文件里面加上以下

server{

        listen 80;

        # 域名,本地测试可以使用127.0.0.1或localhost

        server_name ;

        # php项目根目录

        root /home/data-www/blog;

        location /{

                # 定义首页索引文件的名称

                index index.php index.html index.htm;

                # 影藏入口文件

                if (-f $request_filename/index.html){

                            rewrite (.*) $1/index.html break;

                }

                if (-f $request_filename/index.php){

                            rewrite (.*) $1/index.php;

                }

                if (!-f $request_filename){

                            rewrite (.*) /index.php;

                }

                try_files $uri $uri/ /index.php$query_string;

        }

        # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI协议默认配置.

        # Fastcgi服务器和程序(PHP)沟通的协议

        .location ~ .*\.php${

                # 设置监听端口

                fastcgi_pass 127.0.0.1:9000;

                # 设置nginx的默认首页文件

                fastcgi_index index.php;

                # 设置脚本文件请求的路径

                fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;

                # 引入fastcgi的配置文件

                include fastcgi_params;

                fastcgi_split_path_info ^(.+\.php)(/.*)$;

                set $path_info $fastcgi_path_info;

                fastcgi_param PATH_INFO $path_info;

                try_files $fastcgi_script_name =404;

        }

}

3,如果多项目部署,就需要配置vhost

第一步:编辑nginx.conf文件,在最后加上     include    vhost/*.conf;

第二步:进入vhost文件夹,创建    域名.conf    文件,如创建一个:quanma.meyat.com.conf

第三步:编辑quanma.meyat.com.conf文件,内容如下:

        server

        {

                listen 80;

                server_name quanma.meyat.com;

                index index.html index.htm index.php default.html default.htm default.php;

                root /data/wwwroot/default/quanma/public/;

                #error_page 404 /404.html;

                location / {

                        index index.html index.php;

                        if (-f $request_filename/index.html){

                                rewrite (.*) $1/index.html break;

                        }

                        if (-f $request_filename/index.php){

                                rewrite (.*) $1/index.php;

                        }

                        if (!-f $request_filename){

                                rewrite (.*) /index.php;

                        }

                        try_files $uri $uri/ /index.php$query_string;

                }

                location ~ [^/]\.php(/|$)

                {

                        # comment try_files $uri =404; to enable pathinfo

                        #try_files $uri =404;

                        fastcgi_pass 127.0.0.1:9000;

                        fastcgi_index index.php;

                        include fastcgi_params;

                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                        fastcgi_split_path_info ^(.+\.php)(/.*)$;

                        set $path_info $fastcgi_path_info;

                        fastcgi_param PATH_INFO $path_info;

                        try_files $fastcgi_script_name =404;

                        #include fastcgi.conf;

                        #include pathinfo.conf;

            }

            location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

            {

                    expires 30d;

            }

            location ~ .*\.(js|css)$

            {

                    expires 12h;

            }

            # Disallow access to .ht, .svn, .bzr, .git, .hg, .cvs directories

            location ~ /\.(ht|svn|bzr|git|hg|cvs) {

                    deny all;

            }

            #access_log /date/nginx/bmp.com.conf/access.log main;

}

以上就是重庆云诚科技小编解疑贡献者:(乱可爱一把+)回答的关于“Thinkphp5项目在nginx服务器部署”的问题了,不知是否已经解决你的问题?如果没有,下一篇内容可能是你想要的答案,下面继续解释下文用户【心许君兮君知否】回答的“php项目如何部署在服务器上”的一些相关疑点做出分析与解答,如果能找到你的答案,可以关注本站。

Thinkphp5项目在nginx服务器部署

php项目如何部署在服务器上

贡献用户名:【心许君兮君知否】 ,现在由重庆云诚科技小编为你详解与【php网站项目】的相关内容!

贡献者回答一、阿里ECS服务器配置

     1.因为线上已经有几个站点了.所以要配置ngnix多站点

     2.阿里云ecs目录结构,ngxin 在/etc/nginx/目录下,配置的地方主要是nginx.config文件。或者在conf.d新建一个配置文件然后在include到nginx.config文件中

        

     3.nginx.config新建站点信息

server {

listen       80;

server_name  www.你的域名.com;

root         站点的相对路径;

index index.php index.html index.htm;

#charset koi8-r;

#access_log  /var/log/nginx/host.access.log  main;

# Load configuration files for the default server block.

include /etc/nginx/default.d/*.conf;

location / {

#try_files $uri $uri/ /index.php;

root   /opt/www/pcweb/ytyy_pc;

index  index.php index.html index.htm;             if (!-e $request_filename) {   rewrite  ^(.*)$ /index.phps=$1  last;   break;    }}             url重写(可以没有)

# redirect server error pages to the static page /40x.html

#

error_page  404              /404.html;   40错误页面配置

location = /40x.html {

}

# redirect server error pages to the static page /50x.html

#

error_page   500 502 503 504  /50x.html;  50错误页面配置

location = /50x.html {

}

location ~ .php$ {

root           站点相对路径;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}

location ~ /.ht {

deny  all;

}

}

配置文件的基本内容如上;

配置完成后测试配置文件是否正确

这样配置就可以使用了

然后重启nginx服务器 

这样nginx配置就结束了可以使用了。吧站点文件放到对应的目录下面。我直接git clone过去的。

二.thinkphp项目文件转移

本来以为上传完就结束了。上传上去碰到的第一个问题就是访问页面报错,页面被电信的114页面劫持了。麻蛋 看不到报错

万能百度大法

解决方法1.internet高级选项->隐私->站点  新加阻止站点

解决方法2:控制面板->网络和internet->本地连接->属性->ipv4  使用如下ip

终于搞定可以看到报错页面了麻蛋。再次开启万能百度大法

 

 

 得到最终结论是文件目录权限引起的。thinkphp 的runtime目录没有写入权限thinkphp文件上传到阿里的好像都有这个问题。解决问题很简单

进入到项目文件目录

直接跟文件最高权限

chmod -R 777 [目录]  //linux修改文件权限

 

今天的内容先分享到这里了,读完本文《(php网站项目)PHP项目部署》之后,是否是您想找的答案呢?想要了解更多,敬请关注www.cqycseo.com,您的关注是给小编最大的鼓励。

推荐文章:

  • 管家婆一句赢钱料图
  • 两肖两码准
  • 今期香港挂挂牌生肖表
  • 小鱼儿特马站
  • 平心静气打一生肖数字
  • 马会传真2019特马
  • 管家婆三十码
  • 管家婆登陆官网
  • u7金牛版
  • 平特一尾什么意思
  • 本文由网上采集发布,不代表我们立场,转载联系作者并注明出处:https://www.cqycseo.com/kangadmin/makehtml_archives_action.php?endid=0&startid=-1&typeid=15&totalnum=6115&startdd=4140&pagesize=20&seltime=0&sstime=1679321406&stime=&etime=&uptype=&mkvalue=0&isremote=0&serviterm=

    联系我们

    在线咨询:点击这里给我发消息

    微信号:

    工作日:9:30-18:30,节假日休息