Install Wordpress on Subdirectory

I want to install Wordpress ( not multisite ) in subdirectory ! ex: I search a way using this forum. Some posts are old. But still I cannot find a way.

Please help me.

By default, EE doesnt support a subdirectory (not sub domain) creation in its commands.

You can install it for a domain name and have your nginx config file edited accordingly. Check this github issue:

Hi !

I’m not developer…

If I want install on subdirectory ! I can install it on subdomain and change the nginx config file. Is that right ?

ex: -> change the nginx config file ->

Can you please mention steps to follow.

Then, Im afraid that EE’s auto way of installing WordPress might not be the best solution for you. Apart from the nginx config, you will need also to edit your WordPress database for your new URL, preserving serialized data etc.

I’m not a developer but I’m a student.

I already install wordpress site on one of my domain name using EE wordpress Now I want to install second wordpress site on subdirectory.

Please help.

As mentioned before, by default, EE doesnt support a subdirectory (not sub domain) creation in its commands, so unfortunately, you wont be able to install the subdirectory with the same ease you installed the domain one.

There is no auto way to do this with EE at the moment, so consider hiring a developer/sysops admin for this task.

Generally speaking, in your case, I would create a database through EE’s tools (PMA), I would create a simple PHP site using create command of EE and then I would create a subdirectory in which I would extract WordPress in.

Then I would edit nginx config and apply a rewrite subdirectory rule in server’s config.

The last step would be to visit WordPress’ subdir through my browser and complete the subdir installation, using the previously created database’s credentials.

thanks for the help and take your time to write answers ! I will try this now ! thanks again !

No worries, thats why we are around for.

Start using this command: ee site create --mysql

It will return usefull information regarding your MySQL created user/database and your newly created domain. Save them, you will need them.

Now navigate to /var/www/ and paste the following: wget unzip

A newly created folder, named ‘wordpress’ will appear. Feel free to delete the file and rename ‘wordpress’ to your preferred subdirectory name.

Now, there is a harder part. The one that needs a rewrite rule for your subdirectory. Edit /etc/nginx/sites-enabled/ file using nano (or your favorite text editor) and add the proper code for the subdirectory rewrite.

This URL might help you:

Now, you need to reload nginx’s saved config. Use this command: service nginx reload

Once you do so, visit through browser and start the famous auto-installer of WordPress.

You will be asked for credentials of database. Enter the previously saved ones and voila, everything should be more than fine :slight_smile:

Start using this command: ee site create --mysql

Can I create the site on subdomain ?

Yes, you can use any variant of ‘create’ command of EE, found here:

set $dir “”; if ($request_uri ~ ^/([^/])/.$ ) { set $dir1 /$1; } location / { try_files $uri $uri/ $dir1/index.php?$args; }

In above code … is anywhere I have to change according my subdirectory name ?

ex: $dir1 -> mysite

Because when I got reload the nginx

I got following error

Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.

You need to change $dir1 to $yoursubfoldersname , everywhere.

Do what the info message suggests: See systemctl status nginx.service" and “journalctl -xe” for details. And fix the issues.

You probably paste the code in a wrong part of the config.

Pasting output of journalctl and your vhost’s config is the easy way to get help from me or another member in here, however, following the way I mentioned previously will help you self-train on devops issues.

Always use the command nginx -t to check your configuration before using service nginx reload.

About wordpress in subdirectory, easyengine support multisite install in subdirectory. By checking the configuration file, it use this configuration :

if (!-e $request_filename) {
  # Redirect wp-admin to wp-admin/
  rewrite /wp-admin$ $scheme://$host$uri/ permanent;
  # Redirect wp-* files/folders
  rewrite ^(/[^/]+)?(/wp-.*) $2 last;
  # Redirect other php files
  rewrite ^(/[^/]+)?(/.*\.php) $2 last;