“Error – Unable to write preferences file”, “Syntax error! Apache has not been designed to serve pages while running as root”
The DesktopServer preferences file stores information about your websites including the correct “webOwner” for the server to run correctly. It is important that “webOwner” matches your system username. It is also important that the preferences file has correct ownership and permissions to function correctly on Macintosh operating systems. Here is how to correct the file if the permissions and “webOwner” are incorrect. These instructions only apply to Macintosh operating systems.
This document describes how you may modify permission settings by entering commands in the Terminal application. Users unfamiliar with Terminal and UNIX-style environments should proceed with caution. The entry of incorrect commands may result in data loss and/or unusable system software. Improper alteration of permissions can result in reduced system security and/or exposure of private data.
If you receive one of the following issues: An error message indicating “Error – Unable to write preferences file”, “Syntax error! Apache has not been designed to serve pages while running as root”.
This issue can occur if you have migrated your system from another computer, have changed your login username or account, or have experienced another type of file/disk permissions issue or upgrade failure.
First, you should change the ownership of your hidden preferences file to your correct username. Note: this requires that you run the following commands precisely on the command line. Here is how:
- Start your Terminal.app application from your /Applications/Utilities folder.
- Type the following command, followed by pressing the return key to determine your username (write this down):
- Next, carefully type the following command on one line. Replace username with the username you determined from the command above and press the return key (you will be prompted for your Macintosh login password):
- You can now quit the Terminal.app application (via the pull down menu).
sudo chown username:staff /Users/Shared/.com.serverpress.desktopserver.json
Next, you will want to verify and edit the preferences file and change the “webOwner” to your username. In the image to the left, the username for “webOwner” is “johnsmith”. In some cases, this might be set to “root” or to an incorrect username. Please be sure to replace this value within quotes with the username you obtained from the whoami command above. The preferences file is hidden but can be edited using Text Edit or Text Wrangler. Please click here for information on how to open the preferences file.