httpd配置和https配置

httpd配置和https配置

httpd配置和https配置

安装httpd服务

[root@localhost ~]# yum -y install httpd
[root@localhost ~]# systemctl start httpd

查看是否有80端口

[root@localhost ~]# ss -antlp
State    Recv-Q   Send-Q     Local Address:Port       Peer Address:Port   Process
LISTEN   0        128              0.0.0.0:111             0.0.0.0:*       users:(("rpcbind",pid=1000,fd=4),("systemd",pid=1,fd=331))
LISTEN   0        32         192.168.122.1:53              0.0.0.0:*       users:(("dnsmasq",pid=2087,fd=6))
LISTEN   0        128              0.0.0.0:22              0.0.0.0:*       users:(("sshd",pid=1268,fd=5))
LISTEN   0        5              127.0.0.1:631             0.0.0.0:*       users:(("cupsd",pid=1275,fd=10))
LISTEN   0        128            127.0.0.1:6010            0.0.0.0:*       users:(("sshd",pid=2389,fd=15))
LISTEN   0        128                 [::]:111                [::]:*       users:(("rpcbind",pid=1000,fd=6),("systemd",pid=1,fd=333))
LISTEN   0        128                    *:80                    *:*       users:(("httpd",pid=37042,fd=4),("httpd",pid=37041,fd=4),("httpd",pid=37040,fd=4),("httpd",pid=37038,fd=4))

在系统查找主机带的模板

[root@localhost ~]# find / -name *vhosts.conf
/usr/share/doc/httpd/httpd-vhosts.conf
[root@localhost ~]# cat /usr/share/doc/httpd/httpd-vhosts.conf
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/var/www/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"
    CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/var/www/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "/var/log/httpd/dummy-host2.example.com-error_log"
    CustomLog "/var/log/httpd/dummy-host2.example.com-access_log" common
</VirtualHost>

cp一份到/etc/httpd/conf.d/的辅助配置文件中

[root@localhost ~]# cd /etc/httpd/conf.d/
[root@localhost conf.d]# ls
autoindex.conf  README  userdir.conf  welcome.conf
[root@localhost conf.d]# cp  /usr/share/doc/httpd/httpd-vhosts.conf /etc/httpd/conf.d/
[root@localhost conf.d]# ls
autoindex.conf  httpd-vhosts.conf  README  userdir.conf  welcome.conf

创建网页目录并修改属主属组

[root@localhost conf.d]# cd /var/www/html/
[root@localhost html]# mkdir haha  hehe
[root@localhost html]# echo hahahahah > haha/index.html
[root@localhost html]# echo hello world > hehe/index.html
[root@localhost html]# chown -R apache.apache haha
[roo
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值