Connect & Share

Installation of PHP On Linux Distribution

:: Installation of PHP On Linux Distribution :: Prerequisites for PHP installation on Linux Environment :: 1. Need Root access for the host server on which you woould like to install PHP. 2. Apache web server must be installed. If you want MySQL support in PHP, MySQL server also must have been installed prior to the next steps. =================================== # Installation of the PHP on CentOs Server. =================================== Before installing PHP on the Centos Server you must install Apache and Mysql server on your CentOs Machine, Kindly follow the instructions to install :: IMP NOTE :: As CentOs comes with the utility YUM, and you can use yum to install apache and mysql. 1. Installing Mysql :: We ran the Command ::
# yum install mysql mysql-server
Then, In order to starts Mysql automatically whenever the system boots we run the command ::
# chkconfig --levels 235 mysqld on
And then Mysql start ::
# /etc/init.d/mysqld start Or service mysql start
Run below commands in order to allow authentication for your mysql server. Commands ::
# mysqladmin -u root password yourrootsqlpassword
# mysqladmin -h -u root password yourrootsqlpassword
So nobody can access your mysql server without authentication. 2. Installing Apache :: Apache2 is available as a CentOS package, therefore we can install it using below instructions :: We ran the Command ::
# yum install httpd
Now configure your system to start Apache at boot time. Command ::
# chkconfig --levels 235 httpd on
start Apache:
# /etc/init.d/httpd start OR service httpd start
You can test your apache installation via accessing your ip on the web browser. E.g. It should show you the the message as below :: ------------------------------------ Apache2 Test page Powered By CentOs.... [caption id="attachment_252" align="alignnone" width="407"]Apache Test Page Apache Test Page[/caption] ------------------------------------ NOTE :: Default document for the centOS os /var/www/html and configuration file is /etc/httpd/conf/httpd.conf Finally Now you can proceed to install PHP using below commands :: Via command ::
# yum install php
It will install php on your server. Once done its manadatory to restart the apache after it. Command ::
# /etc/init.d/httpd restart Or service apache restart
=================================== # Installation of the PHP on Fedora Server. =================================== User same steps to install mysql and apache on the fedora server. Install PHP via command ::
# yum install php php-soap php-pear php-devel
Once installed restart the apache server.
# service httpd restart
And then test the PHP via creating phpinfo testing website as below :: * Create a localhost phpinfo testing website * Create the phpinfo folder Command ::
# mkdir /usr/share/phpinfo
* Create the /usr/share/phpinfo/index.php server file with the following code :: --------------------------- <?php phpinfo(); ?> --------------------------- * Create the /etc/httpd/conf.d/phpinfo.conf Apache configuration file with the following code :: ----------------------------------------------------------------------------------- # phpinfo - PHP utility function for displaying the PHP configuration # # Allows only localhost by default Alias /phpinfo /usr/share/phpinfo <Directory /usr/share/phpinfo/> order deny,allow deny from all allow from localhost </Directory> ----------------------------------------------------------------------------------- Once done. Restart the Apache Server Command ::
# service httpd restart
Once done with all, Visit localhost/phpinfo in your web browser. Or you may do with the server ip address that is Thats all!!!! =================================== # Manual installation of the PHP :: =================================== In order to do install manual installation of PHP we must install mysql and apache manually on the Linux OS . Follow the instructions as below :: --------------------- Installing apache :: --------------------- 1. Download the apache source :: Refer the link :: In this case we will refer the apache version 2.2.23 Download the source ::
# cd /usr/local/src
# wget
# tar -zxvf httpd-2.2.23.tar.gz
Once the source is downloaded and extracted it will create directory called :: httpd-2.2.23 Now proceed with the installation ::
# cd httpd-2.2.23
# ./configure --enable-so
# make
# make install
if during the ./configure command prompts for the error such as " configure: error: no acceptable C compiler found in $PATH" you must install GCC to overcome this error. you can get it installed via RPM. Once done again run the ./configure and make and make install. Once installed, Start Apache and verify installation using commands below ::
# cd /usr/local/apache2/bin
# ./apachectl start
And test the apache page via browing the ip It should show the apache page with message "It works"!!! --------------------- Install Mysql --------------------- 1. Download the latest stable relase of MySQL and refer the site for download :: Here select the myql version from the first drop down, In our case we selecte d5.1 and LinuX OS and download the version"Generic Linux (glibc 2.3) (x86, 32-bit), RPM Package MySQL Server" While download it will ask to fill up the form "" and once you submit the form it will allow you to download the source. Upload the downloaded source to the server.
# cd /usr/local/src
# the RPM will be downloaded as "MySQL-server-5.1.66-1.glibc23.x86_64.rpm"
2. Before install new RPM, you must remove existing instalations ::
# rpm -qa | grep -i mysql
mysql-5.0.22- mysqlclient10-3.23.58-4.RHEL4.1
# rpm -e mysql --nodeps
# rpm -e mysqlclient10
3.. Install the downloaded MySQL package
# rpm -ivh MySQL-server-5.1.66-1.glibc23.x86_64.rpm
It will install the mysql on your server. Once installation is done you must apply authentication for your mysql. Using below command ::
# /usr/bin/mysqladmin -u root password 'My2Secure$Password'
Once you setup authenticatio nobody other than authenticated user will be able to access your mysql server. 4, Now Verify the MySQL installatio using the below command ::
# mysql -V
It will show you the mysql version with mysql prompt. As well as Connect to the MySQL database using the root user and make sure the connection is successfull.
[local-host]# mysql -u root -p
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 13 Server version: 5.1.66-rc-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> Mysql installation is successful. --------------------- Install PHP --------------------- Now installing PHP. 1. Download source code Refer the link :: And copy the required PHP version ::
# cd /usr/local/src
Download the source to this directory. that is php-5.3.19.tar.bz2 Extract it.
# tar -zxvf php-5.3.19.tar.bz2
It will create a directory called php-5.3.19
# cd php-5.3.19
# /configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql
There are many other options which turn on additional features. For all available configuration options and their default values type
# ./configure –help
To compile and install PHP run the command ::
# make
# make install
Once done the installation, Edit httpd.conf All necessary changes to httpd.conf (Apache configuration file) should have already been made automatically during the installation, so usually you need not to do anything. Anyways, check that following lines were added to your httpd.conf file or not. ------------------------------------------------------- LoadModule php5_module modules/ AddType application/x-httpd-php .php ------------------------------------------------------- If not, add them manually. Create php.ini file Importantly, you have to create php.ini configuration file
# cp php-5.3.19/php.ini-recommended /usr/local/php/lib/php.ini
Once done, restart the apache ::
# /etc/init.d/httpd restart
service httpd restart
Allow httpd to start automatically each time systems boot.
# chkconfig httpd on
Now your PHP is installed successfully with apache and MySql server.

Leave a Reply