1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

/phpmyadminのBASIC認証対策してても,管理画面だしたくない。URL変えようぜ!

Last updated at Posted at 2016-05-04

#よくあるサンプルが・・

server {
       server_name  ***;

        location /phpmyadmin {
                root /usr/share/phpMyAdmin;
                index index.php;
                }

             location ~ ^/phpmyadmin.+\.php$ {
                    ###### 中略 ######
                ・
                ・
                ・
             ###### 中略 ######
  
                  }
        }#phpmyadmin
}#server

これに↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
BASIC認証つけますよと・・

location /phpmyadmin {
       #BASIC
       auth_basic "Restricted";
       auth_basic_user_file /etc/nginx/.htpasswd;
       # root /usr/share;
        root /var/www;
        index index.php;

       location ~ ^/phpmyadmin.+\.php$ {
             # fastcgi_pass unix:/var/run/php5-fpm.sock;
             fastcgi_pass   127.0.0.1:9000;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             include fastcgi_params;
        }
     }#phpAdmin

大抵の人がこれの場合でログインできなくても管理画面(ログイン画面)が出てしまいます汗
これにIP制限とかもできますが・・
外からもアクセスしたい人や、IPが固定じゃない苦学生,制限できない事情がある方はURLを変えて隠そうぜ笑
IP制限してる人もURL変更しちゃおう

#現在のphpmyadminのシンボルクリックへ移動して

cd /usr/share/nginx/html
ls -l
total 8
-rw-r--r-- 1 root root 537 Mar  4 06:46 50x.html
-rw-r--r-- 1 root root 612 Mar  4 06:46 index.html
lrwxrwxrwx 1 root root  21 Aug  6 10:50 phpmyadmin -> /usr/share/phpmyadmin

#シンボルクリック名変更
sudo mv phpmyadmin hoge
# location/phpmyadmin {
location /hoge{
        #BASIC
        auth_basic "Restricted";
       auth_basic_user_file /etc/nginx/.htpasswd;
       # root /usr/share;
        root /var/www;
        index index.php;

       # location ~ ^/phpmyadmin.+\.php$ {
        location ~ ^/hoge.+\.php$ {
             # fastcgi_pass unix:/var/run/php5-fpm.sock;
             fastcgi_pass   127.0.0.1:9000;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             include fastcgi_params;
        }
     }#phpAdmin

設定ファイル再読み込み
sudo service nginx reload

http://server_name/phpmyadmin/
ではエラーが出て
こうすれば自分が設定したserver_nameとhogeの部分でアクセスができるようになる!  http://server_name/hoge/

できない人はシンボルクリックの権限、所有者とか変えてみてください。

#確認
ls -l
#変更
sudo chown ユーザ名 hoge

以上 未熟な大学生より。

参考文献
Nginx と安全な phpMyAdmin :https://websetnet.com/ja/install-and-secure-phpmyadmin-with-nginx-on-an-ubuntu-14-04/
BASIC認証:http://aratatool.com/app2/knowledge/knowledge/5

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?