阿里雲服務器(Centos7)搭建PHP開發環境(下)安裝Apache + PHP + PHPmyadmin

【一、安裝Apache】

yum install httpd httpd-devel

【二、安裝PHP及插件】

yum install php php-mysql php-common php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

【三:啓動Apache】

systemctal start httpd

設置Apache的httpd服務開機啓動:chkconfig httpd on

設置MySQL服務開機啓動:chkconfig mysqld on

Apache安裝完成後,根目錄的默認路徑爲/var/www/html/,此時可在些目錄建立PHP文件 如:index.php,輸入代碼:

<?php
phpinfo();
?>

此時可以去瀏覽器測試 ,(默認關閉防火牆)
在這裏插入圖片描述

【四、PHPmyadmin安裝配置】

1、先安裝epel,不然安裝pgpmyadmin時會出現找不到包。

yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

2、安裝,

yum install phpmyadmin

3、修改配置文件

vi /etc/httpd/conf.d/phpMyAdmin.conf

<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8

Apache 2.4

  # Require ip 127.0.0.1  #註釋掉
  # Require ip ::1   #註釋掉
  Require all granted   #新添加

Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1

<Directory /usr/share/phpMyAdmin/setup/>

Apache 2.4

  #Require ip 127.0.0.1  #註釋掉
  #Require ip ::1   #註釋掉
  Require all granted   #新添加

Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1

4、重啓httpd使改動生效。

systemctl restart httpd

5、測試

ip/phpmyadmin
在這裏插入圖片描述

[參考文檔]
https://blog.51cto.com/sonice/2412188
https://www.ruixunidc.net/a/guanyuruixun/wenzhangzixun/wenzhangzhongxin/2019/0708/602.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章