This blog post will teach you how to Install Apache, MySQL and PHP on your linux system. If you are a designer or developer and use PHP, mySQL and Apache, you'll be needing these applications to be installed.
Microsoft window user can get Apache,MySQL & PHP together in XAMMP software. For more detail information regarding XAMMP software click here.
If you are using linux and you are not advance user of linux and want to install LAMP (Linux, Apache, MySQL and PHP) then this blog post will be helpful for you.
As mentioned above LAMP stands for Linux, Apache, MySQL, PHP. Installing all these software in Linux and configured them to make them work is one of difficult task for beginners.
Install Apache
Apache is web server program developed and maintained by an open community of developers under Apache Software Foundation.
First we will install apache web server
Steps:
1. Open up the Terminal (Applications > Accessories > Terminal) or press ctrl+alt+T.
2. Copy/Paste or type the following command into Terminal and then press enter:
sudo apt-get install apache2
3. The Terminal will then ask you for you're password, type it and then press enter.
Testing Apache Server Installation
To make sure everything installed correctly we will now test Apache to ensure it is working properly.
1. Open up any web browser and then enter the following into the web address:
You should see a folder entitled apache2-default/. Open it and you will see a message saying "It works!" , congrats to you! or something like that!
Install PHP
After successfull installation of Apache we will install PHP 5.
Step 1. Open Terminal again if it is not opened already
Step 2. Copy/Paste or type the following line into Terminal and press enter:
sudo apt-get install php5 libapache2-mod-php5
Step 3. Once PHP is installed, we have to restart Apache server in order for PHP to work and be compatible with Apache. Type the following code in Terminal to restart Apache:
sudo /etc/init.d/apache2 restart
Test PHP
Let check whether php is installed corectly or not
Step 1. In the terminal copy/paste or type the following line to create a test web page
sudo gedit /var/www/phptest.php
This will open up a file called phptest.php.
Step 2. Copy/Paste this line into the phptest file:
<?php phpinfo(); ?>
Step 3. Save and close the file.
Step 4. Now open you're web browser and type the following into the web address:
http://localhost/phptest.php or http://127.0.1.1/phptest.php
It will show all information about your php.
If you are able so see information about your php then you have successfully install php and Apache. Now we will install MySQL.
Install MySQL
MySQL is a widely used open source database.
Following are steps to install MySQL in linux:
Step 1. Once again open Terminal and then copy/paste or type this line:
sudo apt-get install mysql-server
Step 2. For other computers on your network to view the server you have created, you must first edit the "Bind Address". Begin by opening up Terminal to edit the my.cnf file.
gksudo gedit /etc/mysql/my.cnf
Change the line
bind-address = 127.0.0.1
and change the 127.0.0.1 to your IP address.
Step 3. This is where things may start to get tricky. Begin by typing the following into Terminal:
mysql -u root
Following that copy/paste or type this line:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
Step 4. We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste or type the following line into Terminal:
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:
gksudo gedit /etc/php5/apache2/php.ini
Now we have to uncomment the following line by removing the semicolon (;).
Change this line:
;extension=mysql.so
To :
extension=mysql.so
Now just restart Apache
sudo /etc/init.d/apache2 restart
Test phpmyadmin
Open web browser and enter http://localhost/phpmyadmin
If you get a 404 error then You need to configure apache2.conf to work with Phpmyadmin.
sudo gedit /etc/apache2/apache2.conf
Include the following line at the end of the file, save and quit.
include /etc/phpmyadmin/apache.conf
Now restart Apache server again to reflect changes
sudo /etc/init.d/apache2 restart
Congratulation!!! you have done it !!
References and useful links-
---------------------------------------------
No comments :
Post a Comment