Archive

Archive for the ‘PHP Configuration’ Category

How To Find The Version of Linux You Are Using

February 12th, 2009 No comments

Sometimes you need to know what version of the Operating system is installed on your server. This is extremely useful when you order a dedicated server and want to know what is the version of OS on it. A simple command will help you as usual:

cat `ls /etc/*{-,_}{release,version} 2>/dev/null | head -n 1`

This will show you something like

The picture below shows the difference between common commands: one shown above and uname -a. Sometimes you don’t need the kernel version, just the operating system name. This command should help you to do that.

PHP Deletes Angle Brackets While Parsing HTML: How to Solve

February 7th, 2009 1 comment

Today I’ve faced a problem that was quite strange. One of my WordPress installations refused to understand posted angle brackets. This was especially related to tags and the encoded symbols like > < and so on. I started to think what I did before :) .

The issue is described at PHP Bugs.  There is no exact solution there that’s why I decided to create this guide.

I’ve found that the issue was found after a recent PHP update using Directadmin custombuild script. I’ve got all recent software, but PHP doesn’t recognize simple symbols. My first thought was that the problem is with XML interpretation, that is especially related to libxml2. I’ve followed Directadmin forums and thought the problem is with libxml2 version.  I’ve tried to update it to version 2.7.3. There was no success as the problem still continued to persist.

#cd /usr/local/directadmin/custombuild
#wget http://xmlsoft.org/sources/libxml2-2.7.3.tar.gz
#tar -zxvf libxml2-2.7.3.tar.gz
#cd libxml2-2.7.3
#./configure –with-iconv=/usr/local
#make
#make install

This step itself doesn’t help, but you need to do it in order to fix the entire problem.

The second step you need to make is to build php with libexpat. In order to do this, you will need to perform the following steps:

- install expat-devel by entering  yum install expat-devel.

- add expat support to your PHP build. In order to do this (I assume you’re using custombuild to build PHP), you have to edit /usr/local/directadmin/custombuild/configure/ap2/configure.php5–with-libexpat-dir=/usr is the string you need to end to your current file contents.

expat adding to php

Then you need to update  the PHP version in /usr/local/directadmin/custombuild/versions.txt to 5.2.8 (most current version at the moment). After that you have to build PHP again.

cd /usr/local/directadmin/custombuild
./build php

There is no need to build anything but PHP that’s why I’ve said No to all other proposals (like cURL, Freetype, etc).  As Apache is restarted automatically, you just have to wait while the build process is complete. After that you’re welcome to enjoy your new PHP installation.

How to Enable Socket Support In PHP

December 6th, 2008 1 comment

In order to add socket support with PHP you need jsut to include it into your configure string: there is no need to install any third-party applications or software. All you need is to recompile PHP, and it can be done in some minutes.

First of all you need to know where your PHP installation is located. I think you already have it installed if you are going to add some functions. Try searching for your PHP package (I mean installing PHP from source in this article) at your server: it should exist.

When you have the package near and know where it is located, you should identify your current configuration to avoid deleting some elements from the configure line. The most useful method is to copy your current configure line from the output produced by phpinfo(); You may create a new file containing just these lines:

<?
phpinfo();
?>

Then run it using a web browser. At the beginning of this output you should see a configure line: it should look like:

‘./configure’ ‘–with-apxs2′ ‘–with-curl=/usr/local/lib’ ‘–with-gd’ ‘–enable-gd-native-ttf’ ‘–with-ttf’ ‘–with-gettext’ ‘–with-jpeg-dir=/usr/local/lib’ ‘–with-freetype-dir=/usr/local/lib’ ‘–with-kerberos’ ‘–with-openssl’ ‘–with-mcrypt’ ‘–with-mhash’ ‘–with-mysql=/usr’ ‘–with-mysqli=/usr/bin/mysql_config’ ‘–with-pear’ ‘–with-png-dir=/usr/local/lib’ ‘–with-zlib’ ‘–with-zlib-dir=/usr/local/lib’ ‘–enable-zip’ ‘–with-iconv=/usr/local’ ‘–enable-bcmath’ ‘–enable-calendar’ ‘–enable-ftp’ ‘–enable-magic-quotes’ ‘–enable-mbstring’ ‘–enable-pcntl’

Copy it to your text editor and remove quotes and apostrophes. Then add ‘–enable-sockets’ to this line: that’s the only string we need to enable socket support.

Then we need to make PHP. If you’re doing it for the first time, see my previous post: How to configure PHP .

The command is simple enough: make :) . I’d suggest you to make clean before doing make to avoid some possible errors. After the PHP is  “made” you need to make install and then to reboot Apache or any web server you might have to see the changes.  If everything went OK, you should see that socket functions are now available.

How to Enable mhash in PHP built from source

October 25th, 2008 No comments

If you have a server that doesn’t come with any panel and all the software was compiled from sources, you have to install the missing packages by yourself, without any scripts, etc. Today we’ll support for a server that has nothing related with this library.

As we’re dealing with a non-rpm system, we’ll have to install all the software we need from sources. In order to support hash algoritms we need to install libmhash. Just download it, extract with the following command:

tar -xzvf mhash-0.9.9.tar.gz

and go to the extracted directory:

cd mhash-0.9.9

Then you will use the usual combination for linux:

./configure
make
make install

Then you will need to recompile PHP with

–with-mhash

If you don’t know how to recompile PHP,  just search this blog as it contains lots of information on installing and configuring PHP.