Ubuntu, PHP, NetBeans - part I

Posted by Petr Pisl on Jun 29 2008, 11:47:53 PM CEST

This article is about installing PHP environment - PHP, Apache, MySQL and xDebug in Ubuntu 8.04. Everything is available through the default Ubuntu repositories, so it should not be hard. I did this last week, when I prepared a machine for our UI study. It's expected that you have already installed Ubuntu or you use VirtuaBox and you have installed Ubuntu as a virtual machine.

Open a terminal. You will need to install all the parts as root, so you have to execute commands trough sudo or  you can in the terminal write command

$ sudo bash

and from this time all what you do in this terminal you do as root. There are the steps for installing the PHP development environment:

  1. Install Appache web server

    apt-get install apache2

  2. Install MySQL server

    apt-get install mysql-server

    The installation of MySQL server will ask for password for root user. It's not mandatory, but I recommend to enter a password.

  3. Install PHP 5

    apt-get install php5

  4. Install MySQL extension for PHP

    apt-get install php5-mysql

  5. Install xDebug extension for PHP - the extension for debugging.

    apt-get install php5-xdebug

  6. This all what you have to install. Now we will set up Apache and PHP.

  7. Setup the Apache web server to use users web sites

    After installing Apache the server should be running. If you click this link http://localhost/ the Firefox is opened and you should see the same content as is on the picture. 

    Localhost

    But when you try the url, which acces web sites in your home folder, it fails. Instead petr write your username:).


    To get it work you have to:
    • Enable userdir module in Apache web server

      a2enmod userdir

    • Create public_html folder in your homedir (do it uder your account, not as root)

      mkdir public_html

    • Restart Apache web server

      /etc/init.d/apache2 restart

      If you do it correctly after refreshing Firefox you should see empty content of the folder as on the picture.



  8. Enable remote debugging in xDebug

    In the folder public_html create index.php file with content:
    <?php
         phpinfo();
    ?>
    
    Refresh Firefox and you should see how the PHP runtime is setup. Search for the property xdebug.remote_enable property. By default this property is switched off as you can see on the picture.


    To enable this property you have to open file /etc/php5/conf.d/xdebug.ini and add line

    xdebug.remote_enable=on

    and restart the Apache web server

    /etc/init.d/apache2 restart

This is all. Now you are ready to start develop a PHP application. Next I will write how to instal JRE (Java Runtime Environment) or JDK (Java Development Kit) and NetBeans PHP. Also I will describe how to check, whether the debugging and MySQL database work well.

Category: Tips & Tricks | Permalink | Comments [7]

Trackback URL: http://blogs.sun.com/netbeansphp/entry/ubuntu_php_netbeans
Comments:

A cent.... next time use a2enmod instead of the two ugly symlinks... regards

Posted by Marcelo Morales on June 30, 2008 at 11:51 PM CEST #

Thanks Marcelo. I have corrected this in the blog.

Posted by Petr Pisl on July 01, 2008 at 07:36 PM CEST #

A great article - many thanks.
I am 1 day in with Ububtu.
Have installed PHP5, and it works. Can amend the 'xdebug.ini' file but cannot save it. Cannot gain administrator status. All reference materials say admin access can be made through sudo commands, but cannot open editor from there.
Think same problem is preventing the import of ttf files in the fonts directory.
Any help would be appreciated.

Posted by John CLAYTON on July 13, 2008 at 07:47 PM CEST #

Sorry about the post.

Have solved the problem.

Thanks again for article.

Posted by John CLAYTON on July 13, 2008 at 08:05 PM CEST #

sudo tasksel

install lamp and voila php, apache & mysql are installed and configured, except for the xdebug part.

Posted by Doug Holton on July 16, 2008 at 12:13 AM CEST #

your comment system is broken.

I tried to post a response and it says I am using blacklisted words.

Just use sudo tasksel

Posted by Doug Holton on July 16, 2008 at 12:15 AM CEST #

Hi Doug,

thanks for the tip. It's easier. I will try it on fresh ubuntu installation.

And you are right. Your first comment was marked as a spam.

Thanks,
Petr

Posted by Petr on July 16, 2008 at 12:26 AM CEST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed