前端Nginx 后端Apache,Wordpress如何开启伪静态? - V2EX
Gauin

前端Nginx 后端Apache,Wordpress如何开启伪静态?

  •  
  •   Gauin Oct 30, 2012 6850 views
    This topic created in 4956 days ago, the information mentioned may be changed or developed.
    BudgetVM VPS空间 Linux主机。

    同事帮忙配置了伪静态,但没弄好。我折腾了一晚上,没搞定。有大牛会弄的吗?分享个方法,我让同事弄一下。

    http://www.gauin.com/ 博客停了好几天了,伪静态还没弄好 求助
    Supplement 1    Mar 15, 2013
    不得已 用军哥的LNMP一键安装包配置好了 目前博客运行正常

    http://www.gauin.com/ 可以访问看看
    13 replies    2014-11-06 22:31:48 +08:00
    santa
        1
    santa  
       Oct 30, 2012
    后端Apache的话应该直接用.htaccess解决,nginix什么都不用做才对吧
    qiuai
        2
    qiuai  
    PRO
       Oct 30, 2012
    @santa 是的
    anyforever
        3
    anyforever  
       Oct 30, 2012   1
    楼上两位的正解,应该在Apache里配置伪静态.
    你找Apache下的配置方法就Ok了。
    Gauin
        4
    Gauin  
    OP
       Oct 30, 2012
    @anyforever 我试了 没弄好。Gtalk能给我下吗
    chairo
        5
    chairo  
       Oct 30, 2012
    添加.htaccess,且删除nginx里的伪静态规则
    Gauin
        6
    Gauin  
    OP
       Oct 30, 2012
    @chairo 下面是Nginx的 conf文件配置。删掉那些?

    user daemon;
    worker_processes 8;

    #error_log logs/error.log;
    #error_log logs/error.log notice;
    #error_log logs/error.log info;

    pid logs/nginx.pid;
    google_perftools_profiles /var/tmp/tcmalloc;
    worker_rlimit_nofile 51200;


    events {
    use epoll;
    worker_connections 51200;
    }


    http {
    server_tokens off;
    include mime.types;
    default_type application/octet-stream;

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

    #access_log logs/access.log main;

    sendfile on;
    tcp_nopush on;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 8m;

    #keepalive_timeout 0;
    keepalive_timeout 120;

    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/x-Javascript text/css application/xml;
    gzip_vary on;
    include vhost/*.conf;

    server {
    listen 80;
    server_name www.gauin.com;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {
    root /usr/local/apache2/htdocs/wordpress/;
    index index.html index.htm index.php;
    }

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    location ~ \.(php|php5)?$ {
    proxy_pass http://127.0.0.1:81;
    }
    include proxy.conf;

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    # root html;
    # fastcgi_pass 127.0.0.1:9000;
    # fastcgi_index index.php;
    # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    # include fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    # deny all;
    #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    # listen 8000;
    # listen somename:8080;
    # server_name somename alias another.alias;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}


    # HTTPS server
    #
    #server {
    # listen 443;
    # server_name localhost;

    # ssl on;
    # ssl_certificate cert.pem;
    # ssl_certificate_key cert.key;

    # ssl_session_timeout 5m;

    # ssl_protocols SSLv2 SSLv3 TLSv1;
    # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    # ssl_prefer_server_ciphers on;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}

    }
    chairo
        7
    chairo  
       Oct 30, 2012
    @Gauin 试试server段用这个写法,原配置文件保留备份,如果下边这段不能用建议恢复成你的那个文件

    server {
    listen 80;
    server_name www.gauin.com;
    index index.html index.htm index.php;
    root /usr/local/apache2/htdocs/wordpress/;

    location / {
    try_files $uri @apache;
    }

    location @apache {
    internal;
    proxy_pass http://127.0.0.1:81;
    include proxy.conf;
    }

    location ~ .*\.(php|php5)?$ {
    proxy_pass http://127.0.0.1:81;
    include proxy.conf;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }

    }
    ajoop
        8
    ajoop  
       Oct 30, 2012
    如果就一个博客的话,没必要后端用apache了,直接LNMP就可以了,占用资源还少,如果用军哥LNMP一键安装包的话,添加网站时候会提示你是否设置rewrite的,其中就有WP伪静态的选项,根本不用自己去写。
    Gauin
        9
    Gauin  
    OP
       Oct 30, 2012
    @ajoop 同事是运维工程师 然后后 说前端Nginx 后端Apache服务器性能碉堡啊 你懂的 我就同意了

    工程师都爱折腾啊
    Gauin
        10
    Gauin  
    OP
       Oct 30, 2012
    @chairo

    Gtalk给我帮忙弄一下好吗?我会说我不信你吗? 博客挂了好几天了 就为这事啊 就为这事儿
    TONYHEAD
        11
    TONYHEAD  
       Oct 31, 2012
    有插件的,搜索下nginx
    ybf1220
        12
    ybf1220  
       Oct 31, 2012
    其实前端 nginx 后端 apache 和直接 nginx+php-fpm 相差不是很大。在20%之内。再说 apache2 对 内存是占用很大的。而且容易跨站。 只是对付 php 的话 用php-fpm 管理 fastcgi,这样执行足以,要性能好,可以再安装缓存插件 ,比如 eacc ,memcache,APC,xcache 等,轻量级我比较推崇,虽然 apache2 现在还是web服务器的老大。
    vowmmm
        13
    vowmmm  
       Nov 6, 2014
    @chairo 非常感谢。搞了好久,试来试去,大家都说,“直接用.htaccess解决,nginix什么都不用做”。最终发现,不是apache的.htaccess的问题。加上

    location / {
    try_files $uri @apache ;
    }

    location @apache {
    internal;
    proxy_pass http://127.0.0.1:81;
    include proxy.conf;
    }

    就可以了。我又查了一下@apache的意思,没找到。
    能说说@apache的意思吗?
    About     Help     Advertise     Blog     API     FAQ     Solana     3246 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 76ms UTC 11:37 PVG 19:37 LAX 04:37 JFK 07:37
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86