Install WordPress on a server with Plesk

My blog runs on a virtual server with plesk as administration tool. Installing the blog I had some issues with file permissions. On the wordpress website you can find a tutorial to change file permissions, but it doesn’t answer all problems with a system that has Plesk installed.

At first you have to decide where to install the blog. You can choose one of your domains or a subdomain. You might have to create it and activate the PHP support before.

Now you should login to your server via SSH, which you can do with the console (or terminal) on a UNIX system or with a program like PuTTY on a windows system. When you’re connected, navigate to the httpdocs folder of your domain or subdomain you want to install the blog in. For a domain example.com the folder might be look like this:

cd /var/www/vhosts/example.com/httpdocs

The folder doesn’t always be in the vhosts folder in /var, so you have to find out, where your it is located on your server.

Afterwards you have to downoad the latest version of WordPress (in this example I used the english version);

wget http://wordpress.org/latest.zip

After downloading the file you have to extract it:

unzip latest.zip

The content of the file will be extracted to a folder called “wordpress”. If you want to serve your blog in a different folder, you should rename the folder:

mv wordpress/ blog

You’ve successfully installed WordPress. If you navigate to example.com/blog in your browser you should see the WordPress config wizzard, but you’ll not be able to create a configuration file. While extracting the files all files and folder have been assigned to the user that has extracted the files (e.g. root). To be able to access the folders with the Plesk user through FTP you have to assign the folders and files to the Plesk user. To do this navigate to the folder of the blog and then change the owner:

cd blog/
chown your_plesk_username . -R

Now you should also set the group to the Plesk default group:

chgrp psacln . -R

Even after doing all this steps you are not able to create the configuration file thourgh the WordPress setup wizzard. To run the installation you have to assign the ROOT folder of the blog to the users that runs the Apache server. To find out which user runs the Apache server, you can use the “top” command.

Output (excerpt): 3113 www-data  18   0 45400  25m 4044 S  0.0  0.5   0:18.57 apache2

This line tells you that the user www-data runs the Apache server. You can leave the top view using CTRG+C.

Now you have to assign the ROOT folder of your blog to the www-data user (the point at the end of the command is important):

chown www-data .

Now you should be able the execute the WordPress setup wizzard and you should be able to logon to our blog. But there are some additional things to do, so you can fully manage your blog through the WordPress admin panel. You have to change the permissions on the folder “cache”, “uploads”, “upgrades” and eventually on the folders “plugins” und “themes”. You have to make them writeable for the Apache user. All those folders are located in the folder “wp-content” so you can make them all writeable by changing the permissions of this folder. To be able to access those folders with the FTP user, you should assign them to the group of the Apache user:

chgrp www-data wp-content

To enable the group to change and create files, you have to change the permissions:

chmod g+w wp-content/ -R

Now your done. You have left all the default security settings of Plesk but changed all the folders that have issues with the default settings. You shouldn’t give the Apache group write access to all folder. Or even give all users permissions on all folders as some plugins ask you to.

The only limitation with this setting is the installation of plugins or themes or the upgrade of WordPress. In this cases you have to enter the FTP username and password. But if you assign all folders to the www-data user, you loose the ability to access the folders via FTP (at least the write permission). In most cases you can’t solve this problem as the www-data user is not allowed to access via FTP and you can’t change the user that runs the Apache server to the Plesk user.

If you have any problems with this solution or if you have any additional tips, I would like to read your comments.

3 comments » Write a comment

  1. Generally I do not post on blogs, but I would like to say that this post really forced me to do so, Excellent post!

Leave a Reply

Required fields are marked *.