10章节 部署网站Nginx和Apache

时间秒杀一切 提交于 2020-07-28 08:57:37

Windows用的是IIS,Linux部署网站用Nginx和Apache

第1步:把光盘设备中的系统镜像挂载到/media/cdrom目录。

[root@linuxprobe ~]# mkdir -p /media/cdrom
[root@linuxprobe ~]# mount /dev/cdrom /media/cdrom
mount: /dev/sr0 is write-protected, mounting read-only

第2步:使用Vim文本编辑器创建Yum仓库的配置文件,下述命令中具体参数的含义可参考4.1.4小节

[root@linuxprobe ~]# vim /etc/yum.repos.d/rhel7.repo
[rhel7]
name=rhel7
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0

第3步:动手安装Apache服务程序。注意,使用yum命令进行安装时,跟在命令后面的Apache服务的软件包名称为httpd。

[root@linuxprobe ~]# yum install httpd
Loaded plugins: langpacks, product-id, subscription-manager
………………省略部分输出信息………………

10.3 SELinux安全子系统

SELinux服务有三种配置模式,具体如下。

enforcing:强制启用安全策略模式,将拦截服务的不合法请求。

permissive:遇到服务越权访问时,只发出警告而不强制拦截。

disabled:对于越权的行为不警告也不拦截。

[root@linuxprobe ~]# 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=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected. 
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

可以使用getenforce命令获得当前SELinux服务的运行模式:

[root@linuxprobe ~]# getenforce 
Enforcing

为了确认图10-6所示的结果确实是因为SELinux而导致的,可以用setenforce [0|1]命令修改SELinux当前的运行模式(0为禁用,1为启用)。注意,这种修改只是临时的,在系统重启后就会失效:

[root@linuxprobe ~]# setenforce 0
[root@linuxprobe ~]# getenforce
Permissive

再次刷新网页,就会看到正常的网页内容了,如图10-7所示。可见,问题确实是出在了SELinux服务上面。

[root@linuxprobe wwwroot]# firefox

 

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!