Manual installation of WordPress on Synology NAS

WordPress can be installed as a package from within the DSM of Synology. However this comes with several limitations. Especially if one wants to install several wordpress websites on the same NAS. The Synology WordPress package only installs one instance of WordPress. Installing WordPress manually is not as straightforward as one would expect. There are several issues that need to be resolved before the WordPress site works.

Prerequirements for this quide: Your Synology NAS should run Web Station and have phpMyAdmin installed and working. Both can be installed as packages within your DSM. You need to enable SSH on the NAS and have a programme like PuTTy to make a SSH connection. 

  1. Download the latest version of WordPress from the wordpress site: https://wordpress.org/download/. Unzip the file and upload it to your Synology NAS. Most of the time this is in the folder web, which was created when you installed the package Web Station.  In this tutorial we place the WordPress files in its own folder.
  2. When you copy the wordpress files either directly or through FTP to your Synology NAS, all files receive your username and usergroup as owner of the files.  In order for WordPress to work correctly all WordPress folders and files need to have http as its owner and usergroup. This can be done by connecting to your NAS with SSH and loging in as root. Navigate to the directory of your webfiles (most of the time this is /volume1/web). Peform the following command:
    chown -R "http:http" \wordpress

    This will set the owner of the entire folder and file of the directory wordpress to http:http. Leave the SSH connection open.

  3. Next we would have to set access permisions for the files and folders of WordPress. We will use the command chmod, which means change mode. According to WordPress themselves the following settings need to be applied. For folders chmod 750 and for files chmod 640. (see: https://codex.wordpress.org/Hardening_WordPress). Perform the following SSH command:
    find /volume1/web/wordpress/ -type d -exec chmod 750 []\;

    This searches in your WordPress directory all instances of the type directory (-type d) and executes on each instance the command chmod 750. This sets the right permissions on the folders. Next we would have to set the right permissions on the files:

    find /volume1/web/wordpress/ -type f -exec chmod 640 []\;

    This searches in your WordPress directory for all instances of the type files (-type f) and executes on each instance the command chmod 640. This sets the right permission on the files. Don’t close the SSH connection but keep it open.

  4. We would now have to create the database and database access for our WordPress installation. Create the database and the user according to specifications of WordPress https://codex.wordpress.org/Installing_WordPress#Using_phpMyAdmin. In this instance with phpMyAdmin. On this page you will also find other platforms to create the database and the user.
  5. Now you can start the automated installation of WordPress. Visit http://<yourdomain or IP>/wordpress/wp-admin/install.php. This link starts the automated process of the installation.  Fill in the details you created in step 4. If everything works you should be able to log into the administration pages of WordPress. Go to Settings > Permalinks and click on Save Changes. This process creates a crucial file in the WordPress directory called .htaccess.
  6. Set the correct WordPress directory and URL. Stay logged in your administration pages and go to Settings > General and change the Site Address URL by removing /wordpress. This will enable your site to be reached by just entering the domain name but loading WordPress from the subdirectory.
  7. Copy (don’t cut) the files index.php and .htaccess from the WordPress directory to the root of your web folder. You can do this with the DSM File Station or via FTP or any other way you can copy these files.
  8. Download or open directly index.php in Wordpad and add /wordpress to the last line:
    require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );

    This enables the settings you set i step 6. Safe the file and upload it back to the root of your website overwritting the original php file.

  9. By copying and uploading the files, the ownership of the files have changed back to your username and usergroup. We would need to correct this on these two files in your root directory. Go back to your SSH connection and execute the following command:
    chown http:http .htaccess

    This changes the owner of the file .htaccess as http:http. We would need to do the same for the file index.php:

    chown http:http index.php
  10. In order for WordPress to change the file .htaccess. Its permissions have to be set as indicated by WordPress (https://codex.wordpress.org/Changing_File_Permissions). In this case .htaccess needs to have chmod 666 set. This is done in SSH:
    chmod -v 666 .htaccess

    SSH connection can be closed now.

  11. You can now visit your website and WordPress should display normally. You can login to your administration pages and you should be able to download plugins and change the permalinks.

This guide has been tested on Synology DS918+ with DSM 6.2.

Leave a Reply

Your email address will not be published. Required fields are marked *