Ubuntu Apache配置网站

发布于 20 天前  110 次阅读


/etc/apache2/sites-available 下新建一个文件,命名为 [可自己设置].conf

输入以下内容,可使用Vim

<VirtualHost *:80>
    ServerAdmin [邮箱]
    ServerName [网站网址]
    ServerAlias [网站域名]
    DocumentRoot [路径]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# 以下为设置https,如不需要,可不复制
<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
        ServerAdmin [邮箱]
        DocumentRoot [路径]
        ServerName [网站网址]
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        SSLCertificateFile [xxx.crt]
        SSLCertificateKeyFile [xxx.key]
        SSLCertificateChainFile [root_bundle.crt]
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        </Directory>
    </VirtualHost>
</IfModule>