以下是配置 CentOS Apache2 服務器的步驟:
sudo yum update -y
。sudo yum install httpd -y
。sudo systemctl start httpd
。sudo systemctl enable httpd
。sudo firewall-cmd --permanent --add-service=http
,sudo firewall-cmd --permanent --add-service=https
,sudo firewall-cmd --reload
。/etc/httpd/conf.d/
目錄下創建如mydomain.conf
的文件。<VirtualHost *:80>
標簽內設置ServerName
、DocumentRoot
等。sudo mkdir -p /var/www/yourdomain.com
,sudo chown -R apache:apache /var/www/yourdomain.com
。sudo systemctl reload httpd
。sudo yum install certbot python2 - certbot - apache - y
。sudo certbot --apache -d yourdomain.com
。以上步驟可根據實際需求調整,配置過程中可查看/var/log/httpd/
目錄下的日志文件排查問題。