1. rm -f /var/run/yum.pid 清理睡眠状态
rm -f /var/run/yum.pid
firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --permanent --zone=public --add-port=3306/udp
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=80/udp
firewall-cmd --reload
vi /etc/selinux/config #将SELINUX=enforcing这一行修改为SELINUX=disabled
reboot
yum remove mariadb-libs.x86_64
yum install httpd -y
systemctl enable httpd
systemctl restart httpd
systemctl status httpd
yum -y install mariadb mariadb-server
systemctl enable mariadb
systemctl start mariadb
mysql_secure_installation
  1. 开放防火墙

    firewall-cmd --permanent --zone=public --add-port=3306/tcp
    firewall-cmd --permanent --zone=public --add-port=3306/udp
    firewall-cmd --permanent --zone=public --add-port=80/tcp
    firewall-cmd --permanent --zone=public --add-port=80/udp
    firewall-cmd --reload
    systemctl stop firewalld
  2. 关闭selinux
    vi /etc/selinux/config
    将SELINUX=enforcing这一行修改为SELINUX=disabled

  3. reboot

  4. 删除默认数据库
    rpm -qa | grep mariadb 查找出默认数据库mariadb的包名。
    yum remove mariadb-libs.x86_64 删除

  5. yum install httpd -y
    systemctl enable httpd
    systemctl restart httpd
    systemctl status httpd //查看服务状态
    此时访问成功回显apache测试页,网站根目录/var/www/html

  6. 安装mysql
    yum -y install mariadb mariadb-server
    systemctl enable mariadb
    systemctl start mariadb
    mysql_secure_installation

  7. mysql -uroot -p 123456
    GRANT ALL PRIVILEGES ON . TO ‘root‘@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;

  8. FLUSH PRIVILEGES; 远程登陆完成。

  9. exit 退出

  10. php安装

    1. rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    2. yum -y remove php*
    3. yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
    4. systemctl enable php-fpm.service
      systemctl start php-fpm.service
  11. 配置Apache解析php文件并自动关联

    1. vi /etc/httpd/conf/httpd.conf
    2. 找到:DirectoryIndex index.html改为:DirectoryIndex index.html index.htm index.php
    3. 找到:AddType application/x-gzip .gz .tgz在该行下面添加:AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
    4. 重启Apache:systemctl restart httpd
    5. 在浏览器输入服务器IP地址或者绑定的域名访问即可,html文件下是网站主目录,如果是里面有个文件夹才是主目录可以在配置文件修改主目录路径,或者在IP地址访问后面加上文件夹名字。