Apache2.4.6 配置虚拟主机

1.编辑hosts文件

vim /etc/hosts

2.设置(*为网址):

127.0.0.1 ***.com
120.78.202.104 ***.com

3.确保 下面两项开启

Include conf.modules.d/*.conf

IncludeOptional conf.d/*.conf

4.在 conf.d 里面新建vhost.conf 文件

vim /etc/httpd/conf.d/vhost.conf

5.新增虚拟主机设置

<VirtualHost *:80>
        ServerName ****.com
        DocumentRoot "/var/www/17lottery/public"
        DirectoryIndex index.php index.html
        <Directory "/var/www/17lottery/public">
                Options -Indexes +FollowSymlinks
                AllowOverride All
                Require all granted
        </Directory>
        ErrorLog "logs/lot_9xzb-error_log"
        CustomLog "logs/lot_9xzb-access_log" common
</VirtualHost>

6.重启Apache 

以下是在Apache 2.4.6上部署SSL证书的步骤: 1. 获取SSL证书文件 你可以从证书颁发机构(CA)或自行签名的证书中获取SSL证书文件。通常,这个文件包括以下内容: - 证书文件(.crt) - 私钥文件(.key) - 中间证书文件(.ca-bundle) 确保你拥有这些文件,并将它们保存在一个安全的地方。 2. 配置Apache配置文件中启用SSL模块。在CentOS中,配置文件通常位于`/etc/httpd/conf/httpd.conf`或`/etc/httpd/conf.d/ssl.conf`。在Ubuntu中,通常位于`/etc/apache2/sites-available/default-ssl.conf`。 在配置文件中找到以下语句,并启用它们: ``` LoadModule ssl_module modules/mod_ssl.so ``` 3. 配置虚拟主机配置文件中找到要启用SSL的虚拟主机,并添加以下配置: ``` <VirtualHost *:443> ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/html SSLEngine on SSLCertificateFile /path/to/cert.pem SSLCertificateKeyFile /path/to/key.pem SSLCACertificateFile /path/to/ca-bundle.pem </VirtualHost> ``` 在这个示例中,`example.com`和`www.example.com`是你的网站域名,`/var/www/html`是你的网站根目录。`/path/to/cert.pem`是你的证书文件,`/path/to/key.pem`是你的私钥文件,`/path/to/ca-bundle.pem`是你的中间证书文件。 4. 重启Apache 完成上述步骤后,保存配置文件,并重新启动Apache: ``` sudo systemctl restart httpd.service # CentOS sudo systemctl restart apache2.service # Ubuntu ``` 现在你的网站应该已经启用了SSL证书。你可以在浏览器中输入你的网站地址来验证证书是否已正确部署。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值