apache
来源:互联网 发布:淘宝水星小飞船证吗 编辑:程序博客网 时间:2024/06/06 08:43
1:配置yum源,下载并安装httpd
[root@localhost ~]# vim /etc/yum.repos.d/rhel_dvd.repo [root@localhost ~]# yum clean allLoaded plugins: langpacksCleaning repos: rhel_dvdCleaning up everything[root@localhost ~]# [root@localhost ~]# hostnamectl set-hostname apache-server.example.com[root@localhost ~]# hostnameapache-server.example.com[root@localhost ~]# yum install httpd -yLoaded plugins: langpacksrhel_dvd | 4.1 kB 00:00 (1/2): rhel_dvd/group_gz | 134 kB 00:00 (2/2): rhel_dvd/primary_db | 3.4 MB 00:00 Resolving Dependencies--> Running transaction check---> Package httpd.x86_64 0:2.4.6-17.el7 will be installed--> Processing Dependency: httpd-tools = 2.4.6-17.el7 for package: httpd-2.4.6-17.el7.x86_64--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-17.el7.x86_64--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64--> Running transaction check---> Package apr.x86_64 0:1.4.8-3.el7 will be installed---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed---> Package httpd-tools.x86_64 0:2.4.6-17.el7 will be installed---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================ Package Arch Version Repository Size================================================================================Installing: httpd x86_64 2.4.6-17.el7 rhel_dvd 1.2 MInstalling for dependencies: apr x86_64 1.4.8-3.el7 rhel_dvd 103 k apr-util x86_64 1.5.2-6.el7 rhel_dvd 92 k httpd-tools x86_64 2.4.6-17.el7 rhel_dvd 77 k mailcap noarch 2.1.41-2.el7 rhel_dvd 31 kTransaction Summary================================================================================Install 1 Package (+4 Dependent packages)Total download size: 1.5 MInstalled size: 4.3 MDownloading packages:(1/5): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00 (2/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00 (3/5): httpd-tools-2.4.6-17.el7.x86_64.rpm | 77 kB 00:00 (4/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00 (5/5): httpd-2.4.6-17.el7.x86_64.rpm | 1.2 MB 00:00 --------------------------------------------------------------------------------Total 11 MB/s | 1.5 MB 00:00 Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : apr-1.4.8-3.el7.x86_64 1/5 Installing : apr-util-1.5.2-6.el7.x86_64 2/5 Installing : httpd-tools-2.4.6-17.el7.x86_64 3/5 Installing : mailcap-2.1.41-2.el7.noarch 4/5 Installing : httpd-2.4.6-17.el7.x86_64 5/5 Verifying : mailcap-2.1.41-2.el7.noarch 1/5 Verifying : httpd-tools-2.4.6-17.el7.x86_64 2/5 Verifying : apr-1.4.8-3.el7.x86_64 3/5 Verifying : apr-util-1.5.2-6.el7.x86_64 4/5 Verifying : httpd-2.4.6-17.el7.x86_64 5/5 Installed: httpd.x86_64 0:2.4.6-17.el7 Dependency Installed: apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-17.el7 mailcap.noarch 0:2.1.41-2.el7 Complete![root@localhost ~]# systemctl start httpd[root@localhost ~]# systemctl enable httpdln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'[root@localhost html]# systemctl stop firewalld.service
查看网页
[root@localhost html]# vim /etc/httpd/conf/httpd.conf
查看配置文件
[root@localhost ~]# cd /var/www/html[root@localhost html]# ls[root@localhost html]# vim index.html[root@localhost html]# systemctl restart httpd
编辑文件,可以在网页上显示
测试
2:改变index.html为westos
[root@localhost html]# vim /etc/httpd/conf/httpd.conf
[root@localhost html]# vim westos
[root@localhost html]# systemctl restart httpd
清理上次实验痕迹
[root@localhost html]# rm -fr westos[root@localhost html]# lsindex.html[root@localhost html]# vim /etc/httpd/conf/httpd.conf
[root@localhost html]# systemctl restart httpd
3:改变发布目录
[root@localhost html]# mkdir /westos/html -p ##建立发布目录[root@localhost html]# vim /westos/html/index.html ##编辑发布目录内容
[root@localhost html]# vim /etc/httpd/conf/httpd.conf ##修改配置中发布目录指向[root@localhost html]# systemctl restart httpd
[root@apache-server ~]# ls -lZd /var/www/html ##查看原来发布目录标签drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www/html[root@apache-server html]# ls -lZd /westos/ ##查看westos标签drwxr-xr-x. root root system_u:object_r:default_t:s0 /westos/[root@apache-server html]# semanage fcontext -a -t httpd_sys_content_t '/westos(/.*)?' ##修改westos标签[root@apache-server html]# restorecon -FvvR /westos/ #刷新restorecon reset /westos context system_u:object_r:default_t:s0->system_u:object_r:httpd_sys_content_t:s0restorecon reset /westos/html context system_u:object_r:default_t:s0->system_u:object_r:httpd_sys_content_t:s0restorecon reset /westos/html/index.html context system_u:object_r:default_t:s0->system_u:object_r:httpd_sys_content_t:s0
测试
[root@apache-server html]# vim /etc/httpd/conf/httpd.conf [root@apache-server html]# systemctl restart httpd
4:设置访问黑白名单
[root@apache-server html]# vim /etc/httpd/conf/httpd.conf [root@apache-server html]# systemctl restart httpd
测试
5:设置密码
[root@apache-server html]# cd /etc/httpd/conf
[root@apache-server conf]# ls
httpd.conf magic
[root@apache-server conf]# htpasswd -cm authfile admin ##创建密码用户(第一次加c)
New password:
Re-type new password:
Adding password for user admin
[root@apache-server conf]# cat authfile
admin:
[root@apache-server conf]# htpasswd -m authfile admin1
New password:
Re-type new password:
Adding password for user admin1
[root@apache-server conf]# cat authfile[root@apache-server html]# cd /etc/httpd/conf
[root@apache-server conf]# ls
httpd.conf magic
[root@apache-server conf]# htpasswd -cm authfile admin ##创建密码用户(第一次加c)
New password:
Re-type new password:
Adding password for user admin
[root@apache-server conf]# cat authfile
admin:apr1
[root@apache-server conf]# htpasswd -m authfile admin1
New password:
Re-type new password:
Adding password for user admin1
[root@apache-server conf]# cat authfilein:
[root@apache-server conf]# vim /etc/httpd/conf/httpd.conf
[root@apache-server conf]# systemctl restart httpd
6:多域名解析
建立文件
[root@apache-server conf]# mkdir /var/www/westos/news.westos.com -p[root@apache-server conf]# mkdir /var/www/westos/gongyi.westos.com -p
[root@apache-server conf]# vim /var/www/westos/news.westos.com/index.html
[root@apache-server conf]# vim /var/www/westos/gongyi.westos.com/index.html
[root@apache-server conf]# cd /etc/httpd/conf.d/[root@apache-server conf.d]# lsautoindex.conf README userdir.conf welcome.conf
[root@apache-server conf.d]# vim default.conf ##编辑www配置文件
[root@apache-server conf.d]# vim news.conf ##编辑news配置文件
[root@apache-server conf.d]# cp news.conf gongyi.conf ##编辑gongyi配置文件
[root@apache-server conf.d]# systemctl restart httpd
测试
[root@foundation11 ~]# ping www.westos.comPING www.westos.com (172.25.254.111) 56(84) bytes of data.64 bytes from www.westos.com (172.25.254.111): icmp_seq=1 ttl=64 time=0.143 ms64 bytes from www.westos.com (172.25.254.111): icmp_seq=2 ttl=64 time=0.154 ms^C--- www.westos.com ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1000msrtt min/avg/max/mdev = 0.143/0.148/0.154/0.013 ms[root@foundation11 ~]# ping news.westos.comPING www.westos.com (172.25.254.111) 56(84) bytes of data.64 bytes from www.westos.com (172.25.254.111): icmp_seq=1 ttl=64 time=0.196 ms64 bytes from www.westos.com (172.25.254.111): icmp_seq=2 ttl=64 time=0.294 ms^C--- www.westos.com ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 999msrtt min/avg/max/mdev = 0.196/0.245/0.294/0.049 ms[root@foundation11 ~]# ping gongyi.westos.comPING www.westos.com (172.25.254.111) 56(84) bytes of data.64 bytes from www.westos.com (172.25.254.111): icmp_seq=1 ttl=64 time=0.132 ms64 bytes from www.westos.com (172.25.254.111): icmp_seq=2 ttl=64 time=0.170 ms^C--- www.westos.com ping statistics ---
- Apache
- APACHE
- Apache
- Apache
- apache
- Apache
- apache
- Apache
- Apache
- Apache
- Apache
- apache
- Apache
- apache
- apache
- apache
- Apache
- Apache
- python爬取csdn用户头像
- NVIDIA Jetson TX1 系列开发教程之十:V4L2+OpenCV2.4.13实现预览、拍照功能
- 目标检测--Enhancement of SSD by concatenating feature maps for object detection
- 【偶现】【reboot】【二】java.util.concurrent.TimeoutException
- JAVA连接Redis错误提示(二)
- apache
- Android Launcher启动应用程序流程源码解析
- [RK3288][Android6.0] Fuse将被SDCardFS替换
- bootstrap-table和layer
- Ubuntu17.04 编译Elastic fusion 出现CUDA8.0与GCC版本问题
- 【poj 2406】Power Strings
- Linux下容易被忽视的那些命令用法
- sparse文件简介
- Android N MediaPlayer(一) : MediaMetadataRetriever分析