报此错,是虚拟主机没配置好;修改虚拟主机配置文件中到第二个AllowOverride中到none改为all
报此错,开重写功能;命令:a2enmod rewrite;然后重启服务器
1.建立apache虚拟主机
/etc/apache2/sites-available
cp default www.test.com
cp default test.com
mkdir /var/www/test.com
a2ensite www.test.com
a2ensite test.com
(ln -s etc/apache2/sites-available/www.test.com /etc/apache2/sites-enabled/ )
/etc/init.d/apache2 restart
2.建立nginx虚拟主机
cd /etc/nginx/sites-available
cp default www.test.com
ln -s /etc/nginx/sites-available/www.test.com /etc/nginx/sites-enabled/www.test.com
sudo /etc/init.d/nginx restart
3.数据库
通过权限->添加新用户-> 创建与用户同名的数据库并授予所有权限
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName www.test.com
DocumentRoot /var/www/test
<Directory /> w
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/test/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.www.test.com.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.www.test.com.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>