在CentOS 7中部署web服务器

目录

一、安装web服务器相关软件

二、启动和关闭服务

三、关闭防火墙

四、测试web服务安装、启动是否成功

五、登录mariadb 数据库

六、测试服务器是否支持 PHP


一、安装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

完了。


#生如夏花之绚烂,死如秋叶之静美。#

  • 23
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值