3

I have a fresh installation of UbuntuĀ 10.10 (Maverick Meerkat) and I'd like to get PHP to work. I've tried

sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart

but when I navigate to http://localhost/ all I see is the the Firefox error page stating "Unable to connect".

Moreover, when I try http://localhost/test.php, instead of the PHP file being executed, the browser asks if I'd like to download the file.

Here is the error.log file contents:

[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

5 Answers5

9

You can install LAMP running one command:

Install tasksel Install tasksel

Select LAMP Server,

Enter image description here

Follow the installation process.

After the installation is completed, you can test your localhost the way you did.

To check PHP is working

sudo   gedit  /var/www/info.php

And paste in this PHP information code:

<?php
    phpinfo();
?>

Save it and exit.

Restart Apache 2:

sudo /etc/init.d/apache2  restart

You can test PHP runing the info.php file:

http://localhost/info.php
Achu
  • 21,407
5

The steps listed at http://netbeans.org/kb/docs/php/configure-php-environment-ubuntu.html are exactly what I needed. I did a fresh installation of Ubuntu, ran

sudo tasksel install lamp-server

and then followed the steps in the Troubleshooting section i.e.

apt-get --purge remove php5-common

apt-get install php5 phpmyadmin
1
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
Oli
  • 299,380
Johnson
  • 11
0

The real problem behind this is not the installation of PHP5, which went just fine, but the fact, there's an IDN extension installed either manually or from some ancient package, most probably php5-intl.

The purging of php5-common has uninstalled all of the installed extensions, so it has fixed this error, but the solution was very 'Computer Science' like: "Have you tried to shut it off and on again?", while you could have just issued dpkg --purge php5-intl to achieve the same result.

oerdnj
  • 7,940
-1

Check if your PHP 5 mod is enabled in Apache 2 (/etc/apache2/mods-enabled). If you can't find @php5* symlinks there, you can try:

sudo a2enmod php5
sudo /etc/init.d/apache2 restart

And be sure Apache 2 listens on the port 80.

Iradrian
  • 1,338