KatPadi's Point

WordPress x NGINX

After being a complete pain in the ass, I was finally able to make both my blog.katpadi.ph and katpadi.ph work!

WordPress x NGINX, bitch!

Here are the things I learned (the hard way):

The magic happens inside the “sites-available” directory. A file called “default” (it can be named anything) has the important stuff to be able to serve a web page/site. For every server block, the following definitions are needed:

The “root” directive:
This defines the directory location of the contents of the website. Nginx will look for the files to serve in the browser.

The “server_name” directive:
You should put here the domains that will show the website. Define things like whatever.com or hello.whatever.com here.

The line “location /”:
The “location /” specifies that the directives within the brackets will apply to all resources requested by the client that do not match other location blocks.

The try_files:
Try files look something like this:

try_files $uri $uri/ /index.html;

It attempts to serve a request through a series of alternative options. For example, it will first check if $uri exists. If it does, it will serve it. If not, it will try to serve $uri/ and then index.html.

I saved the config I used in Gist.

It took a me a week or so to get my everything migrated to VPS. This part’s the hardest because I’m used to Apache.

I’ve asked several “experts” for help but in the end I was able to solve all the headache-y stuff. Thanks to Google and StackOverflow.

Anyway, config struggle solved.

WordPress x NGINX

Photo c/o Mazhar (http://bornvirtual.com)

Now, off to making a mail server, or whatever…after work or whenever.

Leave a Reply

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