yum install httpd -y
443为HTTPS服务的默认端口
启用SSL功能,安装mod_ssl.so模块
yum install -y mod_ssl
使用Certbot签发和续费泛域名SSL证书:https://blog.csdn.net/cljdsc/article/details/133461361
vhost的域名配置文件.conf,在目录:/etc/httpd/conf.d
Listen 80
# 指定域名
ServerName www.example.com
# 指定文档根目录
DocumentRoot /var/www/html
# 是否启用访问日志
CustomLog /var/log/httpd/access.log combined
# 指定错误日志路径
ErrorLog /var/log/httpd/error.log
# 配置虚拟主机
ServerAdmin admin@example.com
DocumentRoot /var/www/html/project
# 访问权限
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
# 使用PHP解析器处理.php文件
SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"
# 定义PHP脚本的目录索引
DirectoryIndex index.php index.html
# 自定义错误页面
ErrorDocument 404 /error_404.html
# 设置HTTP头信息
Header set X-Content-Type-Options "nosniff"
Header set X-XSS-Protection "1; mode=block"
DocumentRoot /var/www/html/project
ServerName www.cpayfinance.com
ServerAlias www.cpayfinance.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/cpayfinance.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cpayfinance.com//privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/cpayfinance.com//chain.pem
# 访问权限
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
# 使用PHP解析器处理.php文件
SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"
# 定义PHP脚本的目录索引
DirectoryIndex index.php index.html
# 自定义错误页面
ErrorDocument 404 /error_404.html
# 设置HTTP头信息
Header set X-Content-Type-Options "nosniff"
Header set X-XSS-Protection "1; mode=block"
Listen 80
# 指定域名
ServerName www.cpayfinance.com
# 指定文档根目录
DocumentRoot /var/www/html
# 是否启用访问日志
CustomLog /var/log/httpd/access.log combined
# 指定错误日志路径
ErrorLog /var/log/httpd/error.log
# 配置虚拟主机
ServerAdmin admin@example.com
DocumentRoot /var/www/html/project
# 访问权限
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
# 使用PHP解析器处理.php文件
SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"
# 定义PHP脚本的目录索引
DirectoryIndex index.php index.html
# 自定义错误页面
ErrorDocument 404 /error_404.html
# 设置HTTP头信息
Header set X-Content-Type-Options "nosniff"
Header set X-XSS-Protection "1; mode=block"
DocumentRoot /var/www/html/project
ServerName www.cpayfinance.com
ServerAlias www.cpayfinance.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/cpayfinance.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cpayfinance.com//privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/cpayfinance.com//chain.pem
# 访问权限
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
# 使用PHP解析器处理.php文件
SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"
# 定义PHP脚本的目录索引
DirectoryIndex index.php index.html
# 自定义错误页面
ErrorDocument 404 /error_404.html
# 设置HTTP头信息
Header set X-Content-Type-Options "nosniff"
Header set X-XSS-Protection "1; mode=block"
# apachectl -t
Syntax OK
systemctl restart httpd