我正在运行Ubuntu。 我的Apache2默认文件如下所示:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None 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.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 None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
我有这个名为Index.php的文件在/ var / www /
<? phpinfo(); ?>
当我在浏览器中访问http:// localhost /时,出现404 Not Found错误:
在此服务器上找不到请求的URL /。 本地端口80上的Apache / 2.2.16(Ubuntu)服务器
我究竟做错了什么? 当我第一次设置LAMP时,这实际上工作,但它现在不工作。
看一看/ etc / apache2 / sites-enabled。 看来我的升级到10.10已经从该目录中删除了符号链接。 尝试将symlinking默认设置为/ etc / apache2 / sites-available / default
sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/default
查看错误日志(tail /var/log/apache2/error.log)以查找Apache尝试查找的确切路径。
与我完全一样的问题。
以下为我工作:
正如Andreas Jansson所说,符号链接默认为:
sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/default
并重新启动apache2:
sudo /etc/init.d/apache2 restart
然后它工作:
http://localhost/
使用url localhost / info.php。 文件info.php必须包含<?php phpinfo(); ?>
<?php phpinfo(); ?>
你有PHP模块安装和启用? 因为,通常情况下,它会在服务器签名中提及,但是您的服务器不会。 这也可以解释为什么服务器不能识别index.php
就是你的意思。
尝试
sudo a2enmod php5