This page has been automatically translated. Click here to open the original page

Setup Apache2, MySQL and PHP5 on Ubuntu Linux



Apache2,MySQL,PHP Last weekend I decided to give a purpose to an old PC (Pentium III with 128MB RAM, 30GB HD) on which a few months ago I installed Ubuntu Server 6.0.6. As always what I was missing was an online test environment that allowed me to make the modifications and new features to add to my sites to avoid doing hot, I needed to install and configure Apache2, MySQL and PHP5.

Tip: Click here to start a scan of system errors and optimize PC performance


Starting with a guide on html.it, here is the steps that I followed:

  • Update list of available packages (it is good practice to always do before new facilities):

    sudo apt-get update 
  • Installing Apache2:
     sudo apt-get install apache2-mpm-prefork 
  • Installing MySQL
     sudo apt-get install mysql-server 
  • Install the PHP5 module for Apache2:
     sudo apt-get install libapache2-mod-php5 
  • Installation of the library to use MySQL PHP5:
     sudo apt-get install php5-mysql 
  • Installing PHP library for image manipulation
     sudo apt-get install php5-gd 
  • Installing PHP library to run PHP from the command line also:
     sudo apt-get install php5-cli 
  • Enabling MySQL extension to the configuration file for PHP5:
     vi /etc/php5/apache2/php.ini 

    line editing

     ;extension=mysql.so 

    in

     extension=mysql.so 
  • Restart Apache2:
     sudo /etc/init.d/apache2 restart 

Then to test that everything was working correctly I proceeded as follows:

Test integration between Apache2 and PHP5

Creating test_php.php file in the directory / var / www with the following contents:

 
 

With browser access to 'URL http://servername/test_php.php (where servername represents the IP address or the name of the linux server) and verify information display featured in PHP5 configuration

Test integration between PHP5 and MySQL

Creating a db test on MySQL:

 mysqladmin -u root create test 

Creating test_mysql.php file in the directory / var / www with the following contents:

 
  
 

With browser access to 'URL http://servername/test_mysql.php (where servername represents the IP address or name of the linux server) and checks the message "OK" message indicating that the connection to DB "test" is was successful.

Did you like this article?
Subscribe now to our newsletter to receive the articles directly on your computer:

Articles related to "Setup Apache2, MySQL and PHP5 on Ubuntu Linux"


Comments

13 Responses to "Setup Apache2, MySQL and PHP5 on Ubuntu Linux"
  1. ilberni writes:

    all are really apt-get apt-get install

    I also I had to add repository

  2. David writes:

    You're right, thanks for reporting! 'm Not even the most 'able to do a good cut & paste! However I have now corrected.
    Could you clarify what other actions you have done? I started with a Ubuntu Server 6.0.6

  3. vorax writes:

    And 'better on one line

    otherwise often gives error.

    syntax error, unexpected T_STRING, etc. ..

    Hello

  4. lamer01 writes:

    I wanted to tell you that in Test integration between Apache2 and PHP5
    php code you've written has an inaccuracy:
    be

  5. lamer01 writes:

    I wanted to tell you that in Test integration between Apache2 and PHP5
    php code you've written has an inaccuracy:
    should be < ?php phpinfo();?>

  6. Joseph writes:

    Excellent tutorial, no matter the error on phpinfo is a clear typo :) )

    byeee

  7. David writes:

    Thanks for reporting! I corrected the error.

  8. Athos writes

    @ athos athos-desktop: ~ $ mysqladmin-u root create test
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user' root '@' localhost '(using password: NO)'

    I thank the tutorial but do not go out from here

  9. ninja writes:

    Hello Athos anke I have the same problem ... Someone help us??

  10. Mark writes:

    Hello!
    Until integration testing between PHP with MySQL tt well then when I try to connect to the page test_mysql me this error:

    Parse error: syntax error, unexpected $ end in / var / www / test_mysql.php on line 9

    can you help? thanks

  11. Nicola Giosmin writes:

    Thank you,
    one of the most clear and concise guide I've ever used: very useful and accurate, I did everything in an instant.

  12. ox4r writes:

    @ athos

    $ link = mysql_connect ( 'localhost', 'root', 'mypassword')

    In the text file put the mysql password as an example here, otherwise try to connect to the DB without pwd.

  13. Tr1t0N writes:

    Hi I have a problem.
    Following all the instructions, I installed all
    I tried to make it work with e107, but I do not open the site and says it is an application x-httpd-php