News for hackers. Stuff that matters.
Re:How my life was changed when I began caring about the peo... by FooBarWidget on Thursday January 08, 2015 @05:34PM (#8859491)
My Wordpress blog used to go down because of HN. I fixed that as follows.

1. Use the Wordpress supercache plugin.

2. Put Apache behind Nginx, and limit the number of Apache processes to ~6. This way you're effectively using Apache as a "PHP app server", simulating an architecture similar to Passenger/Unicorn. Nginx acts only as a buffering reverse proxy, shielding Apache from slow clients.

Why this instead of running Wordpress/PHP through Nginx using php-fpm? It's because Apache is just easier: mod_rewrite rules work automatically, etc.

Re:How my life was changed when I began caring about the peo... by smacktoward on Thursday January 08, 2015 @05:45PM (#8859546)
I'm not even sure step 2 is necessary, my WP blog has hit HN a few times and the supercache plugin alone has been more than sufficient to handle it.

Really the big problem at this point is that stock WordPress falling over under even moderate traffic is such a common experience that having caching broken out into an optional plugin doesn't make a whole lot of sense. WP should probably ship with at least a basic caching solution built in.

Re:How my life was changed when I began caring about the peo... by nilved on Thursday January 08, 2015 @05:45PM (#8859543)
This is first time I've seen the words "Apache is just easier" in that arrangement. I think php-fpm is significantly easier to set up than Apache and expect it to be more performant with less resources.
Re:How my life was changed when I began caring about the peo... by okaram on Thursday January 08, 2015 @08:42PM (#8860253)
This probably depends more on experience, and which OS/platform you're using; although I don't do it a lot, I've configured Apache servers several dozen times, whereas I've only done nginx a couple of times, so it is 'easier' for me.

Also, on ubuntu (and centos, but haven't used it in a while), it is something like 'apt-get install apache-mod-php' and everything is there :)

Re:How my life was changed when I began caring about the peo... by InclinedPlane on Thursday January 08, 2015 @08:43PM (#8860257)
Yup. I've been running nginx + php-fpm for pretty much as long as it's been possible, and it's pretty great with far less hassle than most other configs.
Re:How my life was changed when I began caring about the peo... by mjevans on Thursday January 08, 2015 @10:43PM (#8860631)
It's easier for things that are written in broken ways that work best with Apache because that's the only platform they targeted.
Re:How my life was changed when I began caring about the peo... by Encosia on Thursday January 08, 2015 @06:42PM (#8859795)
Caching HTML to disk via W3 Total Cache or WP Super Cache is really all you need on most hosting. I never got around to putting Apache behind nginx, but have still survived some relatively large traffic spikes for a personal blog (e.g. 100k+ page views in a few hours) without any trouble at all.

Not to say that your setup isn't better (it obviously is), but I want to make sure no one's intimidated by the task of hardening their WP install because they think they'll need to do both 1 and 2 for it to be worthwhile.

Re:How my life was changed when I began caring about the peo... by JeremyMorgan on Thursday January 08, 2015 @05:41PM (#8859525)
Never configured Apache that way, that sounds really interesting. I was running the site on a fairly well tuned LEMP stack and was using a cache plugin (forgot the name) but it would still choke fairly often.

Since the content of my site only changes a couple times a month I started migrating away from towards a static solution. I'm not trying to say WP is bad but I think if your content is relatively static and you aren't doing a ton of updating, just make it static HTML instead of doing hacky cache stuff. It's simple, secure and runs on any type of server.

The only thing that's lacking right now is a really solid static site generator. Octopress/Jekyll are good solutions but can be a bit frustrating and not very portable.

Re:How my life was changed when I began caring about the peo... by jmccree on Thursday January 08, 2015 @06:33PM (#8859760)
Using nginx/varnish as a caching reverse proxy in front of apache/php is rather common. You get all the ease of use of Apache (mod_rewrite instant .htaccess rule changes, mod_php, etc.) , ability to use whatever cpu intensive plugins/code you want in your application, and once the page is cached it loads instantly for as long as you cache it. Nginx can be configured to serve static assets directly or your app can use CDN links.

I've never really understood the recent fascination with static site generators. I get that it's neat you can upload just everything to S3 and host it there with no servers, but then if you want to change something site wide you have to reload everything. Dynamic app + with caching reverse proxy + optional CDN is a tried and true method. I've been on projects that use this method with small VMs to power sites with tons of traffic.

Re:How my life was changed when I began caring about the peo... by cbhl on Thursday January 08, 2015 @07:24PM (#8859972)
I've had strong recommendations for nanoc and middleman. Additional static site generators can be found all over; one good resource is this list: http://blog.iwantmyname.com/2014/05/the-updated-big-list-of-...
Re:How my life was changed when I began caring about the peo... by ibudiallo on Thursday January 08, 2015 @07:39PM (#8860024)
In my case, I did two things:

1. Add memcached 2. Serve static files via nginx

It allowed me to handle 2.9 million requests

I documented it here: http://idiallo.com/blog/handling-1-million-web-request

Re:How my life was changed when I began caring about the peo... by JeremyMorgan on Friday January 09, 2015 @01:19PM (#8863465)
Nice! I tweeted this, you might see some additional traffic, definitely something my group of friends would be interested in.
Re:How my life was changed when I began caring about the peo... by ibudiallo on Sunday January 11, 2015 @06:17PM (#8871733)
Thanks, and I'm glad you found it interesting.
Re:How my life was changed when I began caring about the peo... by driverdan on Thursday January 08, 2015 @07:33PM (#8860000)
Nginx + PHP-FPM isn't necessarily hard to setup, just different. It will be much faster than nginx in front of apache.
Re:How my life was changed when I began caring about the peo... by stephen_g on Thursday January 08, 2015 @08:46PM (#8860271)
You can do the rewrite with a single nginx command:

    try_files $uri $uri/ /index.php?$args;