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