Topics

On this page

Last updated on Dec 18, 2020

Conventions & File System Layout

Important: You can use easyengine which automated WordPress-Nginx site management.

There is a famous proverb that goes like this:

A place for everything and everything in its place!

There is no denying to this. So we are devoting a dedicated page for all conventions we have used in wordpress-nginx tutorials series.

This page might feel a little boring to read. But it will help you get a grip on all the conventions used. You will definitely thank me for this when you will end-up breaking something. Because in that panic moment, this page will help you troubleshoot quickly.

File-System Layout

Please note that following layout is for Ubuntu 12.04 LTS. Most of them are default locations for respective packages. Sticking with default will save us from some trouble. On non-Ubuntu/Debian OS, some locations may vary.

Nginx

Configuration Files:

Log Files:

PHP

Configuration Files:

Log Files:

Note: You may not find following files by default. They were added in by us.

MySQL – Configuration & logs

Configuration Files:

Log Files:

Website Structure

Following is the convention we will be using for WordPress as well as non-WordPress sites.

Notes:

Few notes about the above website-structure:

  1. Following structure does not take into account shared-hosting scenarios where generally all sites for a users are located under his home directory. Something like /home/bill/www or /home/bill/public_html
  2. Subdomains are treated like domains. They reside directly under /var/www with their own htdocs and logs folder. e.g. subdomain.example.com will use directory /var/www/subdomain.example.com

Notes about access.log & error.log files for websites:

You might have noticed that you can check access.log & error.log for a domain by 2 ways – either from logs folder under domain or nginx’s log folder. There are few reasons for this kind of setup:

  1. Keeping all log files places under /var/log/nginx location make things like logrotation, disk cleanup very easy. Also, things like checking logs for all sites hosted on your nginx server or for all subdomains for a top-level domain will be easy.
  2. Site-specific log folder can make debugging easy. Also, from security perspective you may want to create a user and give him access to a specific site only. In that case we can access logs for that site (if needed)

Related: You can find the complete list of WordPress-Nginx tutorials here.

Important: You can use easyengine which automates WordPress-Nginx site management.


Comments

  1. Very nice series!
    About the “[TODO- more info on how to enable/disable nginx]”, I have a tutorial on a2ensite-like commands for nginx: http://kamalnasser.net/nginx-apache-like-server-structure/

    1. Sorry for delayed reply.

      We were working on https://github.com/rtCamp/easyengine which adds enable/disble and much more functioanlity.

      easyengine can really bring power of nginx to wordpress for just $5 (if you use DigitalOcean) 🙂

  2. Achmad Yusri Afandi Avatar
    Achmad Yusri Afandi

    Good aftenoon Sir.,

    I have problem using nginx.,
    I want to migrate from apache to nginx, but I don’t know configuration nginx for wordpress., then in my wordpress, I have “htaccess”.

    When I convert htaccess wordpress to using nginx, and when I access my website, display a message “500 Internal Server Error” ..,

    Please help me sir.

    1. Nginx doesn’t support htaccess. Try easyengine – http://rtcamp.com/easyengine . It might make your job easy!

    2. what you are missing and Rahul did not explain (this guy is busy) is you do not need to convert htaccess, you can use easyengine as it is for most of the configurations that you had in your htacess file, and if anything is missing (mostly wont by any) the community and Mr.google can help you fix it in few minutes (not more than 2 hours for sure).

  3. I have mysql already installed and the default position of the my.cnf file is /etc/my.cnf

    Mysql looks here first before looking in /etc/mysql/.

    How can I tell ee to look at /etc/my.cnf instead of /etc/mysql/my.cnf?

    Thank you in advance

    1. This is not possible from EasyEngine unless you modify it’s code.

      For now you can create a symbolic link (if you do not have `/etc/mysql/my.cnf`)

      May I know which MySQL/version and OS distro/version you are using?

      1. Thanx for the tip Rahul.
        Ubuntu 12.04, mysql 5.6.14. yes, it’s above the distro version. doh.

        cheers again

      2. Hi,

        Is ee compatible with using AWS RDS?

        Thanks.

        1. Yep. ee can run on any Ubuntu/Debian VPS/Dedicated Server/Desktop.

        2. Update: For RDS part, you need to wait till this gets completed – https://github.com/rtCamp/easyengine/issues/147

  4. khaerul zafi Avatar
    khaerul zafi

    no such file on directory cant find nginx at etc and cant find directory my site on var. where is it? thanks

    1. Sudeep Bhattacharya Avatar
      Sudeep Bhattacharya

      Support related questions are better asked on our community forums (link – https://community.easyengine.rtcampmu.rt.gw/)