如何创建wordpress插件目录的nginx别名

时间:2014-12-23 16:26:41

标签: wordpress nginx alias symlink

我在nginx上运行wordpress并尝试创建一个别名,指向一个插件目录,我在其中编写了一些我自己在git下编译的插件。目前我正在使用unix符号链接来完成这项工作,但是我更愿意使用nginx这样做(如果可能的话)并使我从dev转换为prod更加无缝。我似乎无法正确配置。我在下面包含了我的目录结构和nginx配置。任何帮助将不胜感激 - 谢谢!

WP安装(显示我想用nginx别名替换的符号链接

/home/foobar/www/wordpress
---- /wp-content/plugins
-------- /hello-dolly/
-------- /akismet/
-------- mycustom1 -> /home/foobar/myplugins/mycustom1/
-------- mycustom2 -> /home/foobar/myplugins/mycustom1/

我的自定义插件(在git 下版本化)

/home/foobar/myplugins
---- /mycustom1/
---- /mycustom2/

Nginx配置

server {

    listen       80;

    server_name foobar.com;
    root    /home/foobar/www/wordpress;
    index   index.php;

    autoindex    off;   

    location / {
        try_files $uri $uri/ /index.php?$args;        
    }

    location /wp-content/plugins/myplugin {
        alias /home/foobar/myplugins/mycustom1/;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_buffer_size 4K;
        fastcgi_buffers 64 4k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        include  /etc/nginx/fastcgi_params;
        fastcgi_param WP_ROOT $document_root;
    }

}

0 个答案:

没有答案