Sunday, December 15, 2013

How to enable your web application in your home laptop/pc to be assessible from public network?

To enable my web application that installed on my home laptop/pc to be accessible from public network, below are the steps of what I have gone through to get it working.

Assume that you have created an account at http://freedns.afraid.org/
- Create subdomains
- Install FreeDNS Update client at your laptop/pc

Assume that you are using SingTel service provider as what I am.
Note: SingTel is blocking port 80, your Apache Web Server should listening to other port, I configured my Apache Web Server to listen to port 81.

Assume that you have configured static IP address in your laptop/pc

Below are the steps to configure the port forwarding at your router
1.  Type in http://192.168.1.254 in your browser access the router configuration interface.
2. Click on "Security" -> "NAT and Port Forwarding"
3. Click on "Add a Port Forwarding Rule"
4. Edit the "Application" name
5. Edit the "Source Port" as 81, since port 80 is being blocked
6. "Destination IP" as the laptop/PC fixed IP address.
7. "Destination Port" as 81
8. Click on "Ok" button

Access from public network with your subdomain configured at FreeDNS, you should be able to access your web server.

Friday, December 13, 2013

How to import MySql dump with big blob field?

Error message "Error Code: 2006 - MySQL server has gone away" is prompted when trying to import MySql database dump consists of big blob field value into MySql database.

Below are the steps to resolve this issue
1. Edit max_allowed_packet parameter in my.ini
max_allowed_packet = 524288000
2. Restart MySql database server
Assume the parameters below represent 
Database user id, for example, 'root' : [DB_USER_LOGIN] 
Database dump file : [DB_DUMP_FILE] 
Database name : [DATABASE_NAME]

3. Connect to database
mysql -u[DB_USER_LOGIN]
4. Use the new database that created for importing
use [DATABASE_NAME]
5. Import the data from database dump into newly created database.
\. [DB_DUMP_FILE]

Saturday, November 30, 2013

How to configure db_link on Postgres database to pull data from other database?

I have 2 databases that running on the same database server, but, I have requirement to create a query to join data from the 2 databases. To achieve that, I have to configure db_link in my database server.

Assume the 2 databases are being named as dbA and dbB and the connection are from dbA
dbB User ID: [USER_ID]
dbB Password: [PASSWORD]


To enable db_link, run the command below to enable db_link function
psql -U postgres
postgres=# CREATE EXTENSION dblink
To list the installed extension, type in the command as described below
postgres=# \dx
Below are the sample command that to select data from dbB
SELECT events.* FROM dblink('dbname=dbB user=[USER_ID] password=[PASSWORD]','SELECT title FROM events') AS events(title character varying(255));


Friday, November 8, 2013

How to get your phing to print out timestamp within your timezone?

Try to get the phing scripts below to echo the right timestamp but always unable to do so. The printed timestamp always based on the UTC timestamp.

    <tstamp>
        <format pattern="%Y%m%d_%H%M%S" property="build.time">  
    </format></tstamp>

 <target name="tstamp"> 
  <tstamp>
  <echo>build time = ${build.time}</echo> 
 </tstamp></target>
Initially, I thought this was phing issue, put the locale attributes insides 'format pattern="%Y%m%d_%H%M%S" property="build.time" locale="Asia/Singapore"', but it doesn't solve the issue.
Spent quite a long time to find the root cause, finally, got the clue on what was happening.

Open the php.ini that your PHP is referring to, edit the locale as your current timezone. For other timezone, please refer to http://us1.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = Asia/Singapore
Rerun your phing with the same piece of code. Voila! it just work like a charm!

Wednesday, November 6, 2013

How to resolve "Could not open configuration file /etc/httpd/conf/httpd.conf: Permission denied" when start httpd service on RHEL 6?

I encounter this when I transfer (scp) httpd.conf file from my local machine to my new RHEL 6 server. I overwrote the httpd.conf file at /etc/httpd/conf directory and restart httpd service through "service httpd restart". Error message  "Could not open configuration file /etc/httpd/conf/httpd.conf: Permission denied" is prompted.

Type in the command below,
ls -Z
Output as described below is displayed
-rw-rw-r--. user1     user1      unconfined_u:object_r:user_home_t:s0 httpd.conf
-rw-r--r--. root       root       system_u:object_r:httpd_config_t:s0 magic
Steps to resolve this

1. Run the command below to change "unconfined_u:object_r:user_home_t:s0" to "system_u:object_r:httpd_config_t:s0".
chcon system_u:object_r:httpd_config_t:s0 httpd.conf
Once restart httpd service, it should be able to restart the apache service now.

2. For the sake of change the ownership correctly, you can run command below to change the owner
chown root:root httpd.conf
chmod 644 httpd.conf



Sunday, October 27, 2013

not working in PHP 5.3.3

Redeploy my app on WAMP that aare running on PHP version 5.3.3, out of sudden, discover my old code that use is not working. All my pages suddenly display "?>" or ">" characters everywhere in my web page.

Search through the web and finally got the solution:-

Open php.ini, set "short_open_tag" to "On" value as described below

short_open_tag = On
Restart your webserver, everything will be working fine now.

Saturday, October 19, 2013

How to resolve "You don't have administrator rights! freeSSHd will close!" error message while launch freeSSHd?

Setup SSH server using freeSSHd 1.2.6 on my machine running on Window 7. Error message "You don't have administrator rights! freeSSHd will close!" keep prompting when the app is launched.


Below are the steps to resolve this issue
1. Download OllyDbg from http://ollydbg.de/. Launch the app


2. Open "FreeSSHDService.exe" as displayed in the screenshot below.
Note: The file located at the FreeSSHd installation folder


3. Press Ctrl+G and search for address "0041312A"



4. Right click on the selected "0041312A" address, select "Binary" -> "Edit" menu.


5. Change "HEX +00" field value from "74 49" to "90 90". Click on Ok button.


6. Right click on the modified address, select "Copy to executable" -> "Selection" menu.


7. A new exe will be generated. Right click on any boundaries of the window,select "Save File" menu.



8. Overwrite the existing "FreeSSHDService.exe", launch the app, you can find FreeSSHD icon in the system tray..