Installing PHP on a server

Install PHP

Warning: Before starting the installation, you must have a Web server installed.
You can follow our tutorial to install an Apache server.

1) Download the latest version of PHP source,
Type the following command on your terminal, change the version number (here 5.4.8) to obtain the latest version of PHP
wget http://us2.php.net/distributions/php-5.4.8.tar.bz2

2) Extract the archive: tar -jxvf php-5.4.8.tar.bz2

3) Now compile and install the source code of PHP
Type this: cd php-5.4.8/
then

./configure --prefix=/var/www
make
sudo make install

Finally move the configuration file
cp php.ini-dist /usr/local/lib/php.ini

4) Verify that the installation went well
php -v
Successful installation of PHP display a message similar to this:

PHP 5.4.8 (cli) (built: Oct 18 2012 13:02:07) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

5) Edit the configuration file of PHP
sudo nano /etc/php.ini
Made by the configuration necessary for the needs of your new server.

6) Edit the Apache configuration file
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so

7) Add the type of file extension that will be interpreted by PHP

AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php-source .phps

8) Restart your server
sudo /etc/init.d/apache2 restart

9) First create a PHP script to make sure everything is correct.
Open your text editor (eg: nano)
nano /var/www/info.php
and enter the code then save

10) That you now have a server with PHP, good fun ;)

NB: If you want a good OS for your production server, I urge you to CentOS which is one of the best for this kind of use

Next entry

Previous entry

Similar entries

comments powered by Disqus