GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   who here has setup nginx? (https://gfy.com/showthread.php?t=1058684)

fris 02-23-2012 06:47 AM

who here has setup nginx?
 
having issues getting php to work.

curious on peoples setup.

:helpme

cooldude7 02-23-2012 07:01 AM

wild guess.
try removing .htaccess files.,

raymor 02-23-2012 07:23 AM

I wish I could remember some php on nginx tips, but there were other nginx problems after that made me forget about the PHP stuff. Nginx seems to be one problem after another, so we just added noatime to fstab and went back to a perfectly working, standards compliant Apache setup.

fris 02-23-2012 07:29 AM

Quote:

Originally Posted by raymor (Post 18776400)
I wish I could remember some php on nginx tips, but there were other nginx problems after that made me forget about the PHP stuff. Nginx seems to be one problem after another, so we just added noatime to fstab and went back to a perfectly working, standards compliant Apache setup.

looking to setup nginx for wordpress sites, it can handle it much better than apache.

Spudstr 02-23-2012 07:35 AM

Quote:

Originally Posted by fris (Post 18776410)
looking to setup nginx for wordpress sites, it can handle it much better than apache.

There is no module for PHP for nginx, you need to set it up as php-fpm, it runs as as stand a lone daemon and basically proxies the requests to the socket/php-fpm.

Klen 02-23-2012 07:55 AM

I can send you tutorial to mail written by me if you want.

Klen 02-23-2012 07:56 AM

Quote:

Originally Posted by cooldude7 (Post 18776373)
wild guess.
try removing .htaccess files.,

:1orglaugh:1orglaugh:1orglaugh:1orglaugh:1orglaugh :1orglaugh:1orglaugh:1orglaugh:1orglaugh:1orglaugh :1orglaugh:1orglaugh:1orglaugh:1orglaugh:1orglaugh :1orglaugh:1orglaugh

AdultEUhost 02-23-2012 08:15 AM

php-fpm is what you want I think

alias 02-23-2012 08:42 AM

Not sure, just use it for streaming media.

pumpercloggs 02-23-2012 08:51 AM

you will get even better performance out of apache with varnish in front.

borked 02-23-2012 09:00 AM

Fris, I'd not recommend you go that route... Its great for dissing up plain html, thumbs and stuff, but php-fpm just slows everything right down.
If you still carry on, make sure you test with ab both pre and post nginx

Klen 02-23-2012 09:06 AM

Quote:

Originally Posted by borked (Post 18776564)
Fris, I'd not recommend you go that route... Its great for dissing up plain html, thumbs and stuff, but php-fpm just slows everything right down.
If you still carry on, make sure you test with ab both pre and post nginx

Using php-fpm for years and never had any slowdown problem.Never.

Jack Sparrow 02-23-2012 09:23 AM

Nginx is running wp like a mofo on speed!!

mafia_man 02-23-2012 09:36 AM

Quote:

Originally Posted by KlenTelaris (Post 18776574)
Using php-fpm for years and never had any slowdown problem.Never.

Never had a problem with php-fpm either. Rasmus recommends it ffs...

Klen 02-23-2012 09:41 AM

Quote:

Originally Posted by Jack Sparrow (Post 18776595)
Nginx is running wp like a mofo on speed!!

Now all agree on this or i release kraken :1orglaugh

Jack Sparrow 02-23-2012 11:48 AM

Quote:

Originally Posted by KlenTelaris (Post 18776634)
Now all agree on this or i release kraken :1orglaugh

Well its true. Running smoother then a babies butt.

fris 02-23-2012 11:55 AM

got it setup fine, just need to tune php-fpm.conf

Klen 02-23-2012 12:06 PM

Quote:

Originally Posted by fris (Post 18776925)
got it setup fine, just need to tune php-fpm.conf

Did you edited fastcgi.params too ?

borked 02-23-2012 12:29 PM

Quote:

Originally Posted by Jack Sparrow (Post 18776595)
Nginx is running wp like a mofo on speed!!

Quote:

Originally Posted by KlenTelaris (Post 18776574)
Using php-fpm for years and never had any slowdown problem.Never.

Quote:

Originally Posted by mafia_man (Post 18776626)
Never had a problem with php-fpm either. Rasmus recommends it ffs...

Quote:

Originally Posted by Jack Sparrow (Post 18776909)
Well its true. Running smoother then a babies butt.

But does nginx+php run faster than Apache with PHP is the question? On your setup perhaps, but maybe because you have too many unnecessary apache modules loaded?

I run an API server that is heavily PHP dependent and has 30million+ requests daily. Load was a bit nuts at one point early last year (load 5ish) and it was only serving around 10mill around then, so I gave nginx+php a try. Configured it to the minimum but it thrashed around like hell, sending load way high. Continuously. The reason being the php-cgi spawing was costing too much.

So, I stripped apache down, tweaked all the settings, now server load is a VERY steady 0.05 with 30mill+ hits.

So, I still hold that apache wins hands down.

Well, for high traffic sites that is... your wp may well run smooth and quick, but wait till it gets enough traffic to start spawning children :thumbsup

Klen 02-23-2012 12:42 PM

Quote:

Originally Posted by borked (Post 18777005)
But does nginx+php run faster than Apache with PHP is the question? On your setup perhaps, but maybe because you have too many unnecessary apache modules loaded?

I run an API server that is heavily PHP dependent and has 30million+ requests daily. Load was a bit nuts at one point early last year (load 5ish) and it was only serving around 10mill around then, so I gave nginx+php a try. Configured it to the minimum but it thrashed around like hell, sending load way high. Continuously. The reason being the php-cgi spawing was costing too much.

So, I stripped apache down, tweaked all the settings, now server load is a VERY steady 0.05 with 30mill+ hits.

So, I still hold that apache wins hands down.

Well, for high traffic sites that is... your wp may well run smooth and quick, but wait till it gets enough traffic to start spawning children :thumbsup

I dont know i have only 50k daily traffic on one server.

Brujah 02-23-2012 12:49 PM

borked, how well did you tune php5-fpm? Did you set it up as a socket or used tcp? Did you use the same caching (built-in to nginx) methods in both? It might just be that you're more familiar with fine-tuning Apache.

borked 02-23-2012 03:01 PM

tbh, I don't know now - it was way back at the beginning of 2011. All I remember was I gave it all the resources I could and it still couldn't handle the load (watched by server-status seeing all the slots fill up, and cpu spike).
I tried it on and off for a few days until I called it quits and got dirty with apache. Honestly never looked back since.
Still, I'm not saying bad of nginx - I use it for thumbs on another server that runs at 2-500mbs (adult stuff, not an API) so that I can use apache with keepalive on for the harder processing. That combo works sweet and brought load down from ~8 to 3. Without nginx handling the thumbs, I couldn't have keep-alive on in apache.

Every circumstance is different I guess - I just wouldn't switch to nginx just cos it's what the other boys are doing... look at your situation and try both in different combinations.

Just like I love MySQL, but things were getting crazy (yes, db optimised to hell). Once I figured out where the bulk of the queries were, I moved them over to lucene/solr and shit has been plain sailing ever since. I never eliminated MySQL, but combining both "just made sense" and the server lives happily ever after.

There is no "one size fits all". A server configuration needs to adapt based on the specific requirements. That's my lesson for today ;)

Klen 02-23-2012 03:04 PM

Quote:

Originally Posted by borked (Post 18777366)
tbh, I don't know now - it was way back at the beginning of 2011. All I remember was I gave it all the resources I could and it still couldn't handle the load (watched by server-status seeing all the slots fill up, and cpu spike).
I tried it on and off for a few days until I called it quits and got dirty with apache. Honestly never looked back since.
Still, I'm not saying bad of nginx - I use it for thumbs on another server that runs at 2-500mbs (adult stuff, not an API) so that I can use apache with keepalive on for the harder processing. That combo works sweet and brought load down from ~8 to 3. Without nginx handling the thumbs, I couldn't have keep-alive on in apache.

Every circumstance is different I guess - I just wouldn't switch to nginx just cos it's what the other boys are doing... look at your situation and try both in different combinations.

Just like I love MySQL, but things were getting crazy (yes, db optimised to hell). Once I figured out where the bulk of the queries were, I moved them over to lucene/solr and shit has been plain sailing ever since. I never eliminated MySQL, but combining both "just made sense" and the server lives happily ever after.

There is no "one size fits all". A server configuration needs to adapt based on the specific requirements. That's my lesson for today ;)

Ah well,atleast you are not bull shiting like raymor :1orglaugh Also i think about same scheme when it comes to databases-some parts on mysql,some on sqllite.

Jack Sparrow 02-23-2012 03:44 PM

Quote:

Originally Posted by borked (Post 18777005)
But does nginx+php run faster than Apache with PHP is the question? On your setup perhaps, but maybe because you have too many unnecessary apache modules loaded?

I run an API server that is heavily PHP dependent and has 30million+ requests daily. Load was a bit nuts at one point early last year (load 5ish) and it was only serving around 10mill around then, so I gave nginx+php a try. Configured it to the minimum but it thrashed around like hell, sending load way high. Continuously. The reason being the php-cgi spawing was costing too much.

So, I stripped apache down, tweaked all the settings, now server load is a VERY steady 0.05 with 30mill+ hits.

So, I still hold that apache wins hands down.

Well, for high traffic sites that is... your wp may well run smooth and quick, but wait till it gets enough traffic to start spawning children :thumbsup

Should not be a problem if you set it up for wordpress and wordpress only.
You can tweak it to the bone, and it will run stable and superfast.

Check out yoast.com, he has some nice posts on nginx server setups and they rock.

borked 02-23-2012 03:51 PM

Quote:

Originally Posted by Jack Sparrow (Post 18777439)
Check out yoast.com, he has some nice posts on nginx server setups and they rock.

Odd that he's running LiteSpeed himself though :winkwink:

For every need there is a different solution...

CYF 02-23-2012 04:57 PM

apache 2.4 was just released, with a lot of speed enhancements. It's reported to be faster than nginx in some aspects. I haven't tested it yet, but it could be an option Fris.

mafia_man 02-23-2012 05:12 PM

Quote:

Originally Posted by borked (Post 18777449)
Odd that he's running LiteSpeed himself though :winkwink:

For every need there is a different solution...

Can't use Litespeed for porn anyway. Fucking Mormons.

BradBreakfast 02-23-2012 05:56 PM

I would suggest Varnish Cache

raymor 02-23-2012 06:05 PM

If you do get it working, definitely DO test, with noatime. For best results, comment out the twenty Apache modules you're not using, like mod_speling. On a 400 Mbps site we did a lot of testing on, Apache was the winner. Speed on all was about the same once noatime was enabled because all severs were then doing the same things. With roughly equal performance, Apache's flexibility and correct implementation of standards pushed it over the top.

Brujah 02-23-2012 06:22 PM

Ray were you using relatime before? If not, did it make a big difference? Does Apache have a noatime-like setting so you don't have to change the mount?

raymor 02-23-2012 08:01 PM

Quote:

Originally Posted by Brujah (Post 18777718)
Ray were you using relatime before? If not, did it make a big difference? Does Apache have a noatime-like setting so you don't have to change the mount?


It was not using relatime. Noatime versus default makes a HUGE difference in IOPS, so for small files, some databases, and those PHP scripts that include a bunch of different .php files. For small files, it cuts disk access roughly in half by making it one read rather than a read and a write.

As far as I know, Apache simply follows the mount specification and doesn't have an option to seperately avoid atime within the application. mod_cache_disk to shm would do it, though.

I haven't tested relatime under a heavy webserver workload. I use it on my desktop homedir and our IMAP server.

borked 02-23-2012 11:59 PM

I don't see how nginx can get around that if a disk mounted without noatime, since that's a kernel-level thing. Every file's access time is altered irrespective of software if noatime is not specifically specified.

Klen 02-24-2012 12:29 AM

Btw borked can you post httpd -m on that machine where you optimized apache ?

borked 02-24-2012 01:00 AM

Quote:

Originally Posted by KlenTelaris (Post 18778146)
Btw borked can you post httpd -m on that machine where you optimized apache ?

well, it's pretty useless for anyone to follow since it's specific to the sites that run on that server... trying to copy will most likely break your sites. You just have to go through your own list and see what is unnecessary for your sites (and perhaps load them only in the particular vhost config for site-specific modules)

anyway, here's the list for the member site server running at a few hundred mbs:

Code:

Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 include_module (shared)
 log_config_module (shared)
 logio_module (shared)
 env_module (shared)
 ext_filter_module (shared)
 mime_magic_module (shared)
 expires_module (shared)
 deflate_module (shared)
 headers_module (shared)
 usertrack_module (shared)
 setenvif_module (shared)
 mime_module (shared)
 status_module (shared)
 autoindex_module (shared)
 info_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 actions_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 cgi_module (shared)
 version_module (shared)
 php5_module (shared)
Syntax OK

Other important info:
Code:

CoreDumpDirectory /var/apache-core-dumps

ServerRoot "/etc/httpd"
PidFile run/httpd.pid
Timeout 10
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 3

<IfModule prefork.c>
StartServers      50
MinSpareServers    75
MaxSpareServers  150
ServerLimit      700
MaxClients      700
MaxRequestsPerChild  100
</IfModule>

And by offloading static graphics to nginx, apache bw is pure code..
here are the stats at the low point of the day (current bw 154mbs)

Code:

CPU Usage: u2635.41 s536.09 cu0 cs0 - .704% CPU load
21.7 requests/sec - 162.1 kB/second - 7.5 kB/request
20 requests currently being processed, 110 idle workers

__KK___________W____________W__________W___W_K_____________C____
_K_______C__________________C_________C__CKK_K......__WK_W____W_
________........................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
............................................................


Brujah 02-24-2012 01:13 AM

Why offload to nginx instead of another install of apache? Is it because ... nginx is better for that job?

borked 02-24-2012 01:21 AM

Quote:

Originally Posted by Brujah (Post 18778207)
Why offload to nginx instead of another install of apache? Is it because ... nginx is better for that job?

haha, you're trying (in both senses)!

sure, I could put up another install of apache stripped bare on the same server, but have you ever tried to maintain two apache installs?

nginx has the advantage because out of the box it is a bare-minimum httpd engine, that you build up.
Apache comes out of the box quite loaded, that I end up stripping down.

For a server that simply disses up jpegs, loading up nginx was a no-brainer.

As ever, YMMV. If your server is happy running nginx for your sites, who the hell am I to tell you otherwise?

borked 02-24-2012 01:24 AM

it's like saying do you use tomcat or jetty, and why?

you can't group shit simply without knowing the circumstances

let's have some fun with similes:

nginx ==jetty == WBA lightweight == small footprint
apache == tomcat == WBA heavyweight == big footprint

fris 02-24-2012 08:18 AM

Quote:

Originally Posted by KlenTelaris (Post 18776956)
Did you edited fastcgi.params too ?

[email protected]

if you can send your setup ;)

Klen 02-26-2012 01:42 PM

Quote:

Originally Posted by fris (Post 18778666)
[email protected]

if you can send your setup ;)

I suppose you already resolved problem,but i sent you mail anyway from gfyinfo at email.cz
.I have also some fancy codes which can optimize nginx further so can sent that too.

fris 02-26-2012 05:49 PM

ya thanks, got it setup already, just took me a while for the rewrite rules for one of my code igniter projects.

mainly went by this

http://itresident.com/nginx/nginx-an...t-connections/

borked 02-27-2012 12:17 AM

Quote:

It's not recommended to use PHP5-FPM via unix socket for more than 300+ concurrent connections due to you will definitely get nasty error: sock failed (11: Resource temporarily unavailable) or connect() failed (11: Resource temporarily unavailable) depending on your version, (you may need to increase start_servers, or min/max_spare_servers), and and every 5th page will be return Error 502. By using tcp/ip as a handler you will get more stability but will loose around 10 connection on each 100 concurrent connection in performance.



And the other 2 tricky things to make it to run more smoothly is to gracefully restart PHP5-FPM every 9 minutes and clear the Query Cache on MySQL every 8 minutes. Again, the time depends on your load and content of your project.
That's interesting - maybe that was my problem when I gave it a go...

note though his article title is misleading, since the majority of those 2k active connections are keep alives and with a timeout of 60seconds (very high imo) is likely to be dead timeouts that will gracefully timeout. He has 200/s reads, which is still a lot but nothing apache couldn't handle easily.

fris if you have both setup, mind posting some benchmark test results with ab with same 100 concurrents?

Bird 02-27-2012 12:44 AM

wtf is nginx. Damn now I got to google it...

evulvmedia 02-27-2012 01:12 AM

You need VODKA to set up nginx. Drink vodka and it all starts to make sense. Not Wild Goose or whatever the fuck that shit is, because nothing makes sense if you drink that.

Luckily OPs name is also name of cheap and very good Danish vodka. Which, incidentally, is very difficult to get in Denmark.

raymor 02-28-2012 04:48 PM

Quote:

Originally Posted by borked (Post 18778108)
I don't see how nginx can get around that if a disk mounted without noatime, since that's a kernel-level thing. Every file's access time is altered irrespective of software if noatime is not specifically specified.

To do it on purpose:
Code:

open(filename, O_NOATIME, ...
To do it explicitly you use the flag to open() as above. To do it accidentally and in a way that not only do your users not know you're doing it, but you yourself don't know you're doing it, you try to be as clever as you can with your caching. If your caching code is as "clever" as you can write, by definition you're not clever enough to understand all of it's side effects and you get clever but broken caching like nginx.

Quote:

Originally Posted by Brujah (Post 18777718)
Ray were you using relatime before? If not, did it make a big difference? Does Apache have a noatime-like setting so you don't have to change the mount?

A patch to use O_NOATIME should be fairly trivial, but a module with no patch would be a little more involved because apr_file_open() doesn't currently pass flags directly to open(). Instead it ORs only the APR_* flags. One would need to make a trivial patch to apr_file_open(), then optionally pass O_NOATIME from a module based on configuration (or just use noatime always).

HomerSimpson 02-28-2012 07:13 PM

Quote:

Originally Posted by KlenTelaris (Post 18776456)
I can send you tutorial to mail written by me if you want.

you can send it to celebempire{at}gmail.com also
thanks


Quote:

Originally Posted by pumpercloggs (Post 18776555)
you will get even better performance out of apache with varnish in front.

:thumbsup:thumbsup:thumbsup:pimp


Quote:

Originally Posted by fris (Post 18776410)
looking to setup nginx for wordpress sites, it can handle it much better than apache.

you could also try LiteSpeed from http://www.litespeedtech.com/
it's not free but it's good and easy to use...

Quote:

Originally Posted by Bird (Post 18783589)
wtf is nginx. Damn now I got to google it...

http://nginx.org/


my services
http://www.awmzone.com/services

Brujah 02-28-2012 07:29 PM

Quote:

Originally Posted by raymor (Post 18788135)
To do it on purpose:
Code:

open(filename, O_NOATIME, ...
To do it explicitly you use the flag to open() as above. To do it accidentally and in a way that not only do your users not know you're doing it, but you yourself don't know you're doing it, you try to be as clever as you can with your caching. If your caching code is as "clever" as you can write, by definition you're not clever enough to understand all of it's side effects and you get clever but broken caching like nginx.



A patch to use O_NOATIME should be fairly trivial, but a module with no patch would be a little more involved because apr_file_open() doesn't currently pass flags directly to open(). Instead it ORs only the APR_* flags. One would need to make a trivial patch to apr_file_open(), then optionally pass O_NOATIME from a module based on configuration (or just use noatime always).

I grep'd the source and couldn't see NOATIME anywhere. I did see it listed in the CHANGES file for version 0.4.1 back in 2006, but then removed the same day. Which files in the code did you find that explicitly use NOATIME?

fris 02-29-2012 07:37 AM

got it setup fine, the only issue was the rewrite rules, its a different system than apache


All times are GMT -7. The time now is 05:36 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123