Install Wordpress on Subdirectory


#1

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

Please help me.


#2

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: https://github.com/EasyEngine/easyengine/issues/31


#3

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: mysite.example.com -> change the nginx config file -> example.com/mysite

Can you please mention steps to follow.


#4

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.


#5

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.


#6

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.


#7

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


#8

No worries, thats why we are around for.

Start using this command: ee site create yourwebsite.com --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/yourwebsite.com/htdocs/ and paste the following: wget https://wordpress.org/latest.zip unzip latest.zip

A newly created folder, named ‘wordpress’ will appear. Feel free to delete the latest.zip 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/yourdomain.com file using nano (or your favorite text editor) and add the proper code for the subdirectory rewrite.

This URL might help you: https://github.com/EasyEngine/easyengine/issues/31

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

Once you do so, visit http://yourdomain.com/yoursubdir 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:


Install a separate wordpress in subfolder
#9

Start using this command: ee site create yourwebsite.com --mysql

Can I create the site on subdomain ?


#10

Yes, you can use any variant of ‘create’ command of EE, found here: https://easyengine.io/docs/commands/site/create/


#11

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.


#12

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.


#13

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;
}


#14