Home > Backend Development > PHP Tutorial > 同一Ubuntu服务用Nginx跑Django和Wordpress如何设置

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

WBOY
Release: 2016-06-06 20:47:50
Original
1259 people have browsed it

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

blog.conf配置:

<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>
Copy after login
Copy after login

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

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

回复内容:

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

blog.conf配置:

<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>
Copy after login
Copy after login

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

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

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

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

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template