目录
一、安装web服务器相关软件
安装命令:yum -y install httpd mariadb-server mariadb php php-mysql php-gd php-mbstringyum -y install httpd mariadb-server mariadb php php-mysql php-gd php-mbstring
注:
httpd:Apache 服务
mariadb-server:mariadb 数据库服务端
mariadb:数据库客户端
php:PHP 语言
php-mysql:PHP 连接 MySQL 数据库需要用到的扩展
php-gd:php-gd 是 PHP 的一个扩展库,主要用来画图(比如验证码)
php-mbstring:PHP 编码字符集
二、启动和关闭服务
2.1 启动httpd服务:systemctl start httpd
2.2 关闭httpd服务:systemctl stop httpd
2.3 启动mariadb服务:systemctl start mariadb
2.4 关闭mariadb服务:systemctl stop mariadb
2.5 查看web服务状态:systemctl status httpd
2.6 查看mariadb服务状态:systemctl status mariadb
2.7 设置开机自动启动httpd/mariadb服务:systemctl enable httpd/mariadb
三、关闭防火墙
3.1 临时关闭防火墙:systemctl stop firewalld
3.2 永久关闭防火墙:systemctl disable firewalld
3.3 关闭 selinux
3.3.1 selinux 文件路径:/etc/selinux/config
3.3.2 编辑config文件,vim /etc/selinux/config 。将SELINUX=enforcing修改为SELINUX=disable。重启后生效。
# 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=enforcing
# 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
四、测试web服务安装、启动是否成功
五、登录mariadb 数据库
5.1 设置数据库root登录密码:mysqladmin -u root password "rty@123"
5.2 登录数据库:mysql -u root -p,按提示输入密码
六、测试服务器是否支持 PHP
6.1 Web服务的根目录:cd /var/www/html/
6.2 新建info.php文件:vim info.php
输入以下代码:
<?
echo phpinfo();
?>
6.3 测试PHP是否支持,浏览器输入:IP/info.php
完了。