搜索

首页  >  问答  >  正文

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

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

blog.conf配置:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

<code>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;

        }

}

</code>

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

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

巴扎黑巴扎黑2912 天前435

全部回复(3)我来回复

  • PHP中文网

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

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

    回复
    0
  • 天蓬老师

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

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

    回复
    0
  • 大家讲道理

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

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

    回复
    0
  • 取消回复