我有我的nginx安装我的phpmyadmin问题。
当我input<ServerIP>/phpmyadmin并login时,我被redirect到<ServerIP>/index.php?<tokenstuff>而不是<ServerIP>/phpmyadmin/index.php?<tokenstuff>
Nginxconfiguration文件:
user nginx; worker_processes 5; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 2; #gzip on; include /etc/nginx/conf.d/*.conf; }
Default.conf:
server { listen 80; server_name _; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html; index index.php index.html index.htm; } #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 /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /usr/share/nginx/html; try_files $uri =404; fastcgi_pass unix:/tmp/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$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; } location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share/; fastcgi_pass unix:/tmp/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_script_name; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } }
(关于整理这些configuration文件的任何一般技巧也被接受)
这听起来不像一个nginx问题。 这听起来像phpMyAdmin没有正确安装,并认为它在/而不是/phpmyadmin 。 检查你的phpMyAdminconfiguration。
即使作者已经解决了重新安装phpMyAdmin的问题,nginx需要正确configuration,以便正确地处理login时的redirect。
经过几天在键盘上砸我的头,我终于find了真正的解决scheme,我在这里分享,因为这个线程仍然在谷歌search的优先事项。
正如链接所述: http : //www.samundra.com.np/use-phpmyadmin-with-nginx-and-php7/1374
为了解决这个问题,你应该将下面的代码块添加到你的nginx默认站点 – 可用,你可以通过以下方式访问它:
sudo nano /etc/nginx/sites-available/default
将此块放在server块中:
# Phpmyadmin Configurations 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_param HTTPS on; # <-- add this line fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } # Dealing with the uppercased letters location /phpMyAdmin { rewrite ^/* /phpmyadmin last; }
我希望这有助于某个人
你的问题似乎是这样的: https : //stackoverflow.com/questions/1011101/nginx-location-directive-doesnt-seem-to-be-working-am-i-missing-something
如果通过阅读和改变你的configuration你仍然有问题,请告诉!
这个问题是由cgi.fix_pathinfo = 0的常见configuration导致的,它禁用PHP-FPM的当前path。 一个简单的解决scheme是将cgi.fix_pathinfo更改回1,或者在nginx的虚拟服务器块上设置path参数。
添加一个virtaul主机到您的灯服务器与任何域名如phpmyadmin1.com
server { #listen 80 default_server; #listen [::]:80 default_server ipv6only=on; root /var/www/phpmyadmin; #some /var/www/html/phpmyadmin index index.php index.html index.htm; server_name phpmyadmin1.com; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { root /usr/share/nginx/html; try_files $uri =404; fastcgi_pass unix:/tmp/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
编辑您的主机文件
在底部添加这一行
192.168.1.xx phpmyadmin1.com
保存并closures,然后重新启动您的服务器
service nginx restart service php5-fpm restart
在浏览器上访问您的虚拟主机url,看看phpmyadmin的login页面
只有这对我有效
location /utils/phpmyadmin/ { try_files $uri $uri/ =404; index index.php index.html index.htm proxy_set_header Proxy ""; }
打开:/var/lib/phpMyAdmin/config.inc.php
添加:$ cfg ['PmaAbsoluteUri'] =' https ://www.example.net/path_to_your_phpMyAdmin_directory/';
请参阅: https : //docs.phpmyadmin.net/en/latest/config.html#basic-settings
来自Ubuntu 16.04和更高版本库的phpMyAdmin不能正确redirect。
我只是从官方的phpmyadmin网站下载新版本的phpmyadmin:
sudo wget https://files.phpmyadmin.net/phpMyAdmin/4.6.6/phpMyAdmin-4.6.6-all-languages.tar.gz sudo tar xvf phpMyAdmin-4.6.6-all-languages.tar.gz sudo mv phpMyAdmin-4.6.6-all-languages /usr/share/phpmyadmin sudo rm -rf phpMyAdmin-4.6.6-all-languages.tar.gz sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
打开config.inc.php:
sudo nano /usr/share/phpmyadmin/config.inc.php
并把一些随机的字符“
$cfg['blowfish_secret'] = 'i\kywQ>_h4L~S-Pt2rS'VAe)QpED7JI#';
保存并在浏览器中打开您的域/ phpmyadmin
你也可以改变链接到phpmyadmin(为了更好的安全性),并添加从nginx到链接的基本身份validation:
sudo ln -s /usr/share/phpmyadmin /var/www/html cd /var/www/html sudo mv phpmyadmin anything
现在你的phpmyadmin在https:// domain / anything上工作 ,让我们添加一些密码:
sudo sh -c "echo -n 'YourNameForLoginThere:' >> /etc/nginx/pmapass" sudo sh -c "openssl passwd -apr1 >> /etc/nginx/pmapass"
现在打开你的nginxconfiguration(默认情况下: sudo nano / etc / nginx / sites-available / default )并添加befor last}
location /anything { auth_basic "Restricted"; auth_basic_user_file /etc/nginx/pmapass; }
启用configuration存储:
sudo nano /usr/share/phpmyadmin/config.inc.php
find以下几行:
// $cfg['Servers'][$i]['controluser'] = 'pma'; // $cfg['Servers'][$i]['controlpass'] = 'pmapass';
改成:
$cfg['Servers'][$i]['controluser'] = 'yourdatabaseuser'; $cfg['Servers'][$i]['controlpass'] = 'yourdatabasepassword';
定位:
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; // $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; // $cfg['Servers'][$i]['relation'] = 'pma__relation'; // $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; // $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords'; // $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages'; // $cfg['Servers'][$i]['column_info'] = 'pma__column_info'; // $cfg['Servers'][$i]['history'] = 'pma__history'; // $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs'; // $cfg['Servers'][$i]['tracking'] = 'pma__tracking'; // $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; // $cfg['Servers'][$i]['recent'] = 'pma__recent'; // $cfg['Servers'][$i]['favorite'] = 'pma__favorite'; // $cfg['Servers'][$i]['users'] = 'pma__users'; // $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups'; // $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; // $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches'; // $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns'; // $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings'; // $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
取消注释( 删除// )
现在保存并退出。
去你的MySQL(默认情况下: sudo mysql -u root -p )
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'yourdatabaseuser'@'localhost' IDENTIFIED BY 'yourdatabasepassword'; exit;
现在尝试在浏览器中打开域/任何东西