Maison  >  Questions et réponses  >  le corps du texte

php - 同一Ubuntu服务用Nginx跑Django和Wordpress如何设置

租用的是aliyun服务器,现在上面跑着Django+fastcgi,运行正常。想加个wordpress博客上去,用php5-fpm。

blog.conf配置:

server {
listen 80;
server_name blog.joinwee.com;
error_log /alidata1/wwwlogs/blog.error.log;
access_log /alidata1/wwwlogs/blog.access.log;

location / {
        index index.html index.htm index.php;
        root /alidata1/wordpress/;
        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;
        }

}
location ~ \.php$ {
        include fastcgi_params;
        fastcgi_index index.php;
        #fastcgi_pass 127.0.0.1:53217;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        }
}

想使用二级域名blog.joinwee.com,重动了php5-fpm的,但访问时仍是提示无法访问此网页

请问服务器能同时跑这django和php吗?该如何设置?

巴扎黑巴扎黑2750 Il y a quelques jours397

répondre à tous(3)je répondrai

  • PHP中文网

    PHP中文网2017-04-10 14:39:01

    要用两个server块,分别按照django和php的方式写。
    写完注意重启下Nginx(或者reload)。

    répondre
    0
  • 天蓬老师

    天蓬老师2017-04-10 14:39:01

    既然好像不是在同一个域名下,那就分成2个server写
    毕竟nginx只是用来反代的
    我自己的服务器目前都是php和django同时跑的
    我用的军哥的lnmp.org来搭建lnmp环境,
    需要跑php网站的时候,就直接用vhost.sh
    需要跑django的时候,我是采用supervisord和uwsgi的,然后手动写一份nginx来反代

    répondre
    0
  • 大家讲道理

    大家讲道理2017-04-10 14:39:01

    2个server,或者自定义修改代理,说白了nginx只是代理,你自己制定后端就可以

    répondre
    0
  • Annulerrépondre