Bug in PHP release version.

I came across the following error while “make” process during custom compilation of PHP. This is bug in its release which can rectified by applying a patch.

============
/usr/local/src/php_sources/php-5.4.5/ext/dom/node.c: In function dom_canonicalization:
/usr/local/src/php_sources/php-5.4.5/ext/dom/node.c:1898: error: dereferencing pointer to incomplete
============

Download the patch “php1.patch” from the below URL.

http://www.mediafire.com/?ii19zwu444z4o1z

and execute the following command in the php source directory.

============
@Host [/usr/src/php-5.2.17]# chmod 755 php1.patch
@Host [/usr/src/php-5.2.17]# patch -p0 < php1.patch
patching file ext/dom/node.c
Hunk #1 succeeded at 1950 (offset 55 lines).
patching file ext/dom/documenttype.c
Hunk #1 succeeded at 215 (offset 10 lines).
patching file ext/simplexml/simplexml.c
Hunk #1 succeeded at 1343 (offset -74 lines).
=============

Now do compilation again, error is corrected ๐Ÿ™‚

500 No response while loading cPanel

Sometimes the following would be the error generates when we try to load the cPanel of an account.

==================
[2013-04-07 08:15:05 -0500] warn [cpanel] Failed to load cPanel user file for ‘cPanel_username’ at /usr/local/cpanel/Cpanel/Config/LoadCpUserFile.pm line 32
Internal Server Error: “GET /cpsess7952893738/frontend/x3/index.html?post_login=88039081253834 HTTP/1.1” 500 No response from subprocess ( (cpanel)) with exit signal: 255
==================

This is a permission or ownership issue with the cpanel user file present in the path /var/cpanel/users. It should be corrected as follows:

=================================================
root@server [~]# ll /var/cpanel/users/cPanel_User_Name
-rw-r—– 1 root cPanel_User_Name 949 Oct 16 01:37 /var/cpanel/users/cPanel_User_Name
=================================================

load cPanel now ๐Ÿ™‚

HTTP not working, but HTTPS does in NGINX

Found an issue regarding with http url of site is not working, but sametime https does. Here the Nginx works as a Front End Proxy on port 80 for Apache.

——————-
tcp 0 0 IP:80 0.0.0.0:* LISTEN 2023/nginx
tcp 0 0 IP:80 0.0.0.0:* LISTEN 2023/nginx
tcp 0 0 IP:80 0.0.0.0:* LISTEN 2023/nginx
tcp 0 0 IP:8081 IP:38574 ESTABLISHED 24791/httpd
——————-

Troubleshoot part
===========
Section 1:

————-
I tried first to switch to apache as main as follows, to verify if is clearly an issue only with nginx but not apache.

* Took a backup of apache conf with current date.
* vi /usr/local/apache/conf/httpd.conf and set parameter ‘Listen 0.0.0.0:8081’ to ‘Listen 0.0.0.0:80’ under the line “# Defined in /var/cpanel/cpanel.config: apache_port”. Also replaced all ‘8081’ entries to ’80’, along with NameVirtualHost and in the virtual host.
* vi /var/cpanel/cpanel.config and set parameter ‘apache_port=0.0.0.0:8081’ to ‘apache_port=0.0.0.0:80’. Then execute the following script to make the changes in effect.

/usr/local/cpanel/whostmgr/bin/whostmgr2 –updatetweaksettings

* /etc/init.d/nginx stop
* /etc/init.d/httpd restart

Now apache would run as main webserver without any Front End proxy. Check the http url is loading fine or not. If it is working, the issue is regarding with nginx server.

Section 2:
————-
* Check the nginx configuration for syntax errors.
root@host [~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
* Since I found the synax check is ok with nginx, turned by attention towards vhost entry for this domain in nginx.
* In the path, “/etc/nginx/vhosts” I could see vhost files for all domains but not the particular domain’s in question.
* I created one manually as follows:

—————————————————————————
root@host [~]# cat /etc/nginx/vhosts/domain.com
server {
error_log /var/log/nginx/vhost-error_log warn;
listen domainIP:80;
server_name domain.com www.domain.com;
access_log /usr/local/apache/domlogs/domain.com-bytes_log bytes_log;
access_log /usr/local/apache/domlogs/domain.com combined;
root /home/cPanel_username/public_html;
location / {
location ~.*.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|
flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
expires 1d;
try_files $uri @backend;
}
error_page 405 = @backend;
add_header X-Cache “HIT from Backend”;
proxy_pass http://domainIP:8081;
include proxy.inc;
}
location @backend {
internal;
proxy_pass http://domainIP:8081;
include proxy.inc;
}
location ~ .*.(php|jsp|cgi|pl|py)?$ {
proxy_pass http://domainIP:8081;
include proxy.inc;
}
location ~ /.ht {
deny all;
}
}
—————————————————————————

* Now I tried to switch nginx back as Front proxy. Reverted the changes made in “/var/cpanel/cpanel.config”, “/usr/local/apache/conf/httpd.conf”.
* Then make sure you executed the command “/usr/local/cpanel/whostmgr/bin/whostmgr2 –updatetweaksettings” to make the changes in cpanel.config to be in effect. Then restart apache and start nginx.

You can see http url works as a charm ๐Ÿ™‚

Please note that, next time when you face the same issue, you can directly go to section 2 for fast troubleshooting and closing the ticket.

Mail Client Configuration shows incorrect server name

Sometimes it happen the Mail Client Configuration(cPanel > Email Accounts > any email account in list > More > Configure Email Client) option generates incorrect server name under “Secure SSL/TLS Settings”

The server name can be corrected in the following files of cPanel.

/var/cpanel/ssl/dovecot-CN
/var/cpanel/ssl/exim-CN
/var/cpanel/ssl/courier-imapd-CN
/var/cpanel/ssl/courier-pop3d-CN

Slow downloading speed from server

This can be of many reasons, might be due to server load, firewall etc. Basically we check these areas when slow downloading speed occurs ๐Ÿ™‚

But I have identified one uncommon and not easily notifiable thing on my server regarding with my public Ethernet interface. Please see the following result.

———————-
# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Half
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: g
Wake-on: g
Link detected: yes
———————-

Did you notice the Speed: 100Mb/s and Duplex: Half ?, that is the issue here ๐Ÿ˜€ which allows only half duplex transmission – transmission to only one direction at a time and thus limits the speed.

You can change to full duplex as follows:

————–
ethtool -s eth0 speed 100 duplex full autoneg off
————–

This will change the half duplex to full which allows sending and receiving at a time. Also set auto-negotiate to off as the switch has this function set to and it is best to match up the options.

(Note : In some server it can be eth1 the public interface and eth0 use for internal network, in that case change eth0 to eth1. Always be careful with that)

Then #service network restart

———————-
# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
MDI-X: Unknown
Supports Wake-on: g
Wake-on: g
Link detected: yes
———————-

Make sure secondary IPs associated with your ethernet are up, if not showing in ifconfig, then restart ipaliases.

#/etc/init.d/ipaliases restart

ERROR : Can’t locate Net/SNMP.pm in @INC

Recently I met with an error in server while checking traffic in and traffic out plugin for monitoring system(Nagios).

———–
Can’t locate Net/SNMP.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.8/i686-linux /usr/local/lib/perl5/5.8.8 /usr/local/lib/perl5/site_perl/5.8.8/i686-linux /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl .) at /usr/local/nagios/libexec/check_bw_snmp_out line 16.
BEGIN failed–compilation aborted at /usr/local/nagios/libexec/check_bw_snmp_out line 16.
———–

This can be easily fixed by installing Net::SNMP

Try,

#cpan
#cpan> install Net::SNMP

SSI(Server Side Include) Not Working

SSI (Server Side Includes) are directives that are placed in HTML pages, and evaluated on the server while the pages are being served. SSI is to include the contents of one or more files into a web page on a web server. For example, a web page containing a daily quotation could include the quotation by placing the following code into the file of the web page.

The syntax should be as:

includes

This has to be given in the main file where you suppose to include or parse this SSI, ie invoking file.html(SSI) to main file which is present in the same directory.

Sometimes it wont work in server. The following simple steps are the fix for it.

First make sure mod_include.c is enabled in apache modules
Then, In accounts htaccess file

Options +Includes
AddType text/html .html
AddHandler server-parsed .html

Restart apache ๐Ÿ™‚ and see the changes.

Install EAccelerator

eAccelerator is a free open-source PHP accelerator, optimizer, and dynamic content cache. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times.


#cd /usr/src/
#wget http://path/to/whereeveryou/download/eaccelerator-x.x.x.tar.gz
#tar xzvf eaccelerator-x.x.x.tar.gz

(Make sure you are going to compile it for the PHP version the site using. To confirm it create a phpinfo page in the domain and note the PHP API, PHP Extension and Zend Extension. Because these three things can be seen while compiling through shell, so you can compare if they are same or not)

#phpize
#./configure –with-php-config=/usr/bin/php-config or /usr/local/bin/php-config

(Get the correct path of “php-config” from your server according to version of PHP the domain using)

#make
#make test (–>you can check if any error is there)
#make install

(Note the extension path in the last, like /usr/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so)

Then go to php.ini, lets say “/etc/php5/php.ini”. You can get it from “php –ini” or from the phpinfo page.

#vi /etc/php5/php.ini

(Set the following in php.ini file)

zend_extension=”/usr/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so”
eaccelerator.shm_size=”16″
eaccelerator.cache_dir=”/tmp/eaccelerator”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.filter=””
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”0″
eaccelerator.shm_prune_period=”0″
eaccelerator.shm_only=”1″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″

Then create eaccelerator directory and set correct permission.

#mkdir /tmp/eaccelerator
#chmod 777 /tmp/eaccelerator

Restart Apache.

#/etc/init.d/httpd stop
#/etc/init.d/httpd start

Check eaccelerator in the phpinfo page ๐Ÿ™‚

Unable to SU to root

The error “ -bash: /bin/su: Permission denied ” you get while trying to su to root after logged as sudo because of the incorrect permission of “ /bin/su “. Make sure you have given correct permission as follows:

—————–

# chmod 4750 /bin/su
# ll /bin/su
-rwsr-x— 1 root wheel 24312 Mar 21 2012 /bin/su*

If the problem still exists, check if the sudo user has been added as wheel user in the server. Check it in the file /etc/group like as follow:

wheel::10:root,sudouser (..sudouser should be replaced with correct sudo username)

In case you have no backend access, you can login to WHM and add wheel user there Home ยป
Security Center ยป
Manage Wheel Group Users
then choose sudo user from list and click “ Add to Group “.

—————–