Thursday, November 25, 2010

Setting up PHP on debian server


#apt-get install php4

or check the latest version in Debian website.

Also install the following if not automatically installed with above command and also install the Suggested packages if needed

apache-common libapache-mod-php4 php4 php4-mysql php4-pear

There are a few other packages we'll need to install to get Apache working with PHP.

#apt-get install libapache2-mod-php4 php4-cgi


All the necessary packages are installed, but we aren't quite done yet. Using your favorite text editor, we'll need to make some changes to /etc/apache2/apache2.conf.
First, locate the line "#AddType application/x-httpd-php .php" and un-comment the line by removing the # from the beginning. Next, we'll need to add the line below.

LoadModule php4_module /usr/lib/apache2/modules/libphp4.so

To get those changes to take effect, we'll have to restart Apache. If we don't, web browsers will be downloading our full PHP files rather than Apache processing them first.

/etc/init.d/apache2 restart

Note: If we get an error while restarting, saying the module is already loaded, we can go ahead and remove the LoadModule Line added above.

To show that PHP is working, we'll place a PHP file in our web folder, and browse it through a Web Browser.

No comments:

Post a Comment