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

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