Ubuntu – Install PHP 5 on a fresh installation

10.10PHPsoftware installation

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

Best Answer

  • 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
    
  • Related Question