分分钟学会httpd服务

简介: 1.安装httpd,并将访问apache服务器的首页修改为hello.html, 且内容为: “My Home Page is hello”

1.安装httpd,并将访问apache服务器的首页修改为hello.html, 且内容为: “My Home Page is hello”

[root@AAA ~]# systemctl stop firewalld.service 
[root@AAA ~]# getenforce 
Enforcing
[root@AAA ~]# setenforce 0
[root@AAA ~]# getenforce 
Permissive
[root@AAA html]# echo 'My Home Page is hello' > home.html
[root@AAA html]# ls
home.html  index.html
<IfModule dir_module>
    #DirectoryIndex index.html
     DirectoryIndex home.html
</IfModule>
[root@AAA html]# curl 192.168.193.129
My Home Page is hello

dbee60130cb346388e488ea7fbf2918f.png

2.虚拟主机:虚拟两台主机ip为100,200, 对应访问目录:/www/ip/100, /www/ip/200并创建首页文件index.html

[root@WHL ~]# nmcli connection modify ens160 +ipv4.addresses 192.168.193.100/24
[root@WHL ~]# nmcli connection modify ens160 +ipv4.addresses 192.168.193.200/24
[root@WHL ~]# nmcli connection up e
e7c753f0-aa71-4ab5-8b54-ace0c085b2b0  ens160                                
[root@WHL ~]# nmcli connection up ens160 
'Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
[root@WHL ~]# mkdir -pv /www/ip{100,200}
mkdir: created directory '/www'
mkdir: created directory '/www/ip100'
mkdir: created directory '/www/ip200'
[root@WHL ~]# echo 'this is 100' > /www/ip
ip100/ ip200/ 
[root@WHL ~]# echo 'this is 100' > /www/ip100/index.html
[root@WHL ~]# echo 'this is 200' > /www/ip200/index.html
[root@WHL ~]# vim /etc/httpd/conf.d/myhost.conf 
<VirtualHost 192.168.193.100:80>
    DocumentRoot "/www/ip100/"
</VirtualHost>
<VirtualHost 192.168.193.200:80>
    DocumentRoot "www/ip200"
</VirtualHost>
<Directory /www/ip>
    AllowOverride None
    Require all granted
</Directory>
[root@WHL ~]# systemctl restart httpd

3.配置不同端口的虚拟主机访问apache服务器

[root@WHL ~]# mkdir -p /www/port/{8000,9000}
[root@WHL ~]# echo "this is page for port 8000" > /www/port/8000/index.html
[root@WHL ~]# echo "this is page for port 9000" > /www/port/9000/index.html
[root@WHL ~]# vim /etc/httpd/conf.d/myhost.conf 
Listen 8000
Listen 9000
<VirtualHost 192.168.193.100:8000>
    DocumentRoot "/www/port/8000"
</VirtualHost>
<VirtualHost 192.168.193.200:9000>
    DocumentRoot "www/port/9000"
</VirtualHost>
<Directory /www/port>
    AllowOverride None
    Require all granted
</ Directory>
[root@WHL ~]# systemctl restart httpd


相关文章
|
应用服务中间件 nginx
Nginx单独配置conf文件
Nginx单独配置conf文件
104 1
|
5月前
|
JSON 前端开发 应用服务中间件
Nginx 核心配置文 nginx.conf介绍
Nginx 核心配置文 nginx.conf介绍
141 0
|
关系型数据库 MySQL 应用服务中间件
在Centos7上将Apache(httpd)切换为Nginx的过程记录
近期要上线几个基于tornado+motor的移动端接口服务,众所周知,Apache和tornado天生八字不合,尤其apache对python3尤为的不友好,tornado和nginx才是木石前盟,另外由于apache目前系统占用确实比较高,不光进程数多,httpd竟然占用了200多M,太庞大,决定换为较轻量级,高并发的nginx。
在Centos7上将Apache(httpd)切换为Nginx的过程记录
|
应用服务中间件 nginx
【Nginx】第七节 模块介绍
【Nginx】第七节 模块介绍
102 0
【Nginx】第七节 模块介绍
|
安全 应用服务中间件 nginx
Nginx - 最小配置
安全服务器是只允许所需数量的服务器。理想情况下,我们将通过单独启用其他功能来基于最小系统构建服务器。进行最少的配置也有助于调试。如果该错误在最小系统中不可用,则分别添加功能,然后继续搜索错误。 这是运行nginx所需的最低配置:
|
移动开发 小程序 安全
Nginx - 最小配置!你值得拥有
安全服务器是只允许所需数量的服务器。理想情况下,我们将通过单独启用其他功能来基于最小系统构建服务器。进行最少的配置也有助于调试。如果该错误在最小系统中不可用,则分别添加功能,然后继续搜索错误。
224 0
Nginx - 最小配置!你值得拥有
|
网络安全
httpd服务的配置
httpd服务的配置
293 0
|
存储 数据挖掘 应用服务中间件
【Nginx】如何按日期分割Nginx日志?看这一篇就够了!!
Nginx是没有以日期格式作为文件名来存储的,也就是说,Nginx不像Tomcat,每天自动生成一个日志文件,所有的日志都是以一个名字来存储,时间久了日志文件会变得很大。这样非常不利于分析。虽然nginx没有这个功能但我们可以写一个小脚本配合计划任务来达到这样的效果。即让Nginx每天产生一个日志文件,方便我们进行后续的数据分析。
381 0
|
测试技术 网络安全 PHP