CentOS+Apache+PHP+MariaDB環境搭建

  • Apache 2.4.6
  • MariaDB 5.5.60

一、安裝 MariaDB

  1. 首先查看yum裏面是否包含MariaDB的包。
[admin@localhost Desktop]$ yum list | grep mariadb
mariadb.x86_64                              1:5.5.60-1.el7_5           @base    
mariadb-libs.x86_64                         1:5.5.60-1.el7_5           @base    
mariadb-bench.x86_64                        1:5.5.60-1.el7_5           base     
mariadb-devel.i686                          1:5.5.60-1.el7_5           base     
mariadb-devel.x86_64                        1:5.5.60-1.el7_5           base     
mariadb-embedded.i686                       1:5.5.60-1.el7_5           base     
mariadb-embedded.x86_64                     1:5.5.60-1.el7_5           base     
mariadb-embedded-devel.i686                 1:5.5.60-1.el7_5           base     
mariadb-embedded-devel.x86_64               1:5.5.60-1.el7_5           base     
mariadb-libs.i686                           1:5.5.60-1.el7_5           base     
mariadb-server.x86_64                       1:5.5.60-1.el7_5           base     
mariadb-test.x86_64                         1:5.5.60-1.el7_5           base

2.進行安裝。

[admin@localhost Desktop]$ sudo yum install mariadb mariadb-server -y

3.查看是否安裝成功。

[admin@localhost Desktop]$ rpm -qa | grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-server-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64

4.常用命令。

# 查看 mariadb 安裝位置
[admin@localhost Desktop]$ rpm -ql mariadb
# 設置開機自動啓動
[admin@localhost Desktop]$ systemctl enable mariadb
# 開啓mariadb服務
[admin@localhost Desktop]$ systemctl start mariadb
# 關閉 mariadb 服務
[admin@localhost Desktop]$ systemctl stop mariadb
# 重啓mariadb服務
[admin@localhost Desktop]$ systemctl restart mariadb

5.使用數據庫。

[admin@localhost Desktop]$ mysql -u root -p

二、安裝Apache組件

1.首先查看yum裏面是否包含httpd的包。

[admin@localhost Desktop]$ yum list | grep httpd
httpd.x86_64                                2.4.6-89.el7.centos.1      updates  
httpd-devel.x86_64                          2.4.6-89.el7.centos.1      updates  
httpd-manual.noarch                         2.4.6-89.el7.centos.1      updates  
httpd-tools.x86_64                          2.4.6-89.el7.centos.1      updates  
keycloak-httpd-client-install.noarch        0.6-3.el7                  base     
libmicrohttpd.i686                          0.9.33-2.el7               base     
libmicrohttpd.x86_64                        0.9.33-2.el7               base     
libmicrohttpd-devel.i686                    0.9.33-2.el7               base     
libmicrohttpd-devel.x86_64                  0.9.33-2.el7               base     
libmicrohttpd-doc.noarch                    0.9.33-2.el7               base     
python2-keycloak-httpd-client-install.noarch

2.進行安裝。

[admin@localhost Desktop]$ sudo yum install httpd -y

3.查看是否安裝成功。

[admin@localhost Desktop]$ rpm -qa | grep httpd
httpd-tools-2.4.6-89.el7.centos.1.x86_64
httpd-2.4.6-89.el7.centos.1.x86_64

4.常用命令。

# 查看 httpd 安裝位置
[admin@localhost Desktop]$ rpm -ql httpd
# 設置開機自動啓動
[admin@localhost Desktop]$ systemctl enable httpd
# 開啓httpd服務
[admin@localhost Desktop]$ systemctl start httpd
# 關閉httpd服務
[admin@localhost Desktop]$ systemctl stop httpd
# 重啓http服務
[admin@localhost Desktop]$ systemctl restart httpd

5.測試。
啓動服務後, 瀏覽器打開http://127.0.0.1/即可查看網頁。
配置文件在 /etc/httpd/conf

參考文獻

https://www.linuxidc.com/Linux/2018-03/151403.htm
http://down.chinaz.com/server/201109/1064_1.htm

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