Ubuntu 16.04.5 LTS
先Terminal 下lsb_release -a,
apache2 -vapache2 2.4.18 了,已经不能找到httpd那个配置文件方法了,apache2 2.4.18安装在 /etc/apache2/下 ,下面有配置文件和几个设置虚拟主机的,先在sites-available 下新建一个test.conf文件吧,把那个000-default 那个里面的内容copy过来,修改成
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName test.com
DocumentRoot /var/www/html/test
<Directory />
Options FollowSymLinks
DirectoryIndex index.php index.html index.htm
AllowOverride All
</Directory>
<Directory /var/www/html/test>
Options Indexes FollowSymLinks MultiViews
# Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
激活 站点(启用配置) sudo a2ensite test ->site-enabled 里去, 也可以用 软链接
sudo ln -s sites-ava... -------> sites-enabled ,
这就不用 去 apache2.conf 改配置了,
在 service apache2 reload 重启,
红色 部分 是关键,绿色 最重要 !~