目录
1、httpd服务安装
yum -y install httpd #安装命令
systemctl start httpd.service #启动服务命令
systemctl enable httpd.service #开机自动启动
systemctl status httpd.service #查看状态
ps -ef | grep httpd #查看进程是不是存在
netstat -lntp #查看端口是不是正在监听
#配置文件默认路径
vim /etc/httpd/conf/httpd.conf
2、关闭防火墙
systemctl start firewalld #开启防火墙服务
firewall-cmd --zone=public --add-port=80/tcp --permanent #防火墙开启端口访问
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload #重启防火墙生效
firewall-cmd --list-ports #查看所有开启的端口
3、httpd服务启动和停止
#开机启动
systemctl enable httpd.service
#启动
systemctl start httpd.service
#启动
systemctl start httpd.service
#停止
systemctl stop httpd.service
#重启
systemctl restart httpd.service
#开机启动
systemctl enable httpd.service
#开机不启动
systemctl disable httpd.service
#检查httpd状态
systemctl status httpd.service
4、https安装ssl
安装apache和ssl模块
1、安装apache
yum install httpd
2、安装ssl模块
yum install mod_ssl
3、重启apache
service httpd restart
安装完mod_ssl会创建一个默认的SSL证书,路径位于/etc/pki/tls,此时可以立即通过https访问服务器了https://X.X.X.X/
如果不使用默认的证书,也可以使用openssl手动创建证书。
5、虚拟主机vhost.conf
vi /etc/httpd/conf.d/vhost.conf
<VirtualHost 10.4.4.61:80>
DocumentRoot /var/www/html/http/IPv4/61
ServerName 10.4.4.61
<Directory /var/www/html/http/IPv4/61>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 10.4.4.62:80>
DocumentRoot /var/www/html/http/IPv4/62
ServerName 10.4.4.62
<Directory /var/www/html/http/IPv4/62>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 10.4.4.63:80>
DocumentRoot /var/www/html/http/IPv4/63
ServerName 10.4.4.63
<Directory /var/www/html/http/IPv4/63>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 10.4.4.64:80>
DocumentRoot /var/www/html/http/IPv4/64
ServerName 10.4.4.64
<Directory /var/www/html/http/IPv4/64>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 10.4.4.65:80>
DocumentRoot /var/www/html/http/IPv4/65
ServerName 10.4.4.65
<Directory /var/www/html/http/IPv4/65>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost [fc00::4:61]:80>
DocumentRoot /var/www/html/http/IPv6/61
<Directory /var/www/html/http/IPv6/61>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost [fc00::4:62]:80>
DocumentRoot /var/www/html/http/IPv6/62
<Directory /var/www/html/http/IPv6/62>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost [fc00::4:63]:80>
DocumentRoot /var/www/html/http/IPv6/63
<Directory /var/www/html/http/IPv6/63>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost [fc00::4:64]:80>
DocumentRoot /var/www/html/http/IPv6/64
<Directory /var/www/html/http/IPv6/64>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost [fc00::4:65]:80>
DocumentRoot /var/www/html/http/IPv6/65
<Directory /var/www/html/http/IPv6/65>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
6、HTML内容
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Server 61 IPv4</title>
</head>
<body>
<h1>
Server 61 IPv4
</h1>
</body>
</html>
标签:httpd,www,服务,service,AllowOverride,systemctl,Allow,HTTP,搭建
From: https://www.cnblogs.com/LauShineLae/p/17506142.html