我全新安装了Ubuntu 10.10(Maverick Meerkat),我想让 PHP 工作。我试过
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
但是当我导航到http://本地主机/我看到的只是 Firefox 错误页面,显示“无法连接”。
此外,当我尝试http://localhost/test.php,浏览器不会执行 PHP 文件,而是询问我是否要下载该文件。
以下是 error.log 文件的内容:
[Thu May 19 12:04:49 2011] [notice] Apache/2.2.16 (Ubuntu) configured -- resuming normal operations
[Thu May 19 12:05:01 2011] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico
[Thu May 19 12:05:04 2011] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico
[Thu May 19 12:12:42 2011] [error] [client 127.0.0.1] File does not exist: /var/www/asd
[Thu May 19 12:13:32 2011] [notice] Graceful restart requested, doing restart
[Thu May 19 12:13:32 2011] [notice] Apache/2.2.16 (Ubuntu) configured -- resuming normal operations
[Thu May 19 12:14:11 2011] [notice] SIGHUP received. Attempting to restart
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/interbase.ini on line 1 in Unknown on line 0
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/lasso.ini on line 1 in Unknown on line 0
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/ming.ini on line 1 in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - idn_to_ascii in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - idn_to_utf8 in Unknown on line 0
PHP Warning: intl: Unable to register functions, unable to load in Unknown on line 0
[Thu May 19 12:14:11 2011] [notice] seg fault or similar nasty error detected in the parent process
答案1
答案2
列出的步骤http://netbeans.org/kb/docs/php/configure-php-environment-ubuntu.html正是我所需要的。我全新安装了 Ubuntu,运行
sudo taskel 安装 lamp-server
然后按照故障排除部分中的步骤进行操作,即
apt-get --purge 删除 php5-common apt-get 安装 php5 phpmyadmin
答案3
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo apt-get install sendmail
sudo /etc/init.d/apache2 restart
答案4
检查您的 PHP 5 模块是否在 Apache 2 中启用(/etc/apache2/mods-enabled)。如果您在那里找不到 @php5* 符号链接,您可以尝试:
sudo a2enmod php5
sudo /etc/init.d/apache2 restart
并确保 Apache 2 监听端口 80。