WebFaction
Community site: login faq

I have set up a Static/CGI/PHP-5.3 app where I have only static content. I have also mod_rewrite rules in .htaccess to clear the file extensions, as in: www.mysite.com/page.html -> www.mysite.com/page

Now I have thought about setting up a static only app, for performance reasons.

First of all: is this necessary, if all static content is served by Nginx on Webfaction? This may be a stupid question, but I guess I'm not getting the difference of Static/CGI/PHP-5.3 app and static only app, if both apps would contain only static files. Speed?

If I understand correctly, Nginx has built-in rewrite rules. How can I remove the .html file extension while using Nginx? I found this tutorial, but don't really know how to use it in my case, especially when it should be used by a noob like myself.

asked 31 Dec '11, 08:34

karri
111
accept rate: 0%


Serving static files from our frontend nginx server is faster. One important reason is that nginx doesn't interprets .htaccess files as a feature.

While our nginx server is compiled with the Rewrite module, you don't have access to its configuration settings so you can't edit them to your needs.

If you want to, you can compile and run your own nginx instance in your home directory, where you can have access to it's configuration.

permanent link

answered 31 Dec '11, 09:04

iliasr ♦♦
2.0k14
accept rate: 36%

Ok. So if I use static/cgi app, I'm not able to use the benefits of Nginx in serving static content? For that, I either need to use the static only app or run my own nginx? I'm not really a programmer, so the latter sounds a bit difficult.

(31 Dec '11, 09:35) karri

Yes, if you want both nginx's performance and the abilty to write your own re-write rules, you need to roll out your own.

It's actually easier than it sounds. You need a create a custom applicaton, which will reserve a network port for you, and then download the latest stable nginx source, untar it, traverse to it's directory and run:

./configure --prefix=$HOME make make install

Finaly you need to edit it's configuration file to listen to the reserved port instead of port 80 and restart it for the change to take effect.

The article I've referred you above has more details and nginx's wiki is also a valuable asset, but if you encounter any issues you can always open a support ticket here

(31 Dec '11, 09:46) iliasr ♦♦

Okay, I installed now Nginx. This guy had instructions for installing Nginx specificly on WebFaction, of course I used the the newer latest version of Nginx.

So is that all I have to do? Now even static files in the static/cgi/php app are served by Nginx, right?

(31 Dec '11, 10:51) karri

You should now be able to link your custom nginx application with a website entry and make it accessible from the web.

Your instance will be serving it's default page untill you move your static content in the document root folder (the html directory by default). It's not serving any php scripts, only static content, like html files, images, css and javascript files.

When you've verified that you are serving your content, you can move on to defining your rewrite rules in your configuration file. There many examples here.

Please note that you need to reload your application each time you make a change.

Finally, when you've done everything and verified that all is working as you please, you can use a benchmarking tool like ab to test the performance of both our shared apache server, our own nginx frontend, your own instance, and make your own conclusions.

(31 Dec '11, 11:16) iliasr ♦♦

How I link my custom nginx app with my website? With website entry and making it accessible from the web, you mean...?

I can see the html directory at the root. I'll move now my static content there.

How can I reboot the application? The instructions (see my previous message) said, I could reboot nginx from the shell, but the command cd ~/webapps/nginx and then ./sbin/nginx did not work for me. It says no such file or directory.

(31 Dec '11, 11:46) karri
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×185
×30
×13
×10

question asked: 31 Dec '11, 08:34

question was seen: 3,941 times

last updated: 31 Dec '11, 11:46

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM