2013-04-27 87 views
1

我設置了nginx php5-fpm在Ubuntu 12.04LTS for wordpress和phpMyAdmin。nginx設置位置錯誤下載

我的phpMyAdmin的座落在/var/www/phpMyAdmin,在/var/run/mysqld/mysqld.sock

我要地圖/到WordPress,/phpmyadmin到phpMyAdmin WordPress的在/home/user/workspace/wordpress,MySQL的,所以我怎麼能做到這一點?

WordPress的似乎確定,但當訪問/phpmyadmin,瀏覽器「下載」請求作爲文件...?

這是我目前nginx.conf:

server { 
    listen 8000; 
    root /home/user/workspace/wordpress; 
    index index.html index.htm index.php;\ 

    location ~* /phpmyadmin { #TODO: shall here be a tailing slash?? 
     #TODO: root or alias??? 
    } 

    location ~ \..*/.*\.php$ { 
     return 403; 
    } 
    location/{ 
     #TODO: show the following line be un-commented?? 
     #try_files $uri $uri/ /index.php?q=$uri&$args; 
     # Uncomment to enable naxsi on this location 
     # include /etc/nginx/naxsi.rules 
    } 
    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini 
     fastcgi_intercept_errors on; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php;#TODO: could this being removed?? 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 

    #FIXME: and how to block all access to /home/user/workspace/wordpress/server.d/* 
    #This doesn't work?? 
    location /sever\.d { 
     autoindex on; 
     deny all; 
    } 

而且,我要兩個目錄wordpress/phpMyAdmin/設置什麼權限,如果所有的服務器都運行爲www-data:www-data? 目前我將它們設置爲755 user:www-data,是否正確?

我還沒有在linux下設置服務器,我在WinXP下使用這些服務器,所以我在嘗試。

回答

1

位置之間添加此

location /phpmyadmin { 
      root /usr/share/; 
      index index.php index.html index.htm; 
      location ~ ^/phpmyadmin/(.+\.php)$ { 
        try_files $uri =404; 
        root /usr/share/; 
        fastcgi_pass 127.0.0.1:9000; 
        fastcgi_index index.php; 
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
        include /etc/nginx/fastcgi_params; 
      } 
      location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { 
        root /usr/share/; 
      } 
    } 
    location /phpMyAdmin { 
      rewrite ^/* /phpmyadmin last; 
    } 

隨時隨地 之間也 丟失的服務器名稱。鍵入server_name example.com;

+0

所以我必須爲phpmyadmin安裝另一個cgi處理程序? – user1034937 2013-04-29 15:26:59