雲網

 找回密碼
 立即註冊
搜索
熱搜: 活動 交友 discuz
查看: 1788|回復: 0

[實測]Centos 8 + Apache + MariaDB + PHP 7.2 + phpMyAdmin 5 安裝

[複製鏈接]

30

主題

38

帖子

290

積分

區版主

Rank: 8Rank: 8

積分
290
發表於 2020-6-6 22:13:12 | 顯示全部樓層 |閱讀模式
本帖最後由 cliff 於 2020-6-6 22:51 編輯

修改 hostname
  1. hostnamectl set-hostname cloud.hk
複製代碼

使用 Yum 更新
  1. sudo yum -y update
複製代碼

  1. sudo dnf install httpd mariadb-server wget unzip
複製代碼
  1. sudo dnf install php php-pdo php-pecl-zip php-json php-mbstring php-mysqlnd
複製代碼
  1. sudo systemctl enable httpd.service
  2. sudo systemctl start httpd.service
複製代碼

  1. systemctl start httpd
  2. systemctl start mariadb
  3. systemctl enable httpd
  4. systemctl enable mariadb
複製代碼


設定 MariaDB
  1. mysql_secure_installation
複製代碼
  1. Securing the MySQL server deployment.

  2. Connecting to MySQL using a blank password.

  3. VALIDATE PASSWORD COMPONENT can be used to test passwords
  4. and improve security. It checks the strength of password
  5. and allows the users to set only those passwords which are
  6. secure enough. Would you like to setup VALIDATE PASSWORD component?

  7. Press y|Y for Yes, any other key for No: y

  8. There are three levels of password validation policy:

  9. LOW    Length >= 8
  10. MEDIUM Length >= 8, numeric, mixed case, and special characters
  11. STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

  12. Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
  13. Please set the password for root here.

  14. New password:

  15. Re-enter new password:

  16. Estimated strength of the password: 100
  17. Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
  18. By default, a MySQL installation has an anonymous user,
  19. allowing anyone to log into MySQL without having to have
  20. a user account created for them. This is intended only for
  21. testing, and to make the installation go a bit smoother.
  22. You should remove them before moving into a production
  23. environment.

  24. Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
  25. Success.


  26. Normally, root should only be allowed to connect from
  27. 'localhost'. This ensures that someone cannot guess at
  28. the root password from the network.

  29. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
  30. Success.

  31. By default, MySQL comes with a database named 'test' that
  32. anyone can access. This is also intended only for testing,
  33. and should be removed before moving into a production
  34. environment.


  35. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
  36. - Dropping test database...
  37. Success.

  38. - Removing privileges on test database...
  39. Success.

  40. Reloading the privilege tables will ensure that all changes
  41. made so far will take effect immediately.

  42. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
  43. Success.

  44. All done!
複製代碼

  1. wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.zip
  2. unzip phpMyAdmin-5.0.2-all-languages.zip
  3. mv phpMyAdmin-5.0.2-all-languages /usr/share/phpmyadmin
  4. cp -pr /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
複製代碼

創建一個 tmp 在 phpmyadmin 裡面
  1. mkdir /usr/share/phpmyadmin/tmp
  2. chown -R apache:apache /usr/share/phpmyadmin
  3. chmod 777 /usr/share/phpmyadmin/tmp
複製代碼


設定 config.inc.php, 加入 Blowfish Secret
Blowfish Secret Generator
  1. sudo vim /usr/share/phpmyadmin/config.inc.php
複製代碼

並加入以下
  1. $cfg['TempDir'] = '/tmp';
複製代碼


  1. vi /etc/httpd/conf.d/phpmyadmin.conf
複製代碼

  1. Alias /phpmyadmin /usr/share/phpmyadmin

  2. <Directory /usr/share/phpmyadmin/>
  3.    AddDefaultCharset UTF-8
  4.    <IfModule mod_authz_core.c>
  5.      # Apache 2.4
  6.      <RequireAny>
  7.       Require all granted
  8.      </RequireAny>
  9.    </IfModule>
  10. </Directory>

  11. <Directory /usr/share/phpmyadmin/setup/>
  12.    <IfModule mod_authz_core.c>
  13. # Apache 2.4
  14.      <RequireAny>
  15.        Require all granted
  16.      </RequireAny>
  17.    </IfModule>
  18. </Directory>
複製代碼

  1. chcon -Rv --type=httpd_sys_content_t /usr/share/phpmyadmin/*
複製代碼


增加到服務器的防火牆
  1. sudo firewall-cmd --permanent --zone=public --add-service=http
  2. sudo firewall-cmd --permanent --zone=public --add-service=https
  3. sudo firewall-cmd --reload
複製代碼



First, install the policycoreutils-python-utils package to manage an SELinux environment with the following command:

dnf install policycoreutils-python-utils
Next, enable access to /usr/share/phpmyadmin directory with the following command:

semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/phpmyadmin/'
semanage fcontext -a -t httpd_sys_rw_content_t "/usr/share/phpmyadmin/tmp(/.*)?"
Now recurse through all the files in your phpmyadmin directory by running the following command:

restorecon -Rv '/usr/share/phpmyadmin/'
Next, you will need to create a firewall rule to allow HTTP service from external networks. You can allow it with the following command:

firewall-cmd --permanent --add-service=http
firewall-cmd --reload
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

Archiver|手機版|小黑屋|雲峰香港

GMT+8, 2020-11-30 12:08 , Processed in 0.046783 second(s), 18 queries .

© 2017 Cloud.hk. All Rights Reserved.

快速回復 返回頂部 返回列表