CentOS 7.x 安裝LAMP
阿新 • • 發佈:2018-10-11
通過命令 出現 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
修改後的文件內容
- <Directory /usr/share/phpMyAdmin/>
- AddDefaultCharset UTF-8
- <IfModule mod_authz_core.c>
- # Apache 2.4
- <RequireAny>
- # Require ip 127.0.0.1 #註釋掉
- # Require ip ::1 #註釋掉
- Require all granted #新添加
- </RequireAny>
- </IfModule>
- <IfModule !mod_authz_core.c>
- # Apache 2.2
- Order Deny,Allow
- Deny from All
- Allow from 127.0.0.1
- Allow from ::1
- </IfModule>
- </Directory>
- <Directory /usr/share/phpMyAdmin/setup/>
- <IfModule mod_authz_core.c>
- # Apache 2.4
- <RequireAny>
- #Require ip 127.0.0.1 #註釋掉
- #Require ip ::1 #註釋掉
- Require all granted #新添加
- </RequireAny>
- </IfModule>
- <IfModule !mod_authz_core.c>
- # Apache 2.2
- Order Deny,Allow
- Deny from All
- Allow from 127.0.0.1
- Allow from ::1
- </IfModule>
- </Directory>
CentOS 7.x 安裝LAMP