这里是在Centos7系统里采用纯yum的方式安装,纯手工一步一步的配置。
1、首先关闭防火墙和selinux
分别执行两个命令和修改selinux配置文件
# systemctl stop firewalld.service
# systemctl disable firewalld.service
# vim /etc/selinux/config 修改完后重启生效
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #把这个变量改成disabled就紧止了selinux了
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
2、yum分布安装httpd、mariadb、mariadb-server、php、php-mysql
# yum install -y httpd
# yum install -y mariadb mariadb-server
# yum install -y php php-mysql
启动httpd、mariadb、重启httpd才能使php关联上httpd
# systemctl start httpd
# systemctl enable httpd
# systemctl start mariadb
# systemctl enable mariadb
环境搭建好了下面解释一下配置文件
# rpm -qc httpd
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd
# vim /etc/httpd/conf/httpd.conf #由于内容太多了这里就重点罗列几个重要的讲解一下
Listen 80 #httpd服务所需要的端口
User apache #httpd的用户
Group apache #httpd的属组
ServerAdmin root@localhost #httpd有新消息指定发送给的邮箱
#ServerName www.example.com:80 #指定访问域名默认是注释的
DocumentRoot "/var/www/html" #网站存放的目录必须有
<IfModule dir_module>
DirectoryIndex index.html #指定进来后访问的首页可以是index.php很重要
</IfModule>
AddDefaultCharset UTF-8 #网站解析用的字节码默认utf8很重要
进到这个目录里# cd /var/www/html并写HTML代码运行测试成功