Jump to content
View in the app

A better way to browse. Learn more.

PHP论坛人

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

安裝phpMyAdmin、修改為 888 port、使用IP當phpMyAdmin的網址來管理資料庫

Featured Replies

安裝phpMyAdmin、修改為 888 port、使用IP當phpMyAdmin的網址來管理資料庫

----------------------------
安裝phpMyAdmin
----------------------------


開始修改
vi /etc/nginx/sites-available/default



搜尋內容
index index.html index.htm index.nginx-debian.html;

修改為
index index.html index.htm index.php;



ESC儲存並離開
:wq



先到phpMyAdmin官網,最新版本是多少,例如 phpMyAdmin 5.2.3
https://www.phpmyadmin.net/



cd /root

wget -P Downloads https://files.phpmyadmin.net/phpmyadmin.keyring


wget -P Downloads https://files.phpmyadmin.net/phpMyAdmin/5.2.3/phpMyAdmin-5.2.3-all-languages.tar.gz


cd Downloads


gpg --import phpmyadmin.keyring


wget https://files.phpmyadmin.net/phpMyAdmin/5.2.3/phpMyAdmin-5.2.3-all-languages.tar.gz.asc


gpg --verify phpMyAdmin-5.2.3-all-languages.tar.gz.asc


mkdir /var/www/html/phpMyAdmin


tar xvf phpMyAdmin-5.2.3-all-languages.tar.gz --strip-components=1 -C /var/www/html/phpMyAdmin


cp /var/www/html/phpMyAdmin/config.sample.inc.php /var/www/html/phpMyAdmin/config.inc.php



vi /var/www/html/phpMyAdmin/config.inc.php


搜尋
$cfg['blowfish_secret'] = '';


修改為
$cfg['blowfish_secret'] = '自定一個長度為32位元的隨機字串';




ESC儲存並離開
:wq




chmod 660 /var/www/html/phpMyAdmin/config.inc.php

chown -R www-data:www-data /var/www/html/phpMyAdmin



重新加载Nginx
nginx -t


systemctl reload nginx



然後修改 (請注意這是搭配PHP 8.4的設置)
vi /etc/nginx/sites-available/default


搜尋這代碼
        location / { 
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        } 


然後,在這段代碼的底下,加入


                location ~ \.php$ {
                        include snippets/fastcgi-php.conf;
                        fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
                }




ESC儲存並離開
:wq






重新加载Nginx
nginx -t

systemctl reload nginx




現在瀏覽器可以進入phpMyAdmin (此時 http 是用 80 port)

http://你的IP/phpMyAdmin






---------------------------------
phpMyAdmin改為 888 port
---------------------------------

我慣用伺服器IP當作phpMyAdmin的網址,並改為 888 port,利用防火牆擋住全部IP連入,限自己的IP才能連入phpMyAdmin


預設網站目錄是放在 /var/www/html/phpMyAdmin/


修改為 888 port,才能連到phpMyAdmin
vi /etc/nginx/sites-available/default


搜尋
listen 80 default_server;
修改為
listen 888 default_server;


下面那一行,使用 # 註解掉
#listen [::]:80 default_server; 



ESC儲存並離開
:wq



重新加载Nginx
nginx -t

systemctl reload nginx



重開機,再次確認是否能正確運行
reboot



phpMyAdmin 已改為 888 port

然後雲主機的WAF防火牆、iptables防火牆,也要修改 888 port 只允許自己的IP才可以連入


這時,防火牆都修改完畢,瀏覽器進入你的伺服器IP

http://你的IP:888/phpMyAdmin/


你將看到這個訊息
尚未設定 phpMyAdmin 設定儲存空間,部份延伸功能將無法使用。了解原因。
或者前往任一個資料庫的「操作」分頁設定。



你需要下載 https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

解壓縮 phpMyAdmin-latest-all-languages.tar.gz

尋找目錄中 /sql/create_tables.sql

找到 create_tables.sql




返回瀏覽器 phpMyAdmin -> 匯入 -> 要匯入的檔案 -> 選擇檔案 -> create_tables.sql -> 匯入

將顯示
完成匯入,共執行了 21 個查詢指令。 (create_tables.sql)


然後返回phpMyAdmin首頁

尚未設定 phpMyAdmin 設定儲存空間,部份延伸功能將無法使用。-----> 已經沒有顯示這一條訊息

Create an account or sign in to comment

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.