立诚勿怠,格物致知
It's all about connecting the dots

nginx支持php(wordpress)和node

nginx配置一下不仅可以做静态服务器,还可以转发请求到服务端本地的端口服务。以前装wordpress这些程序我们会惯例一样地去安装apache,但是如果你装了nginx,就不再需要安装apache了。下面是一个我自己用的配置,我的服务器是centos 7。

这些说明文字有可能有助于你对下面这个配置的理解:

  • 我有两个域名,分别是orzzone.com和yxeye.com;
  • orzzone.com使用的服务是由一个php程序wordpress提供的;
  • yxeye.com使用的服务是由一个node服务提供的,node服务使用的端口号为18080。
user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

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

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

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

    server {
        listen 80;
        server_name www.yxeye.com;
        location / {
            #....
            proxy_pass http://localhost:18080;
        }
        ##### other directive
    }


    server {
        listen 80;
        server_name www.orzzone.com;
        root /var/www/html/orzzone.com/public_html/wordpress;
        index index.php index.html;
        location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;
        }
        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            }
        error_page 404 /404.html;
        location = /40x.html {
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
        ##### other directive
    }
}

 

赞(0) 打赏
文章名称:《nginx支持php(wordpress)和node》
文章链接:https://www.orzzone.com/support-php-wordpress-and-node.html
商业联系:yakima.public@gmail.com

本站大部分文章为原创或编译而来,对于本站版权文章,未经许可不得用于商业目的,非商业性转载请以链接形式标注原文出处。
本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力提供更多优质内容!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册