1. 程式人生 > >CentOS 7.x 安裝LAMP

CentOS 7.x 安裝LAMP

通過命令 出現 mbstring utf embedded fedora list 探測 onf

CentOS 7.x 安裝apache [root@localhost ~]#yum -y install httpd httpd-devel [root@localhost ~]# systemctl start httpd [root@localhost ~]# systemctl enable httpd CentOS 7.x 安裝 Mariadb 數據庫 [root@localhost ~]# yum -y install mariadb mariadb-server mariadb-libs mariadb-devel [root@localhost ~]# systemctl start mariadb [root@localhost ~]# systemctl enable mariadb
數據庫安全設置: [root@localhost ~]# mysql_secure_installation 登陸數據庫: [root@localhost ~]# mysql -uroot -p Centos7.x 使用yum安裝php7 1.安裝epel-release 通過命令: yum -y install epel-release 成功安裝。 2.安裝PHP7 終端再次運行如下命令: rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 成功獲取PHP7的yum源,然後再執行: yum -y install php70w
Centos7.x 使用yum安裝php7.2 1、如果之前已經安裝低版本php,先卸載: [root@localhost ~]#yum -y remove php* 2、由於linux的yum源不存在php7.x,所以我們要更改yum源 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 3、yum 安裝php72w和各種拓展模塊,選自己需要的即可 yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
4、最後,寫一個PHP探測指針,測試PHP: [root@localhost ~]#cd /var/www/html/ [root@localhost ~]#vi info.php <?php phpinfo(); ?> 保存並退出 5、重啟apache服務器: [root@localhost ~]# systemctl restart httpd 6、訪問 http://localhost/info.php *將php與數據庫關聯: [root@localhost ~]#yum install php-mysql CentOS 7.x 安裝phpmyadmin 1、先安裝epel,不然安裝pgpmyadmin時會出現找不到包。 [root@localhost ~]# yum install epel-release [root@localhost ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm 2、[root@localhost ~]# sudo yum install phpmyadmin 3、用文本編輯器打開phpMyAdmin的配置文件(路徑:/etc/httpd/conf.d/phpMyAdmin.conf),找出並註釋掉帶有"Require ip XXXX"字樣的代碼行。會有四處這樣的代碼行,用"Require all granted"取而代之 [root@localhost ~]# sudo vi /etc/httpd/conf.d/phpMyAdmin.conf 修改後的文件內容
  1. <Directory /usr/share/phpMyAdmin/>
  2. AddDefaultCharset UTF-8
  3. <IfModule mod_authz_core.c>
  4. # Apache 2.4
  5. <RequireAny>
  6. # Require ip 127.0.0.1 #註釋掉
  7. # Require ip ::1 #註釋掉
  8. Require all granted #新添加
  9. </RequireAny>
  10. </IfModule>
  11. <IfModule !mod_authz_core.c>
  12. # Apache 2.2
  13. Order Deny,Allow
  14. Deny from All
  15. Allow from 127.0.0.1
  16. Allow from ::1
  17. </IfModule>
  18. </Directory>
  19. <Directory /usr/share/phpMyAdmin/setup/>
  20. <IfModule mod_authz_core.c>
  21. # Apache 2.4
  22. <RequireAny>
  23. #Require ip 127.0.0.1 #註釋掉
  24. #Require ip ::1 #註釋掉
  25. Require all granted #新添加
  26. </RequireAny>
  27. </IfModule>
  28. <IfModule !mod_authz_core.c>
  29. # Apache 2.2
  30. Order Deny,Allow
  31. Deny from All
  32. Allow from 127.0.0.1
  33. Allow from ::1
  34. </IfModule>
  35. </Directory>
4、[root@localhost ~]# systemctl restart httpd

CentOS 7.x 安裝LAMP