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
3
  • Can you post any error messages? Please include your sfotware sources too, you can use the command from How do I find all of my software sources?.
    – Lekensteyn
    Mar 23, 2011 at 13:18
  • @Lekensteyn please refer to my comment to @Achu below Mar 23, 2011 at 13:38
  • BTW I am quite sure that the provided logs are not from the fresh installation and you have installed more than just apache2 and mod_php, namely php5-interbasse, php5-lasso and php5-ming. It's hard to provide correct answer when your question is about something different than your real problem.
    – oerdnj
    Apr 5, 2013 at 6:37

5 Answers 5

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
7
  • Nothing happens when I run sudo tasksel, check LAMP Server and then click OK. I come back to the terminal. I don't get asked for a mysql root password. Mar 23, 2011 at 12:04
  • @gaurav if tasksel doesn't work for you, you can install running sudo apt-get install lamp-server^
    – Achu
    Mar 23, 2011 at 12:08
  • @Achu.. nope... that doesn't work either..same problem Mar 23, 2011 at 12:42
  • @Gaurav You mean you can't install anything? so how can you install the packages you describe on your main question? if got error message when you run the installations, please include the output with you question. thanks
    – Achu
    Mar 23, 2011 at 13:04
  • @Achu I can install everything. The problem is that installing LAMP server does not help. In fact, when I remove everything i.e. apache2, libapache2-mod-php5 and php5 using purge, and then install only apache2, localhost comes up with the default "It works" page. It's when I add the PHP packages that the problem of "Cannot connect" comes up. Mar 23, 2011 at 13:37
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
1
  • 1
    sendmail is a little old fashioned as MTAs go... postfix is probably a better choice IMO.
    – Oli
    Nov 7, 2011 at 23:04
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.

-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.

5
  • how do check that Apache2 listens on port 80? I tried the commands and "Module php5 already enabled" is what I get. Mar 23, 2011 at 11:56
  • With the command 'sudo nmap localhost'. By default you don't have the 'nmap' installed.
    – Iradrian
    Mar 23, 2011 at 12:04
  • 1
    Instead of using netmap to check port 80 from the client perspective, you can use netstat which is installed by default (from the net-tools package) to get a list of all listening services (over TCP): netstat -tln
    – Lekensteyn
    Mar 23, 2011 at 13:22
  • Or even netstat -aunt | grep :80 -- checking that the entry is under the Local Address column.
    – belacqua
    Mar 28, 2011 at 16:39
  • The logs provided in the question quickly clearly indicate that the PHP was in fact enabled in the Apache.
    – oerdnj
    Apr 5, 2013 at 6:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .