Category: Technical

Technical Information

Manual PHP Compilation

Below steps would be more than enough to recompile php on stock centos/fedora machines. This would be best suited for servers with out any control panel. For ones with control panel, you need to first take the configure command from the phpinfo and then appended what is required.

Before proceeding, it is recommended that you have httpd-devel installed in your server.

# rpm -qa | grep httpd-devel

If the above doesn’t yield any result, ensure to install it using yum.

# yum install httpd-devel

Now let us start with the steps of PHP compilation.

# cd /usr/local/src

# tar -jxvf php-5.2.13.tar.bz2

# cd php-5.2.13

# ‘./configure’ ‘–prefix=/usr/local/php’ ‘–with-apxs2=/usr/sbin/apxs’ ‘–with-png-dir=/usr’ ‘–enable-gd-native-ttf’ ‘–without-gdbm’ ‘–with-gettext’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg-dir=/usr’ ‘–with-openssl’ ‘–with-zlib’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-magic-quotes’ ‘–enable-sockets’ ‘–enable-wddx’ ‘–with-kerberos’ ‘–enable-shmop’ ‘–enable-calendar’ ‘–with-libxml-dir=/usr’ ‘–enable-pcntl’ ‘–enable-mbstring=shared’ ‘–without-sqlite’ ‘–enable-mbregex’ ‘–with-gd’ ‘–enable-bcmath’ ‘–enable-dba’ ‘–with-xmlrpc’ ‘–with-mysql=/usr/bin/’ ‘–with-mysqli=/usr/bin/mysql_config’ ‘–enable-dom’ ‘–with-xsl’ ‘–enable-soap’ ‘–with-xsl=/usr’ ‘–enable-xmlreader’ ‘–enable-xmlwriter’ ‘–enable-pdo’ –with-pdo-mysql=/usr’ ‘–with-pdo-sqlite=/usr’ ‘–enable-json’ ‘–enable-zip’ ‘–with-pspell’ ‘–with-mhash=/usr’ ‘–with-tidy=/usr’ ‘–with-curl=/usr’ ‘–with-mcrypt=/usr’ ‘–enable-gd-native-ttf’ ‘–with-ttf’ ‘–with-t1lib=/usr’

You may get errors related to missing libraries in the above command. Those all are available in yum. Install the library and its devel package and execute the above command once again. Take an example of missing freetype library, below steps needs to be followed.

#yum search freetype

# yum install freetype.i386 freetype-devel.i386

And once the required library is installed go and execute the configure command string  again until all libraries required are installed and configure command creates required scripts and files to get ready for the next step of compilation.

# cat /proc/cpuinfo  | grep processor | wc -l

# make -j4 [4 is result from earlier command]

# cp .libs/libphp5.so  /etc/httpd/modules/

# make -j4 install [may have to update the httpd.conf file so as to remove the php module added again in it by this command]

And now, you have php compiled running on your server, which you may confirm using

# php -v

PostgreSQL psql: could not connect to server: Connection refused

First thing to be checked is to see if postgresql service is running on the server.
# /etc/init.d/postgresql status

If it is running and you get the error, you need to add enable TCP/IP support. By default, the PostgreSQL server only allows connections to the database from the local machine or localhost. This is a security feature of PostgreSQL.

To allow remote IP addresses/servers to access postgresql server we need configure it accordingly. For this we need to edit the config file /var/lib/pgsql/data/pg_hba.conf.

# vi /var/lib/pgsql/data/pg_hba.conf

You will find

host    all         all         127.0.0.1          255.255.255.255   md5

Now add a new line as below

host    all         all     123.237.1.158      255.255.255.0      trust

where 123.237.1.158 is the IP address from which you are trying to access the postgresql server.

Save and close the file.

Also you may need to enable TCP/IP communication, which can be done in the configuration file /var/lib/pgsql/data/postgresql.conf. Ensure that the setting tcpip_socket is set to true.

# vi /var/lib/pgsql/data/postgresql.conf

tcpip_socket = true

Save and close the file.

Now restart PostgreSQL server, so that the config changes are updated.

# /etc/init.d/postgresql restart

This will open default port 5432.

You may test the connectivity using 3rd party application like pgadmin or using psql client. The psql command from would be as follows.

# psql -h PostgreSQL-IP-ADDRESS -U USERNAME -d DATABASENAME

Notes : This documentation is with regard to Centos. However same holds good for debian and also ubuntu. The configuration files paths on debian/ubuntu is as below

/etc/postgresql/7.4/main/pg_hba.conf

/etc/postgresql/7.4/main/postgresql.conf

where 7.4 is the postgresql version installed on the server.


Adding Virtual IP in Ubuntu

First of all check the ethernet device name, you may use the below command for the same.

$ ifconfig | grep eth

eth0      Link encap:Ethernet  HWaddr 70:5w:x6:2b:63:f9

To add virtual IP address edit the interfaces file

$ vi /etc/network/interfaces

And add the below data, ensure the IP which you are going to mention are in the same network as currently used IP address. Also ensure that the IP being added is not used in the network. Add the below entries to the end of the interfaces file.

auto eth0:1
iface eth0:1 inet static
address 192.168.1.50
netmask 255.255.255.0

Now it is time to restart the network

$ /etc/init.d/networking restart

Now to check if the new interface has come up you could use the first command itself

$ ifconfig | grep eth

eth0      Link encap:Ethernet  HWaddr 70:5w:x6:2b:63:f9

eth0:1      Link encap:Ethernet  HWaddr 70:5w:x6:2b:63:f9

So you have 2 interfaces on your machine now, with 2 different ips which can be accessed from your LAN.

Hope this was helpful 🙂

Secure tmp

On a cpanel server you could secure tmp using the script /scripts/securetmp

However, most of the servers would find the tmp space inadequate. So you can increase the tmp size using either the manual method or again using the securetmp script. Below are the steps to accomplish the same.

We have 3 scenarios here

1 ) Running securetmp for the first time.

2 ) Need to increase tmp size but have already run securetmp

  • Increase space again using securetmp script
  • Manually Increase the space.

Let us see how this can be done.

1 ) Running securetmp for the first time.

As of now the cpanel script /scripts/securetmp create a file of size 512 MB and /tmp is mounted on this file. But 512 MB would be inadequate for a busy server, so first we shall modify the script to create the tmp file whose size is more than 512 MB. Let us assume that our server needs 1 GB of tmp space.

The script uses kilobytes in it, so let us convert 1 GB to KB

1 gigabyte = 1 048 576 kilobytes

Now let us make the change in the securetmp script

# replace “512000” “1048576”  −− /scripts/securetmp

Now we can run the script

# /scripts/securetmp

And answer few questions it asks before it setups the new tmp partition.