项目中apache2的配置和使用--ubuntu
一、安装apache2
sudo apt-get install apache2
二、配置
1、配置静态页面
将前端代码文件夹放到/var/www/html下
2、配置代理
首先建立软链接
ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/proxy.load
ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled/proxy_http.load
其次将test.conf放到sites-available文件夹下,执行命令sudo a2ensite test.conf, systemctl reload apache2
3、开启ssi
首先建立软链接
ln -s /etc/apache2/mods-available/include.load /etc/apache2/mods-enable/include.load
其次,在include.load中添加(也可加到主配置文件中)
<Directory /var/www>
Options Indexes FollowSymLinks Includes
AllowOverride None
Order allow,deny
Allow from all
AddType text/html .shtml .html
AddOutputFilter INCLUDES .shtml .html
</Directory>
重启 systemctl restart apache2或者service apache2 restart
4、访问
打开浏览器,请求地址访问