NGINX更改phpmyadmin网址

bweufnob  于 2023-03-07  发布在  Nginx
关注(0)|答案(3)|浏览(302)

我最近将我的网站的URL从www.example.com改为www.mydomain.commydomain.com(无子域),运行Ubuntu上的NGINX。我让phpmyadmin在www.example.com上工作www.mydomain.com/phpmyadmin(使用本教程:https://www.digitalocean.com/community/articles/how-to-install-phpmyadmin-on-a-lemp-server/),但是在更改了url之后,我在登录后得到了一个白色页。是否需要更改一些phpmyadmin配置文件来反映此url更改?

cgvd09ve

cgvd09ve1#

这将把你的/phpmyadmin更改为/otherfilename,并且适用于LEMP服务器(nginx)

  1. sudo apt更新
  2. sudo apt安装程序phpmyadmin
    1.用户名:/usr/share/phpmyadmin/var/www/html/phpmyadmin
    1.检查你的网址https://server_domain_or_IP/phpmyadmin
    1.更新您的vhost
location /phpmyadmin {
    root /usr/share/;
    index index.php;

    try_files $uri $uri/ =404;
    location ~ ^/phpmyadmin/(doc|sql|setup)/ {
        deny all;
    }

    location ~ /phpmyadmin/(.+\.php)$ {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        include snippets/fastcgi-php.conf;
    }
}
  1. sudo服务nginx重新启动
    1.再次检查你的网址到访问phpmyadmin
  2. cd/变量/网址/html/
  3. ls-l
    1.检查phpmyadmin文件
    1.创建符号文件
sudo mv phpmyadmin otherfilename
  1. ls-l
    1.检查您新符号文件并在5中更改您的虚拟主机
location /otherfilename{
    root /var/www/html/;
    index index.php;
    try_files $uri $uri/ =404;

    location ~ ^/otherfilename/(doc|sql|setup)/ {
        deny all;
    }

    location ~ /otherfilename/(.+\.php)$ {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        include snippets/fastcgi-php.conf;
    }
}
  1. sudo服务nginx重新启动
    1.检查你的新网址https://server_domain_or_IP/otherfilename
xdnvmnnf

xdnvmnnf2#

请查看/etc/nginx/site-available/default,您需要在其中添加location /phpmyadmin

eqoofvh9

eqoofvh93#

还有另一种方法,使用alias指令代替root。

location /ddh73d1re1tp01hpn8sbceryzzzcp1 {
            alias /usr/share/phpmyadmin;
            index index.php index.html index.htm;

            location ~ ^/ddh73d1re1tp01hpn8sbceryzzzcp1/(.+\.php)$ {
                     try_files $uri =404;
                     fastcgi_pass unix:/run/php/php8.1-fpm.sock;
                     fastcgi_index index.php;
                     fastcgi_param SCRIPT_FILENAME $request_filename;
                     include /etc/nginx/fastcgi_params;
}

相关问题