douzi2333 2013-04-27 00:59
浏览 42
已采纳

nginx设置位置错误下载

I'm setting up nginx with php5-fpm on Ubuntu 12.04LTS for wordpress and phpMyAdmin.

My phpMyAdmin locates in/var/www/phpMyAdmin, wordpress in /home/user/workspace/wordpress, MySQL at /var/run/mysqld/mysqld.sock

I want to map / to wordpress, /phpmyadmin to phpMyAdmin, so how can I achieve this??

Wordpress seemed OK, but when accessing /phpmyadmin, the browser "downloads" the request as files...??

This is my current 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;
    }

And, what permission should I set for both the directory wordpress/ and phpMyAdmin/ if all the servers are running as www-data:www-data?? Currently I set them as 755 user:www-data, is that correct??

I haven't set up server under linux yet, I was using those servers under WinXP, so I'm trying.

  • 写回答

1条回答 默认 最新

  • dtp87205 2013-04-28 17:40
    关注

    in you between location add this

    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;
        }
    

    anywhere between also your missing a server name. type in a server_name example.com;

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP