Empowering you with the knowledge to master Linux web hosting, DevOps and Cloud

 Linux Web Hosting, DevOps, and Cloud Solutions

Author: wahab

MSSQL support to PHP in cpanel server

To use the MSSQL extension on Unix/Linux, you first need to build and install the FreeTDS library. FreeTDS is a set of libraries for Unix and Linux that allows your programs to natively talk to Microsoft SQL Server and Sybase databases.

You can refer to the following url to get informations about mssql extension and  the functions supported with it.
http://www.php.net/manual/en/book.mssql.php

To get these functions to work, you have to compile PHP with –with-mssql[=DIR] , where DIR is the FreeTDS install prefix. And FreeTDS should be compiled using
–enable-msdblib

Installation instruction:-

(This is not specific to cpanel servers, you can recompile php directly without easyapache in any normal linux servers with ‘–with-mssql=/usr/local/freetds’)

1-. Download freetds source -> www.freetds.org
2-. tar -zxvf freetds-stable-tgz
3-. cd freetds-*
4-. ./configure –prefix=/usr/local/freetds –with-tdsver=8.0 –enable-msdblib  –with-gnu-ld

Note: If you use SQL 2000, 2005, 2008 then tds version = 8.0
if you use SQL 7.0 then tds version = 7.0

5-. make
6-. make install
7-. To check freetds working, run from terminal
7.1 /usr/local/freetds/bin/tsql -S <ip of the server> -U <User SQL>
7.2 If the connection parameters are correct you will be connected to a prompt.
8-. Add the following text in freetds.conf ( /usr/local/freetds/etc )
[TDS]
host = <ip of the Server with Sql>
port = 1433
tds version = 8.0

9-. Add the following line in the file /etc/ld.so.conf and run ldconfig -v:
include /usr/local/freetds/lib

10-. Recompile PHP with –with-mssql=/usr/local/freetds flag.
Create a file called all_php4 or all_php5 in:

‘/var/cpanel/easy/apache/rawopts/’

The file doesnt exist by default, just create it and add this line to the file:
–with-mssql=/usr/local/freetds
Easy apache will check this file ‘/var/cpanel/easy/apache/rawopts/all_php5’ for any additional php configuration option during recompilation.

11-. Run ‘/scripts/easyapache’

Notes:-

1-. If you are running a 64bit OS and get an error about configure: error: ‘Could not find /usr/local/freetds/lib64/libsybdb.a|so’
then you need to do the following:
1.1 Make sure libsybdb.so is available on the server,then
1.2 ln -s /usr/local/freetds/lib/libsybdb.so.5 /usr/lib64/libsybdb.so.5
1.3 ln -s /usr/local/freetds/lib/libsybdb.so.5 /usr/local/freetds/lib64/libsybdb.so
1.4 Run   ldconfig -v

2-. If you are getting an error about configure:’ error: Directory /usr/local/freetds is not a FreeTDS installation directory’
2.1 cp [tds source]/include/tds.h /usr/local/freetds/include
2.2 cp [tds source]src/tds/.libs/libtds.a /usr/local/freetds/lib
2.3 Recompile again.

Reference:-

http://www.freetds.org/userguide/
http://www.php.net/manual/en/book.mssql.php
http://forums.cpanel.net

Flex2gateway 404 error with railo

Railo 3.x comes with BlazeDS 3.2, the Adobe open source amf engine to communicate from a Flex application to a Java backend. But we may need to modify some tomcat configurations files to get it work.  You need to verify that tomcat configurations files are properly configured for flex or not. The following are the settings needed for Flex  services:-

#1. Updating the web.xml file

/opt/railo/tomcat/conf/web.xml

Uncomment the following settings in the web.xml if present or add the following details.

<!– Load the MessageBrokerServlet  –>
<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-value>
</init-param>
<init-param>
<param-name>messageBrokerId</param-name>
<param-value>MessageBroker</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<!– The mappings for the Flex servlet –>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
/flex2gateway/*
</servlet-mapping>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
/flashservices/gateway/*
</servlet-mapping>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
/messagebroker/*
</servlet-mapping>

#2. Updating the uriworkermap.properties file

/opt/railo/tomcat/conf/uriworkermap.properties

Add the following details.

/*.cfm=ajp13
/*.cfc=ajp13
/*.cfml=ajp13
/*.cfres=ajp13
/*.cfchart=ajp13
/*.cfm/*=ajp13
/*.cfml/*=ajp13
/*.cfc/*=ajp13
/*.jsp=ajp13
/*.do=ajp13
/=ajp13
/flex2gateway/*=ajp13
/flashservices/gateway/*=ajp13
/messagebroker/*=ajp13
/=ajp13

Once you’ve updated Tomcat configuration files, restart Tomcat/Railo.

Verify the Flex

Browse to  http:///flex2gateway/  you should get a white page, if you get an error message, this would mean that either you server is not running, the MessageBroker Servlet is not running or there are some configuration mistakes.

Troubleshooting 404 error

Apache 404 error

1.Please understand that if the URL you’re using is this: http://mydomain/flex2gateway , then all your mappings should look like
/flex2gateway*=ajp13
There must no trailing slash on either of them.

2.Also verify the server.xml is updated correctly and hence the domain is  pointing to its  webroot.

3. Most importantly, the mod_jk module needed to be loaded in to apache, then only the connection between tomcat and apache works. So please verify the apache configurations files and verify the mod_jk is enabled. If not add the following details to the apache configuration file.

<IfModule !mod_jk.c>
LoadModule jk_module [modules directory]/mod_jk.so
<!–IfModule>

<IfModule mod_jk.c>
JkMount /*.cfm ajp13
JkMount /*.cfc ajp13
JkMount /*.do ajp13
JkMount /*.jsp ajp13
JkMount /*.cfchart ajp13
JkMount /*.cfm/* ajp13
JkMount /*.cfml/* ajp13
Flex Gateway Mappings
# JkMount /flex2gateway/* ajp13
JkMount /flashservices/gateway/* ajp13
JkMount /messagebroker/* ajp13
JkMountCopy all
JkLogFile [log directory]/mod_jk.log
</IfModule>

ps: Please restart the httpd service.

Tomcat 404 error

The reason mostly is Tomcat servlet “MessageBrokerServlet” is unavailable or not loaded. In that case please verify the tomcat configuration files are updated correctly as mentioned above, ie web.xml and uriworkermap.properties files. Also verify tomcat log files to find out why “MessageBrokerServlet” is not loaded. Sometimes you may need to comment “MessageBrokerServlet” in other web.xml files.

Tomcat log file location:- /opt/railo/tomcat/logs/

ps: You need to restart railo/tomcat if you made any changes to tomcat configuration files.

Joomla jos_session table crashed

You may come across the following error sometime if you are working joomla site.
jtablesession::Store Failed
DB function failed with error number 145
Table ‘./eilmccco_cmsicdc/jos_session’ is marked as crashed and should be repaired SQL=INSERT INTO jos_session ( `session_id`,`time`,`username`,`gid`,`guest`,`clie nt_id` ) VALUES ( ‘ca7331cb8a008d79e24df425257229ea’,’1227636484′,” ,’0′,’1′,’0′ )

This is a very common error. The problem with this error is that you cannot access your site nor the admin page.
The error messages means that the table “jos_session” is crashed or damaged. This table stores your session information.

This issue can be easily fixed by repairing the session table. For doing this the first thing you should do is find out your joomla database. This can be done by checking your joomla configuration.php file.
Now we can try  repairing the table in following ways.

Cpanel
If you are using the Cpanel, then you can repair you joomla database by clicking the “Repair DB” option in the Mysql section of the Cpanel.

phpMyAdmin

If you can access your database though phpMyAdmin, then on the phpMyAdmin interface, select the joomla database and look for the table “jos_session”. Once you selected the “jos_session” (tick the checkbox) and choose “Repair table” from the drop-down you find at the bottom of the list of tables.

SSH access

If you have shell access of your server, the database can be repaired within the Mysql.
Login to the mysql with necessary privileges
#mysql -u <dbuser> -p
mysql> use joomla1;                              [Assume your joomla database name is joomla1]
mysql> REPAIR TABLE jos_session;

If all the above tricks failed, then you must recreate the “jos_session” table

First of all, please take a complete backup of the joomla database.

phpMyAdmin

1 – Go to MySQL phpMyadmin Control Panel

2 – Go and click on “SQL” near the top left corner of the page, and paste the following lines (below) into the empty text area :

DROP TABLE IF EXISTS `jos_session`;
CREATE TABLE `jos_session` (
`username` varchar(150) default ”,
`time` varchar(14) default ”,
`session_id` varchar(200) NOT NULL default ‘0’,
`guest` tinyint(4) default ‘1’,
`userid` int(11) default ‘0’,
`usertype` varchar(50) default ”,
`gid` tinyint(3) unsigned NOT NULL default ‘0’,
`client_id` tinyint(3) unsigned NOT NULL default ‘0’,
`data` longtext,
PRIMARY KEY (`session_id`(64)),
KEY `whosonline` (`guest`,`usertype`),
KEY `userid` (`userid`),
KEY `time` (`time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

3 – Click on “Execute” or “Go” to execute the command.

Thats it. This must fix your concern…

Please let me know your feedback and also if you have any other easy workaround

It all started here..

Hello Techiez,

This is my first blog on WordPress… I have been working as an Linux Server Administrator for a quite some time. I know there are thousands of Very good forums and blogs regarding the Server administration or Linux and of course i am just a Newbie to the Ocean of Linux Administration. That is the exact reason why started this blog. There are lots of people like me searching and searching in those kind of Big forums but unable to find an exact answer or help. You might not be agree with you, but i knew how it works. So i  thought let’s share whatever you got, atleast try to help…

There is only one thing i can guarantee you, This would not be “Just another WordPress.com site”.

Feel free to leave some words here

Adios for now!!

Page 7 of 7

Powered by WordPress & Theme by Anders Norén