{"id":760,"date":"2021-04-25T10:15:13","date_gmt":"2021-04-25T09:15:13","guid":{"rendered":"http:\/\/laserphotonics.uk\/?p=760"},"modified":"2021-04-25T10:15:15","modified_gmt":"2021-04-25T09:15:15","slug":"running-multiple-wordpress-sites-on-a-synology-device","status":"publish","type":"post","link":"https:\/\/laserphotonics.uk\/?p=760","title":{"rendered":"Running Multiple WordPress Sites On A Synology Device"},"content":{"rendered":"\n<h4>https:\/\/christophermay.dev\/2019\/11\/28\/running-multiple-wordpress-sites-on-synology\/<\/h4>\n\n\n\n<p><\/p>\n\n\n\n<p>This tutorial is all about dev work. Specifically, running multiple wordpress instances as a way to keep projects separated as well as testing in a non-live environment. Synology makes this easy. Let me show you how.<\/p>\n\n\n\n<p>First of all, allow me to preface this by saying there are a few ways you could go about trying to achieve this. The route I chose allows access outside the localhost\/local area network via the Synology dynamic DNS service. I\u2019m not interested in serving sites via my local machine to the outside network beyond personal access for public use, so i\u2019m not going to be covering redirects or proxies, or any other advanced routing today. I would not recommend serving sites to the wider public via your personal machines. This is simply an easy way of accessing development sites when outside of the network, for personal use only.<\/p>\n\n\n\n<h2>Step 1: Getting Prepared<\/h2>\n\n\n\n<p>We need to download WordPress, and get our folders setup. First head over to&nbsp;<a href=\"https:\/\/wordpress.org\/download\/\">https:\/\/wordpress.org\/download\/<\/a>&nbsp;and download it to your computer. I\u2019m using version 5.3, but your version may be different. Once downloaded, login to your disk station and copy the entire zip archive to your web folder. Unzip it inside your web folder. If you do not have a web folder it\u2019s because you have not yet setup webstation. Make sure you have webstation running, as well as php, mariaDB, and phpMyAdmin.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/i1.wp.com\/christophermay.dev\/wp-content\/uploads\/2019\/12\/Inked1_LI.jpg?fit=800%2C593&amp;ssl=1\" alt=\"\"\/><\/figure>\n\n\n\n<h2>Step 2: Adjusting The Settings<\/h2>\n\n\n\n<p>Next you are going to want to create a new folder for the site you are working on. I\u2019m calling mine \u201cwoocommerce\u201d. Copy all the files from your unziped WordPress 5.3 archive and paste them into the new project folder you created.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/i1.wp.com\/christophermay.dev\/wp-content\/uploads\/2019\/12\/InkedInked3_LI.jpg?fit=800%2C598&amp;ssl=1\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now that everything has been prepared, we can tweak our file settings and get the database running. If you try to run WordPress at this point, you\u2019re going to get some serious errors. The first thing we need to do is get our \u201cwp-config.php\u201d file ready.<\/p>\n\n\n\n<h2>wp-config.php<\/h2>\n\n\n\n<p>\/**<br>* The base configuration for WordPress<br>*<br>* The wp-config.php creation script uses this file during the<br>* installation. You don\u2019t have to use the web site, you can<br>* copy this file to \u201cwp-config.php\u201d and fill in the values.<br>*<br>* This file contains the following configurations:<br>*<br>* * MySQL settings<br>* * Secret keys<br>* * Database table prefix<br>* * ABSPATH<br>*<br>* @link https:\/\/codex.wordpress.org\/Editing_wp-config.php<br>*<br>* @package WordPress<br>*\/<\/p>\n\n\n\n<p>\/\/ ** MySQL settings \u2013 You can get this info from your web host ** \/\/<br>\/** The name of the database for WordPress *\/<br>define( \u2018DB_NAME\u2019, \u2018woocommerce\u2019 );<\/p>\n\n\n\n<p>\/** MySQL database username *\/<br>define( \u2018DB_USER\u2019, \u2018wordpress_user\u2019 );<\/p>\n\n\n\n<p>\/** MySQL database password *\/<br>define( \u2018DB_PASSWORD\u2019, \u2018password\u2019 );<\/p>\n\n\n\n<p>\/** MySQL hostname *\/<br>define( \u2018DB_HOST\u2019, \u2018localhost:\/run\/mysqld\/mysqld10.sock\u2019 );<\/p>\n\n\n\n<p>\/** Database Charset to use in creating database tables. *\/<br>define( \u2018DB_CHARSET\u2019, \u2018utf8\u2019 );<\/p>\n\n\n\n<p>\/** The Database Collate type. Don\u2019t change this if in doubt. *\/<br>define( \u2018DB_COLLATE\u2019, \u201d );<\/p>\n\n\n\n<p>\/**#@+<br>* Authentication Unique Keys and Salts.<br>*<br>* Change these to different unique phrases!<br>* You can generate these using the {@link https:\/\/api.wordpress.org\/secret-key\/1.1\/salt\/ WordPress.org secret-key service}<br>* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.<br>*<br>* @since 2.6.0<br>*\/<br>define(\u2018AUTH_KEY\u2019, \u2018XXX\u2019);<br>define(\u2018SECURE_AUTH_KEY\u2019, \u2018XXX\u2019);<br>define(\u2018LOGGED_IN_KEY\u2019, \u2018XXX\u2019);<br>define(\u2018NONCE_KEY\u2019, \u2018XXX\u2019);<br>define(\u2018AUTH_SALT\u2019, \u2018XXX\u2019);<br>define(\u2018SECURE_AUTH_SALT\u2019, \u2018XXX\u2019);<br>define(\u2018LOGGED_IN_SALT\u2019, \u2018XXX\u2019);<br>define(\u2018NONCE_SALT\u2019, \u2018XXX\u2019);<br>\/**#@-*\/<\/p>\n\n\n\n<p>\/**<br>* WordPress Database Table prefix.<br>*<br>* You can have multiple installations in one database if you give each<br>* a unique prefix. Only numbers, letters, and underscores please!<br>*\/<br>$table_prefix = \u2018XX_\u2019;<\/p>\n\n\n\n<p>\/**<br>* For developers: WordPress debugging mode.<br>*<br>* Change this to true to enable the display of notices during development.<br>* It is strongly recommended that plugin and theme developers use WP_DEBUG<br>* in their development environments.<br>*<br>* For information on other constants that can be used for debugging,<br>* visit the Codex.<br>*<br>* @link https:\/\/codex.wordpress.org\/Debugging_in_WordPress<br>*\/<br>define( \u2018WP_DEBUG\u2019, false );<br>define( \u2018FS_METHOD\u2019, \u2018direct\u2019 );<br>\/* That\u2019s all, stop editing! Happy publishing. *\/<\/p>\n\n\n\n<p>$pageURL = \u2018http\u2019;<br>if ($_SERVER[\u201cHTTPS\u201d] == \u201con\u201d) {$pageURL .= \u201cs\u201d;}<br>$pageURL .= \u201c:\/\/\u201d;<br>if ($_SERVER[\u201cSERVER_PORT\u201d] != \u201c80\u201d and $_SERVER[\u201cSERVER_PORT\u201d] != \u201c443\u201d) {<br>$pageURL .= $_SERVER[\u201cSERVER_NAME\u201d].\u201d:\u201d.$_SERVER[\u201cSERVER_PORT\u201d];<br>} else {<br>$pageURL .= $_SERVER[\u201cSERVER_NAME\u201d];<br>}<\/p>\n\n\n\n<p>if ($_SERVER[\u201cHOST\u201d] != \u201c\u201d) {<br>define(\u2018WP_SITEURL\u2019, $pageURL);<br>} else {<br>define(\u2018WP_SITEURL\u2019, $pageURL.\u2019\/woocommerce\u2019);<br>}<\/p>\n\n\n\n<p>if (!defined(\u2018SYNOWORDPRESS\u2019))<br>define(\u2018SYNOWORDPRESS\u2019, \u2018Synology Inc.\u2019);<\/p>\n\n\n\n<p>\/** Absolute path to the WordPress directory. *\/<br>if ( ! defined( \u2018ABSPATH\u2019 ) ) {<br>define( \u2018ABSPATH\u2019, dirname( __FILE__ ) . \u2018\/\u2019 );<br>}<\/p>\n\n\n\n<p>\/** Sets up WordPress vars and included files. *\/<br>require_once( ABSPATH . \u2018wp-settings.php\u2019 );<\/p>\n\n\n\n<p>\/**require_once( ABSPATH . \u2018syno-misc.php\u2019 ); *\/<\/p>\n\n\n\n<p>define( \u2018AUTOMATIC_UPDATER_DISABLED\u2019, true );<br>\/** add_filter(\u2018pre_site_transient_update_core\u2019,\u2019__return_null\u2019); *\/<\/p>\n\n\n\n<p>Create a database username and type it into the line labeled \u201cdefine( \u2018DB_USER\u2019, \u2018XXXXXXXXXX\u2019 );\u201d, replacing the X\u2019s with your chosen name. Also choose a password for the password line directly below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/i1.wp.com\/christophermay.dev\/wp-content\/uploads\/2019\/12\/Inked4_LI.jpg?fit=800%2C436&amp;ssl=1\" alt=\"\"\/><\/figure>\n\n\n\n<p>At the bottom of the above screenshot you see a block of code with a large blank space. This is where you need to paste your secret-key. You can generate a key for this file at the link below. Just follow the link, copy the code and then paste it into your config file.<\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/api.wordpress.org\/secret-key\/1.1\/salt\n<\/div><\/figure>\n\n\n\n<p>In addition to the above edits, we will also need to change the line labeled \u201c$table_prefix = \u2018XXXX\u2019;\u201d to something unique, keep it short. You will also want to change the line labeled \u201cdefine(\u2018WP_SITEURL\u2019, $pageURL.\u2019\/woocommerce\u2019);\u201d Replace woocommerce with whatever you named your site folder inside the web folder.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/i1.wp.com\/christophermay.dev\/wp-content\/uploads\/2019\/12\/Inked5_LI.jpg?fit=800%2C421&amp;ssl=1\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now that we\u2019ve got the config file setup, we can turn our attention to the .htaccess file.<\/p>\n\n\n\n<h2>.htaccess<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># Synology PHP\nAddHandler default-handler .htm .html .shtml\nAddHandler php-fastcgi .php\nAddType text\/html .php\nAction php-fastcgi \/php56-fpm-handler.fcgi\n# Synology PHP\n\n# BEGIN WordPress\n# The directives (lines) between `BEGIN WordPress` and `END WordPress` are\n# dynamically generated, and should only be modified via WordPress filters.\n# Any changes to the directives between these markers will be overwritten.\n\nRewriteEngine On\nRewriteBase \/woocommerce\/\nRewriteRule ^index\\.php$ - [L]\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . \/woocommerce\/index.php [L]\n\n\n# END WordPress<\/code><\/pre>\n\n\n\n<p>We just need to update two spots in red with the folder name of our project. Again, in my project that was \u201cwoocommerce\u201d. Paste both of these modified text files in the folder with the rest of your WordPress files.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/i0.wp.com\/christophermay.dev\/wp-content\/uploads\/2019\/12\/Inked6_LI.jpg?fit=800%2C598&amp;ssl=1\" alt=\"\"\/><\/figure>\n\n\n\n<h2>Step 3: Create Database<\/h2>\n\n\n\n<p>We need to create a database for the WordPress server to store data, including users, posts, and whatever else you create for your site. Setting up Maria DB 10 and phpMyAdmin is not the purpose of this tutorial, so i\u2019m going assume you already know how to do that and have already set both up. Upon logging into phpMyAdmin, you need to create a new database by pressing the \u201cNew button on the left hand side of the screen. This will bring you to the Databases screen where you can enter a name for your new database, and then press the create button. Your new database is now created.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><\/pre>\n\n\n\n<p>Next you are going to want to go to the User accounts screen which can be accessed from menu bar along the top of the screen. From this screen you may either create a new user for your database, or re-use another user you have already created.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/i0.wp.com\/christophermay.dev\/wp-content\/uploads\/2019\/12\/InkedInked7_LI.jpg?fit=800%2C334&amp;ssl=1\" alt=\"\"\/><\/figure>\n\n\n\n<p>That\u2019s it, you should now be ready to use your new site if you did everything correctly. Now navigate to your synology\u2019s webstation address (for me, this is https:\/\/myname.synology.me\/woocommerce). There are many domain options available through the synology DDNS system, so yours may differ from mine. You can repeat these steps as many times as you\u2019d like for as many instances of WordPress as you\u2019d like, just create a new folder for each site you want to create.\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/christophermay.dev\/2019\/11\/28\/running-multiple-wordpress-sites-on-synology\/ This tutorial is all about dev work. Specifically, running multiple wordpress instances as a way to keep projects separated as well as testing in a non-live environment. Synology makes this easy. Let me show you how. First of all, allow me to preface this by saying there are a few ways you could go [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/laserphotonics.uk\/index.php?rest_route=\/wp\/v2\/posts\/760"}],"collection":[{"href":"https:\/\/laserphotonics.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laserphotonics.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laserphotonics.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laserphotonics.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=760"}],"version-history":[{"count":1,"href":"https:\/\/laserphotonics.uk\/index.php?rest_route=\/wp\/v2\/posts\/760\/revisions"}],"predecessor-version":[{"id":761,"href":"https:\/\/laserphotonics.uk\/index.php?rest_route=\/wp\/v2\/posts\/760\/revisions\/761"}],"wp:attachment":[{"href":"https:\/\/laserphotonics.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laserphotonics.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laserphotonics.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}