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;

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

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器