How to Change the Port on NX Server

NX Server is a commercial application released by the company NoMachine. It allows you to connect to your Linux server similar to how you would connect to a Windows computer using remote desktop. NoMachine offers a free version of the product which has a restriction of only allowing 2 simultaneous connections to the server. NX Server runs over SSH so you don’t need to open any other ports on your firewall other than the port for the SSH service.

It is considered a good security practice to change the default port the SSH service listens on. When you change this port it breaks the NX Server service since it expects the SSH service to be running on the default port of 22. You can fix NX Server by modyfing the following file:

/usr/NX/etc/server.cfg

Set the following settings in the file:

SSHDPort = "22"
SSHDAuthPort = "22"

Change “22” to whatever port your SSH service is now listening on. You’ll then need to restart the NX Server service to put the changes into effect:

/etc/init.d/nxserver restart

NOTE: The instructions above were tested on a Linux Red Hat 5 server.

How to Query Multiple Databases in PHP

You can perform a SQL query against more than one database with PHP. Here is a sample generic SQL query against two databases:

SELECT image.image_title, greetings.date
FROM db1.image, db2.greetings
WHERE greetings.image_id=image.imageid

And here is some PHP sample code on how you would query two databases in a single SQL statement:

$query="INSERT INTO db1.table1 SELECT * FROM db2.table2 WHERE a=1";
mysql_query($query,$connection);

VSFTPD Error “500 OOPS: reading non-root config file”

After setting up a new Linux server I kept getting the following error whenever I tried to upload something with the VSFTPD ftp service:

500 OOPS: reading non-root config file

It turns out that I had the following setting in the /etc/vsftpd/vsftpd.conf file:

user_config_dir=/etc/vsftpd/virtual_users

I commented out that setting and restarted the vsftpd service and the problem went away. I then checked to make sure I had spelled the “user_config_dir” directory name correctly and it turns out that I had created the directory with the name “virtual_user” without the “s” at the end. So that error appears to be caused by the “user_config_dir” not being present or accessible to the VSFTPD service. If you get this error make sure the directory you specify for the “user_config_dir” exists and is accessible.

How to Enable Open Directory Debugging

By default the MacOS X Open Directory debugging log file is disabled. You can temporarily reenable it by running the following command in the Terminal app:

sudo killall -USR1 DirectoryService

After you reboot, debugging will be disabled again. If you want to enable Open Directory debugging so that it stays enabled across reboots, run the following command in the Terminal app:

touch /Library/Preferences/DirectoryService/.DSLogAtStart

To disable debugging again just delete that file:

sudo rm /Library/Preferences/DirectoryService/.DSLogAtStart

The debugging log file is located at:

/Library/Logs/DirectoryService/DirectoryService.debug.log