How to Install WordPress core in a Subdirectory using Composer ?

We all like WordPress, but personally I do not want to see all the main WordPress core files in the root of the site, because if manages multiple WordPress sites on the same web server, it is important to keep organized your installs, it looks messy and unprofessional or you may not want to install WordPress at the root of your website. In any case, fortunately, WordPress gives us the flexibility to install the WordPress core in a custom subdirectory. This adjustment gives us more security and also to avoid frequent pitfalls.

There are many ways to implement WordPress core in a Subdirectory, but WordPress itself has a great article on the Codex “Giving WordPress Its Own Directory”, but I thought do something a bit different with composer’s dependencies. In the last article, I explained the method of installing the composer and how to use it for WordPress Plugin and themes.

Please follow below example setup I am doing in my local environment with configuration Apache 2.4.18,PHP 7.0.22,MySQL 5.7.20 and Ubuntu 16.04.1, here i am creating a sitename as “scriphere” folder.

Video Tutorial

Here is the sample source code for “Install WordPress core in a Subdirectory using Composer”, If you do not like the video or if you need other steps, please continue reading.

1.Create a “script here” directory in your local host’s root directory.

2.Next, copy “composer.json” file to the application root folder (Ex: scripthere).

3.Next, open a terminal and go application path and run composer install a couple of times.

4.Next, open the index.php file of the application and set the WordPress “core” path.

5.Next, open the “wp-config.php” file of the application and make settings such as database, vendor, content path, plugin, theme path etc.

6.Next, go to browser and start the installation with your application url , example @http://localhost/scripthere/

7.Next, login as admin the application and set permalink settings as “/%postname%/” and save, @http://localhost/scripthere/core/wp-admin/options-permalink.php

8.That’s all your done, now you can able browse the site in the root (i.e @http: //localhost/scripthere/) even installed WordPress core in a subdirectory, make sure when you’re going to access admin we need to include the “core” in the url (i.e @http: //localhost/scripthere/core/wp-login.php).

Hopefully, this article gives you a great idea about the different directory structures, allowing you to enable another variation separated by the installation. Please Subscribe to ScriptHere.Com by Email. You can also find us on Facebook and Twitter. What is your beloved WordPress installation setup ? Please tell me the following comments.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.