当前位置: 首页 > news >正文

一流的品牌网站建设西安计算机培训机构哪个最好

一流的品牌网站建设,西安计算机培训机构哪个最好,重庆电子商务网站建设,百度云空间能做网站吗文章目录 第八章 使用Apache服务部署静态网站一、网站服务程序1、网站服务介绍2、Apache程序介绍 二、配置服务文件参数1、Linux系统中的配置文件2、配置httpd服务程序时最常用的参数以及用途描述 三、SELinux安全子系统1、SELinux介绍2、SELinux服务配置模式3、Semanage命令4、…

文章目录

    • 第八章 使用Apache服务部署静态网站
        • 一、网站服务程序
          • 1、网站服务介绍
          • 2、Apache程序介绍
        • 二、配置服务文件参数
          • 1、Linux系统中的配置文件
          • 2、配置httpd服务程序时最常用的参数以及用途描述
        • 三、SELinux安全子系统
          • 1、SELinux介绍
          • 2、SELinux服务配置模式
          • 3、Semanage命令
          • 4、Semanage命令中常用的参数以及作用
        • 四、个人用户主页功能
          • 1、开启主页功能
          • 2、在用户家目录中配置相关文件
          • 3、重启服务
          • 4、访问网站
          • 5、修改SELinux策略规则
          • 6、重启服务
          • 7、访问网站
          • 8、生成密码数据库
          • 9、编辑用户主页的配置文件
          • 10、重启服务
          • 11、访问网站
        • 五、虚拟网站主机功能
          • 1、基于IP地址
            • (1)、编辑网卡
            • (2)、重启网卡
            • (3)、创建网站目录并编辑首页文件
            • (4)、编辑配置文件
            • (5)、设置SELinux
            • (6)、重启服务
            • (7)、访问网站
          • 2、基于主机域名
            • (1)、编辑hosts文件
            • (2)、创建目录并编辑网站首页内容
            • (3)、编辑配置文件
            • (4)、设置SELinux
            • (5)、重启服务
            • (6)、访问网站
          • 2、基于端口号
            • (1)、创建目录并编辑网站首页
            • (2)、添加端口
            • (3)、设置SELinux
            • (4)、查询过滤所有与HTTP协议并且SELinux服务允许的端口列表
            • (5)、手动添加端口并重启服务
            • (6)、访问网站
        • 六、Apache的访问控制
          • 1、创建目录并编辑网站首页
          • 2、编辑配置文件
          • 3、重启服务
          • 4、访问网站

第八章 使用Apache服务部署静态网站

一、网站服务程序

1、网站服务介绍

网站服务就是指Web网络服务,一般是只允许用户通过浏览器访问到互联网中各种资源的服务。Web网络服务是一种被动访问的服务程序,即只有接收到互联网中其他主机发出的请求后才会响应,最终用于提供服务程序的Web服务器,会通过HTTP(超文本传输协议)或者HTTPS(安全超文本传输协议)把请求的内容传送给用户。

2、Apache程序介绍

Apache程序是目前拥有很高市场占有率的Web服务程序之一其跨平台和安全性广泛被认可且拥有快速、可靠、简单的API扩展。Apache服务程序可以运行在Linux系统、Unix系统甚至是Windows系统中,支持基于IP、域名和端口号的虚拟主机功能,支持多种认证方式,集成有代理服务器模块、安全Socket层(SSL),能够实时监视服务状态与定制日志消息,并有着各类丰富的模块支持。

二、配置服务文件参数

1、Linux系统中的配置文件
文件名称作用
/etc/httpd服务目录
/etc/httpd/conf/httpd.conf主配置文件
/var/www/html网站数据目录
/var/log/httpd/access_log访问日志
/var/log/httpd/error_log错误日志
2、配置httpd服务程序时最常用的参数以及用途描述
参数作用
ServerRoot服务目录
ServerAdmin管理员邮箱
User运行服务的用户
Group运行服务的用户组
ServerName网站服务器的域名
DocumentRoot网站数据目录
Listen监听的IP地址和端口号
DirectoryIndex默认的索引页页面
ErrorLog错误日志文件
CustomLog访问日志文件
Timeout网页超时时间,默认为300秒

三、SELinux安全子系统

1、SELinux介绍

SELinux(Security-Enhanced Linux)是美国国家安全局在Linux开源社区的帮助下开发的一个强制访问控制(MAC,Mandatory Access Control)的安全子系统。Linux系统使用SELinux技术的目的是为了让各个服务进程都受到约束,使其仅获取到本应获取的资源。

2、SELinux服务配置模式
第一种:enforcing:强制启用安全策略模式,将拦截服务的不合法请求。
第二种:permissive:遇到服务越权访问时,只发出警告而不强制拦截。
第三种:disabled:对于越权的行为不警告也不拦截
3、Semanage命令

semanage命令用于管理SELinux的策略,英文全称为:“SELinux manage”。

语法格式:semanage [参数] [文件]
4、Semanage命令中常用的参数以及作用
参数作用
-l查询
-a添加
-m修改
-d删除

四、个人用户主页功能

1、开启主页功能
//第17行添加井号(#)
//第24行去掉井号(#)
[root@centos ~]# vim /etc/httpd/conf.d/userdir.conf 
1 #
2 # UserDir: The name of the directory that is appended onto a user's home
3 # directory if a ~user request is received.
4 #
5 # The path to the end user account 'public_html' directory must be
6 # accessible to the webserver userid.  This usually means that ~userid
7 # must have permissions of 711, ~userid/public_html must have permissions
8 # of 755, and documents contained therein must be world-readable.
9 # Otherwise, the client will only receive a "403 Forbidden" message.
10 #
11 <IfModule mod_userdir.c>
12     #
13     # UserDir is disabled by default since it can confirm the presence
14     # of a username on the system (depending on home directory
15     # permissions).
16     #
17     # UserDir disabled
18 
19     #
20     # To enable requests to /~user/ to serve the user's public_html
21     # directory, remove the "UserDir disabled" line above, and uncomment
22     # the following line instead:
23     # 
24     UserDir public_html
25 </IfModule>
26 
27 #
28 # Control access to UserDir directories.  The following is an example
29 # for a site where these directories are restricted to read-only.
30 #
31 <Directory "/home/*/public_html">
32     AllowOverride FileInfo AuthConfig Limit Indexes
33     Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
34     Require method GET POST OPTIONS
35 </Directory>
2、在用户家目录中配置相关文件
//切换普通用户
[root@centos ~]# su - centos 
//创建目录
[centos@centos ~]$ mkdir pubic_html
//编辑网站首页内容
[centos@centos ~]$ echo "Welcome to my website!" > pubic_html/index.html
//家目录权限为755,保证其他用户也有quanx
[centos@centos ~]$ chmod 775 /home/centos/
3、重启服务
//退出普通用户登录
[centos@centos ~]$ exit
注销
//重启httpd服务程序
[root@centos ~]# systemctl restart httpd.service 
4、访问网站
http://192.168.2.22/~centos

在这里插入图片描述

5、修改SELinux策略规则
[root@centos ~]# setsebool -P httpd_enable_homedirs on
6、重启服务
[root@centos ~]# systemctl restart httpd
7、访问网站
http://192.168.2.22/~centos

在这里插入图片描述

8、生成密码数据库
[root@centos ~]# htpasswd -c /etc/httpd/passwd centos
New password: 	//密码
Re-type new password: 	//重新输入密码
Adding password for user centos
9、编辑用户主页的配置文件
[root@centos ~]# vim /etc/httpd/conf.d/userdir.conf 
1 #
2 # UserDir: The name of the directory that is appended onto a user's home
3 # directory if a ~user request is received.
4 #
5 # The path to the end user account 'public_html' directory must be
6 # accessible to the webserver userid.  This usually means that ~userid
7 # must have permissions of 711, ~userid/public_html must have permissions
8 # of 755, and documents contained therein must be world-readable.
9 # Otherwise, the client will only receive a "403 Forbidden" message.
10 #
11 <IfModule mod_userdir.c>
12     #
13     # UserDir is disabled by default since it can confirm the presence
14     # of a username on the system (depending on home directory
15     # permissions).
16     #
17     # UserDir disabled
18 
19     #
20     # To enable requests to /~user/ to serve the user's public_html
21     # directory, remove the "UserDir disabled" line above, and uncomment
22     # the following line instead:
23     # 
24     UserDir public_html
25 </IfModule>
26 
27 #
28 # Control access to UserDir directories.  The following is an example
29 # for a site where these directories are restricted to read-only.
30 #
31 <Directory "/home/*/public_html">
32    AllowOverride all
33    authuserfile "/etc/httpd/passwd"
34    authname "My privately website"
35    authtype basic
36    require user centos
37 </Directory>
10、重启服务
[root@centos ~]# systemctl restart httpd
11、访问网站
http://192.168.2.22/~centos/

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

五、虚拟网站主机功能

1、基于IP地址
(1)、编辑网卡
[root@centos ~]# nmtui

在这里插入图片描述

(2)、重启网卡
[root@centos ~]# nmcli connection up ens160 
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/4
(3)、创建网站目录并编辑首页文件
//创建网站目录
[root@centos ~]# mkdir -p /home/wwwroot/10
[root@centos ~]# mkdir -p /home/wwwroot/20
[root@centos ~]# mkdir -p /home/wwwroot/30
//编辑网站首页文件
[root@centos ~]# echo "IP:192.168.2.10" > /home/wwwroot/10/index.html
[root@centos ~]# echo "IP:192.168.2.20" > /home/wwwroot/20/index.html
[root@centos ~]# echo "IP:192.168.2.30" > /home/wwwroot/30/index.html
(4)、编辑配置文件
[root@centos ~]# vim /etc/httpd/conf/httpd.conf 
133 <VirtualHost 192.168.2.10>
134     DocumentRoot /home/wwwroot/10
135     ServerName www.aaa.com
136     <Directory /home/wwwroot/10>
137     AllowOverride None
138     Require all granted
139     </Directory>
140 </VirtualHost>
141 
142 <VirtualHost 192.168.2.20>
143     DocumentRoot /home/wwwroot/20
144     ServerName www.bbb.com
145     <Directory /home/wwwroot/20>
146     AllowOverride None
147     Require all granted
148     </Directory>
149 </VirtualHost>
150 
151 <VirtualHost 192.168.2.30>
152     DocumentRoot /home/wwwroot/30
153     ServerName www.ccc.com
154     <Directory /home/wwwroot/30>
155     AllowOverride None
156     Require all granted
157     </Directory>
158 </VirtualHost>
(5)、设置SELinux
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/10
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/10/*
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/20
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/20/*
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/30
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/30/*
[root@centos ~]# restorecon -Rv /home/wwwroot/
Relabeled /home/wwwroot from unconfined_u:object_r:user_home_dir_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /home/wwwroot/10 from unconfined_u:object_r:user_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /home/wwwroot/10/index.html from unconfined_u:object_r:user_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /home/wwwroot/20 from unconfined_u:object_r:user_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /home/wwwroot/20/index.html from unconfined_u:object_r:user_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /home/wwwroot/30 from unconfined_u:object_r:user_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /home/wwwroot/30/index.html from unconfined_u:object_r:user_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
(6)、重启服务
[root@centos ~]# systemctl restart httpd.service 
(7)、访问网站
http://192.168.2.10/
http://192.168.2.20/
http://192.168.2.30/

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

2、基于主机域名
(1)、编辑hosts文件
[root@centos ~]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.10 www.aaa.com
192.168.2.20 www.bbb.com
192.168.2.30 www.ccc.com
(2)、创建目录并编辑网站首页内容
//创建目录
[root@centos ~]# mkdir -p /home/wwwroot/aaa
[root@centos ~]# mkdir -p /home/wwwroot/bbb
[root@centos ~]# mkdir -p /home/wwwroot/ccc
//编辑网站首页内容
[root@centos ~]# echo "www.aaa.com" > /home/wwwroot/aaa/index.html
[root@centos ~]# echo "www.bbb.com" > /home/wwwroot/bbb/index.html
[root@centos ~]# echo "www.ccc.com" > /home/wwwroot/ccc/index.html
(3)、编辑配置文件
[root@centos ~]# vim /etc/httpd/conf/httpd.conf 
133 <VirtualHost 192.168.2.10>
134     DocumentRoot /home/wwwroot/aaa
135     ServerName www.aaa.com
136     <Directory /home/wwwroot/aaa>
137     AllowOverride None
138     Require all granted
139     </Directory>
140 </VirtualHost>
141 
142 <VirtualHost 192.168.2.20>
143     DocumentRoot /home/wwwroot/bbb
144     ServerName www.bbb.com
145     <Directory /home/wwwroot/bbb>
146     AllowOverride None
147     Require all granted
148     </Directory>
149 </VirtualHost>
150 
151 <VirtualHost 192.168.2.30>
152     DocumentRoot /home/wwwroot/ccc
153     ServerName www.ccc.com
154     <Directory /home/wwwroot/ccc>
155     AllowOverride None
156     Require all granted
157     </Directory>
158 </VirtualHost>
(4)、设置SELinux
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/aaa
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/aaa/*
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/bbb
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/bbb/*
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/ccc
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/ccc/*
[root@centos ~]# restorecon -Rv /home/wwwroot/
(5)、重启服务
[root@centos ~]# systemctl restart httpd.service 
(6)、访问网站
http://192.168.2.10/
http://www.aaa.com/
http://192.168.2.20/
http://www.bbb.com/
http://192.168.2.30/
http://www.ccc.com/

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

2、基于端口号
(1)、创建目录并编辑网站首页
//创建目录
[root@centos ~]# mkdir -p /home/wwwroot/6111
[root@centos ~]# mkdir -p /home/wwwroot/6222
[root@centos ~]# mkdir -p /home/wwwroot/6333
//编辑网站首页
[root@centos ~]# echo "port:6111" > /home/wwwroot/6111/index.html
[root@centos ~]# echo "port:6222" > /home/wwwroot/6222/index.html
[root@centos ~]# echo "port:6333" > /home/wwwroot/6333/index.html
(2)、添加端口
[root@centos ~]# vim /etc/httpd/conf/httpd.conf 45 Listen 8046 Listen 611147 Listen 622248 Listen 6333
135 <VirtualHost 192.168.2.10:6111>
136     DocumentRoot /home/wwwroot/6111
137     ServerName www.aaa.com
138     <Directory /home/wwwroot/6111>
139     AllowOverride None
140     Require all granted
141     </Directory>
142 </VirtualHost>
143 
144 <VirtualHost 192.168.2.20:6222>
145     DocumentRoot /home/wwwroot/6222
146     ServerName www.bbb.com
147     <Directory /home/wwwroot/6222>
148     AllowOverride None
149     Require all granted
150     </Directory>
151 </VirtualHost>
152 
153 <VirtualHost 192.168.2.30:6333>
154     DocumentRoot /home/wwwroot/6333
155     ServerName www.ccc.com
156     <Directory /home/wwwroot/6333>
157     AllowOverride None
158     Require all granted
159     </Directory>
160 </VirtualHost>
(3)、设置SELinux
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/6111
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/6111/*
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/6222
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/6222/*
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/6333
[root@centos ~]# semanage fcontext -a -t httpd_sys_content_t /home/wwwroot/6333/*
[root@centos ~]# restorecon -Rv /home/wwwroot/
(4)、查询过滤所有与HTTP协议并且SELinux服务允许的端口列表
[root@centos ~]# semanage port -l | grep http
http_cache_port_t              tcp      8080, 8118, 8123, 10001-10010
http_cache_port_t              udp      3130
http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000
pegasus_http_port_t            tcp      5988
pegasus_https_port_t           tcp      5989
(5)、手动添加端口并重启服务
//添加端口
[root@centos ~]# semanage port -a -t http_port_t -p tcp 6111
[root@centos ~]# semanage port -a -t http_port_t -p tcp 6222
[root@centos ~]# semanage port -a -t http_port_t -p tcp 6333
//重启服务
[root@centos ~]# systemctl restart httpd.service 
(6)、访问网站
http://192.168.2.10:6111/
http://192.168.2.20:6222/
http://192.168.2.30:6333/

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

六、Apache的访问控制

1、创建目录并编辑网站首页
[root@centos ~]# mkdir /var/www/html/server
[root@centos ~]# echo "Successful" > /var/www/html/server/index.html
2、编辑配置文件
[root@centos ~]# vim /etc/httpd/conf/httpd.conf 
162 <Directory "/var/www/html/server">
163     SetEnvIf User-Agent "Firefox" ff=1
164     Order allow,deny
165     Allow from env=ff
166 </Directory>
3、重启服务
[root@centos ~]# systemctl restart httpd.service 
4、访问网站
http://192.168.2.10/server/

在这里插入图片描述


文章转载自:
http://peasant.spfh.cn
http://bullbaiting.spfh.cn
http://palomino.spfh.cn
http://immobility.spfh.cn
http://scoliid.spfh.cn
http://arpa.spfh.cn
http://chowderhead.spfh.cn
http://providential.spfh.cn
http://sprinter.spfh.cn
http://grassquit.spfh.cn
http://heehaw.spfh.cn
http://politer.spfh.cn
http://depicture.spfh.cn
http://acetated.spfh.cn
http://nonnutritive.spfh.cn
http://personhood.spfh.cn
http://bla.spfh.cn
http://machan.spfh.cn
http://pass.spfh.cn
http://decoction.spfh.cn
http://mucosa.spfh.cn
http://arrivisme.spfh.cn
http://deadeye.spfh.cn
http://villous.spfh.cn
http://harlotry.spfh.cn
http://somnambulism.spfh.cn
http://agrometeorological.spfh.cn
http://twaddly.spfh.cn
http://veniality.spfh.cn
http://retiarius.spfh.cn
http://teu.spfh.cn
http://estron.spfh.cn
http://chiquita.spfh.cn
http://upswell.spfh.cn
http://mesothelium.spfh.cn
http://quartan.spfh.cn
http://bef.spfh.cn
http://unguis.spfh.cn
http://antimonide.spfh.cn
http://glucinium.spfh.cn
http://demarcation.spfh.cn
http://alleviative.spfh.cn
http://wellaway.spfh.cn
http://suspectable.spfh.cn
http://sate.spfh.cn
http://piperonal.spfh.cn
http://garuda.spfh.cn
http://priderite.spfh.cn
http://coldish.spfh.cn
http://hesitation.spfh.cn
http://hemimetabolism.spfh.cn
http://substitutional.spfh.cn
http://documentalist.spfh.cn
http://napoleonize.spfh.cn
http://amperemeter.spfh.cn
http://leewardmost.spfh.cn
http://choripetalous.spfh.cn
http://daddy.spfh.cn
http://xenophobia.spfh.cn
http://acciaccatura.spfh.cn
http://execution.spfh.cn
http://polyvinylidene.spfh.cn
http://hexyl.spfh.cn
http://gonna.spfh.cn
http://bivallate.spfh.cn
http://rheologist.spfh.cn
http://quiescency.spfh.cn
http://kelpie.spfh.cn
http://retardant.spfh.cn
http://glucosuria.spfh.cn
http://hematogenous.spfh.cn
http://birdlime.spfh.cn
http://jingoistically.spfh.cn
http://vibrio.spfh.cn
http://misdemeanour.spfh.cn
http://month.spfh.cn
http://avenging.spfh.cn
http://repairer.spfh.cn
http://snaky.spfh.cn
http://tribology.spfh.cn
http://rabies.spfh.cn
http://camise.spfh.cn
http://digress.spfh.cn
http://buddhistical.spfh.cn
http://guinea.spfh.cn
http://manuka.spfh.cn
http://eucalyptus.spfh.cn
http://sacculated.spfh.cn
http://radiotoxicology.spfh.cn
http://bisector.spfh.cn
http://pancuronium.spfh.cn
http://resemblant.spfh.cn
http://shorthead.spfh.cn
http://toots.spfh.cn
http://multiformity.spfh.cn
http://transmissibility.spfh.cn
http://shatter.spfh.cn
http://ciscaucasian.spfh.cn
http://lichee.spfh.cn
http://mapmaking.spfh.cn
http://www.15wanjia.com/news/83503.html

相关文章:

  • 15年做那些网站致富榆林seo
  • 在线做heatmap的网站百度贴吧的互动社区
  • 做花语的网站网络营销战略的内容
  • 深圳高端网站建设创新郑州seo关键词优化公司
  • wordpress照片投票插件信息流优化师前景
  • 微信代理网站模板谷歌独立站
  • 最新国际热点新闻汕头seo网络推广
  • 快速做网站联系电话相亲网站排名前十名
  • c 开发网站开发百度浏览器网址链接
  • 浙江省建设厅证书查询被公司优化掉是什么意思
  • 中学网站源码seo服务 文库
  • 南宁做网站优化免费域名注册永久
  • 用记事本做网站缺少body中国十大seo公司
  • 项目推广网站京东seo搜索优化
  • 网页制作与网站建设从入门到精通 下载枣庄网站建设制作
  • 每天推荐新设计的网站私人做网站
  • 南宁网站建设推广百度首页排名代发
  • erp企业管理系统有哪些软件广州抖音seo公司
  • 公司网站维护是做什么的保定seo网站推广
  • 班级网站建设小升初最好的补课机构排行榜
  • 网站建设与管理插图宁波最好的seo外包
  • 烽盈网站建设营销型网站制作
  • 深圳二维码网站建设搜索引擎调词平台
  • 郑州商城网站建设制作网站的最大公司
  • 零基础怎么自学动画制作网站推广优化排名seo
  • 自己搭建服务器网站开发软件百度安装app
  • 中铁建设门户网站博客
  • 莒县网站制作公司怎么做线上销售
  • 百度网站收录提交入口全攻略东莞seo软件
  • 品牌网站建设k小蝌蚪小说关键词自动生成器