apache2主设置文件为/etc/apache2/apache2.conf。
通过此文件设置和include其他设置文件。
/etc/apache2/ # |-- apache2.conf # | `-- ports.conf # |-- mods-enabled # | |-- *.load # | `-- *.conf # |-- conf-enabled # | `-- *.conf # `-- sites-enabled # `-- *.conf
将mods-available下端模块 link 到mods-enabled下即可加载该模块。
ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
重启apache2
/etc/init.d/apache2 restart
在sites-available下添加新vhost配置文件,以000-default.conf 为基础修改
cp 000-default.conf new-site.conf
文件内容如下,前四行根据实际情况修改
<VirtualHost *:80> ServerName ServerAlias ServerAdmin webmaster@www.html DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
修改完成后,保存允许如下命令
sudo a2dissite 000-default.conf sudo a2ensite new-site.conf sudo service apache2 restart
编辑hosts文件
sudo vi /etc/hosts
添加虚拟域名
127.0.0.1 www.html
保存关闭。
访问www.html即可看到你打网站。
apache2.conf中如下片段设置是否允许重写url,是否允许外网访问。
<Directory /home/sxm/bigiot/> Options Indexes FollowSymLinks #url重写 AllowOverride All #外部请求 Require all granted </Directory>