0
user-people-family-house-home

【Mysql】Phpmyadmin部署於Ubuntu

本篇介紹如何在 Ubuntu Linux; 的環境中,安裝PhpMyAdmin套件於網頁中顯示。# 更新系統套件sudo...

Posted by Roy on 2021-10-14 14:39:58 Views

本篇介紹如何在 Ubuntu Linux  的環境中,安裝PhpMyAdmin套件於網頁中顯示。

# 更新系統套件
sudo apt updatet
# 安裝phpmyadmin
sudo apt install phpmyadmin

設定軟連結

sudo ln -s /usr/share/phpmyadmin {phpmyadmin_path}

設定Nginx

Ubuntu預設Nginx位置為/etc/nginx

建立sites-available的phpmyadmin.conf

server {
  listen 80;
  listen [::]:80;

  # 網頁目錄
  root /var/www/phpmyadmin;

  # 伺服器名稱
  server_name {your_domain};

  location / {
    try_files $uri/index.php?$query_string;
    root /var/www/phpmyadmin;
    index  index.php index.html;
  }

  location ~ \.php$ {
      fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
      fastcgi_index  index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
  }
error_page 403 404 /404.html; location = /40x.html{ } error_page 500 502 503 504 /50x.html; location = /50x.html { } #301永久轉址(443),轉址時,改變Request Method為GET,無法保留POST資料 #return 301 https://$host$request_uri; #308永久轉址,轉址時,不改變Request Method,能保留POST資料 #return 308 https://$host$request_uri; }

設定完.conf之後,利用軟連結(ln)至sites-enabled

# 進入/etc/nginx/sites-enabled
cd /etc/nginx/sites-enabled
# 設定軟連結
sudo ln -s ../sites-available/phpmyadmin.conf

設定完成後重新開啟Nginx

# 重新啟動Nginx
sudo nginx -s reload

新增一位DB User給予資料庫權限

# 建立一般使用者帳號
CREATE USER `user`@`localhost` IDENTIFIED BY 'yourpassword';

# 設定帳號權限
GRANT ALL ON laravel.* TO `user`@`localhost`;

# 讓設定生效
FLUSH PRIVILEGES;

或者是給予全域的超級管理員

# 建立一般使用者帳號
CREATE USER `user`@`%` IDENTIFIED BY 'yourpassword';

# 設定帳號權限
GRANT ALL PRIVILEGES ON *.* TO 'user';
# 讓設定生效 FLUSH PRIVILEGES;

View Comments