Alright guys after installing apache web server, now we are going to install php mysql on ubuntu so that you guys can start developing some web application with php and mysql.
If you have not install apache web server yet, please install it first before installing php and mysql, read my previous article about it, or just run this command:
sudo apt-get install apache2
How to install php 5
Okay let's install php 5 package and the library required by apache web server so that php 5 can work well on apache web server.
sudo apt-get install php5 libapache2-mod-php5
Next we need to restart the apache2 web server so that the changes can take effect
sudo service apache2 restart
After that we need to make sure php is really works, so we are going to create a php file called info.php which will display php information using phpinfo() function.
sudo touch /var/www/html/info.php
sudo gedit /var/www/html/info.php
Once gedit is poping out, type this simple php command:
Now, run on the web browser the url http://localhost/info.php, and you should see something like this:
That web page indicate that php is working well inside apache web server and you can start do some php coding on it.
Noticed that on PDO section is currently empty, that's because at this point we are not yet install and setup mysql as database server.
How to install Mysql
Next we need to install mysql database server on ubuntu, to do that run this command from the terminal/console/command line prompt:
sudo apt-get install mysql-server mysql-client
You will be asking to fill password for root user on mysql database, make sure you don't forget the password, because you will need it for connection between php and mysql.
We need to install one more package which is the php5-mysql package, this package will connect the mysql server with php.
sudo apt-get install php5-mysql
Alright now go back to the browser and refresh the info.php, this time on PDO section you should see "mysql", that means php and mysql is ready to use.
At this point you can start develop php application/program which runs on apache web server and use mysql to store data of your application.
No comments:
Post a Comment