Apache Vs Nginx (mod_php VS Php-fpm)
Jun 23, 2009Here is the comparison between Apache and Nginx. Request processing overhead and real-world application performance measurements included.
[url]
Here is the comparison between Apache and Nginx. Request processing overhead and real-world application performance measurements included.
[url]
I'm looking at optimizing our dynamic content delivery process and there are some interesting claims regarding fastcgi vs. mod_php.
What I am wondering about is assuming apache serving ONLY php content, why would fastcgi perform any better than mod_php? The memory footprint of spawned workers exists in both solutions.
Wouldn't context switches and buffering in fastcgi actually lower performance?
What could be gained by using a different web server (nginx/lighty) ? The primary bottleneck would still be physical memory (assuming <255 workers) ?
I am doing my web like this:
1) nginx listening at port 80
2) apache listening at port 78
3) nginx throws all shtml pages to apache
they are working perfectly, except one small thing:
I don't want any public visitor may visit port 78 directly, for now, both:
[url]
[url]
are working for visitors.
Anybody knows how to block/hide port 78 to the public access?
my nginx config snippet:
Code:
location = /index.shtml {
proxy_pass [url]
}
my apache2 config snippet:
Code:
Listen 78
If I make apache as follows:
Code:
Listen 127.0.0.1:78
I will get 502 bad gateway when I visit:
[url]
I am wondering if there is an easy way to convert apache to nginx on my Plesk 12 server. Ideally, I would like to save all my hosts without having to re set them all up. I have been searching online, but haven't found a simple way to do so.
View 1 Replies View RelatedI decided to stick with mod_php for my shared server. What I'm looking for is any info/links on best security implementations for mod_php.
View 4 Replies View RelatedAccording to the latest trend and technological advances, which server software should people go with from the very beginning. Which do you recommend as on today?
btw anybody has experience with all 3 (apache/nginx/litespeed) webservers?
I have -
On a common shared environment, I started off with Apache - was fine until some load started generating and it became crapache.
Then litespeed - Totally awesome, could seriously feel the difference, but its cost is something not everybody can afford.
Then nginx - Very nice, felt like litespeed only, the only difference was it got quite complex in configuring it at a later stage BUT its free'ness made me love it badly.
I have a VPS running Parallels Plesk 12.0.18 Update#36 and CentOS 6.6. I'll like to move (if it's possible uninstall complete) Apache and let Nginx to manage all the request coming from outside.
View 4 Replies View RelatedWe'd like to use this tool from Google on our Plesk server: [URL]
is it useful getting these tools going on server, and are they worth it?
When cpanel has apache 2.2 available. I am planning on switching my servers over to it and to SuPHP from mod_php. There are hundreds of accounts on my different servers and I am worried about the transition. I know cpanel has a permission conversion script, but I dont completely trust it. The biggest issue to me though, is all the users that have php_values and flags in their htaccess files that would then be needed converted to php.ini's. Has anyone created a conversion script for doing this in an automated fashion?
I might not even convert my full servers to this and just do with the partial ones (less than 25%), but I really think it would benefit the customers and myself with the nice added layer of protection of suphp.
Whatever i try to modify configuration there is no way i can get file delivered by apache or NGINX to be deflate/gzip compressed.
OS: Debian 7.7
Plesk version: 12.0.18 Update #33
I've tried to add these lines to Nginx (Vhost directives) but it change nothing :
# Gzip Settings
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 4;
gzip_http_version 1.1;
gzip_min_length 1100;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/x-javascr$ application/xml application/xhtml+xml application/xml+rss;
gzip_vary on;
gzip_static on;
gzip_proxied any;
gzip_disable "MSIE [1-6].";
I also tried to disable Nginx and configure deflate in apache with following lines (Vhost directives then in a file in apache2/conf.d) but it is the same ...
<IfModule mod_deflate.c>
# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)s*,?s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
[code]....
How to convert apache rewrite rule to nginx:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^naujienos+ news.php/$1 [L]
RewriteRule ^naujienos/p(.*)$ /news.php?pg=$1 [nc]
RewriteRule ^naujienos/?$ /news.php [nc]
RewriteRule ^naujienos?$ /news.php [nc]
I'm running a shared hosting environment and I'd like to know if it's even possible to secure the Apache while it's running mod_php. I know I could go suPHP with PHP-CGI, but that'd increase drastically the server load.
So what should I do to best secure the server?
So far now I did:
- Apache:
Installed mod_security and mod_evasive.
- PHP:
Set register_globals=OFF
Set disable_functions = ini_restore, popen, exec, shell_exec, system, passthru, proc_open, proc_close
Set safemode=ON
Set open_basedir to user's directory on virtualhost
Is that would be a secure environment for my users?
I am a non-tech person trying to configure Nginx to serve static content (apache will remain on port 80 for the dynamic stuff).
Nginx is already installed, what I need is a workable configuration file for nginx so that it serves all static stuff (images and a few folders with static html) and instructions in how to create it. The server is running DirectAdmin panel, Apache 2.24, PHP 5.23 and XCache 1.2.
I want to pass the X-SENDFILE header to apache through nginx.
Is this possible or do i have to disable the reverse proxy?
for some reason virtual host which i create,i always get error
403.I tried many things,from chowing to various owners and other,until i
found temporal solution-i created copy of html directory(which is
created during install and which working fine) called bla,and pointed
domain to bla directory and then it worked.But this is problematic since
all files are in home directory,which means i will need to copy all of
them into /usr/local/nginx/.
Also what is problem is with alias,i have a script which is located at
/home/ also and that again causing that 403 error since it's not located
in /usr/local/nginx.I tried to make it work by creating symbolic link
but that didn't worked.Seems only solution would be to copy script to
nginx directory which will require a lot of file editing because of
location change.
Also there is a problem with domain alias-*.domain.com not working at
all,nor 1.domain.com.If i have *.domain.com instead domain.com,then i
get 404 error on directory alias,while it works on www.
How do i enable hotlink blank protection for images,where images can be
loaded only by specified domains and direct access?
And how to rewrite following apache rule:
RewriteEngine on
RewriteRule ^directory/(.*)$ /st/st.php?%{QUERY_STRING}
I using latest stable version,and i think same problems was on latest
legacy version too.
Here is my server section of domain:
server {
listen 81;
server_name www.domain.com *.domain.com ;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root bla;
index index.php index.html index.htm;
}
location /TC/ {
alias /home/tradecontrol/client/;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root bla;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on
127.0.0.1:9000
#
location ~ .php$ {
root bla;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/usr/local/nginx/bla$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
# deny all;
#}
}
i dunno if any one here can help (im hoping some one can) but basically i have installed nginx onto a freebsd server, added 2 domains to this webserver.
the first domain works correctly and loads up all php files etc how ever the second domain wont.
its pretty confusing as both configs are the same, if i comment out the working config the non working one will work perfect.
i have uploaded a copy of the configs onto
www f1colo com / config.txt
Well, I decided giving it a shot.
I have a large proxy, are getting ~3k pageviews/day.
I only got 128 MB RAM on my VPS, so no panels works on it (not even kloxo/lxa). I would guess apache wont do it in the long run either.
So I decided to go with nginx. But I feel it isn't quite good optimized, as it sometimes takes like 1 minute to load the page.
Here is my current config:
#######################################################################
#
# This is the main Nginx configuration file.
#
# More information about the configuration options is available on
# * the English wiki - http://wiki.codemongers.com/Main
# * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################
#----------------------------------------------------------------------
# Main Module - directives that cover basic functionality
#
# http://wiki.codemongers.com/NginxMainModule
#
#----------------------------------------------------------------------
user nginx;
worker_processes 12;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
#----------------------------------------------------------------------
# Events Module
#
# http://wiki.codemongers.com/NginxEventsModule
#
#----------------------------------------------------------------------
events {
worker_connections 1024;
}
#----------------------------------------------------------------------
# HTTP Core Module
#
# http://wiki.codemongers.com/NginxHttpCoreModule
#
#----------------------------------------------------------------------
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
#
# The default server
#
server {
listen 80;
server_name _;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
# deny all;
#}
}
}
Any ideas on better optimizing?
we got installed Nginx on server though it helped us to reduce load of our file uploading sites server ,strange but uploads are not working, script uses uber upload please help me to get it work
View 2 Replies View RelatedI was just wondering if anyone has tried using nginx to accelerate Apache under cPanel?
I found a tutorial on how to do it
[url]
and he got amazing results from trying it
[url]
just wanted to see if anyone else has any experience with it
I have nginx conf which works perfectly fine with ip adress,but when i put domain then php for some reason no longer works,i getting download php file situation.
Here is main conf file:
#######################################################################
#
# This is the main Nginx configuration file.
#
# More information about the configuration options is available on
# * the English wiki - http://wiki.codemongers.com/Main
# * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################
#----------------------------------------------------------------------
# Main Module - directives that cover basic functionality
#
# http://wiki.codemongers.com/NginxMainModule
#
#----------------------------------------------------------------------
user nginx;
worker_processes 5;
error_log /var/log/nginx/nginx-error.log crit;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
#----------------------------------------------------------------------
# Events Module
#
# http://wiki.codemongers.com/NginxEventsModule
#
#----------------------------------------------------------------------
events {
worker_connections 2048;
}
#----------------------------------------------------------------------
# HTTP Core Module
#
# http://wiki.codemongers.com/NginxHttpCoreModule
#
#----------------------------------------------------------------------
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log off;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
#
# The default server
#
server {
listen 81;
server_name main.main.net;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ .php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
# deny all;
#}
}
}
A few days ago I switched from lighttpd to nginx for serving images on my photo hosting service. I've noticed speeds have increased greatly, and average server load has dropped from 0.15, down to 0.01.
Nginx was originally made by this russian guy, and has gotten fairly popular among nerds. I was just wondering if anybody else out there is using it, and if they have any tips for optimization, or feature improvements.
The one thing i miss about lighttpd was the server-status module. Nginx has it's own, but it doesn't seem to be as verbose as the one lighttpd had.
nginx homepage: [url]
I have install FreeBSD and i use Nginx for run my website on this webserver.
All working good and the server running from 1/2month..
Today when i visits my site i have see Nginx Gateway Error 502..
and from shell i run top command and all processor are using 0% of cpu but use the normal ram..
all is stopped..
but i don't know why and how happen..
Any people have the same error?
I think i do create a monitor script and when appen just reboot the server (i have solve this problem rebooting the server each 502 error)
look for someone to do the installation and configuration of these two (lighttpd or nginx) to run along with Cpanel as compatible as possible.
Hired a 'SultanHost' but the service was not expected and support the worse.
does anyone on this forum know how to do a referral check to prevent hot linking to files that are on a nginx server? There is this regex code you use but I don't know how to put it together. how to do it on nginx using their rewrite module?
View 12 Replies View Relatednginx will look for web files under /usr/local/nginx/html. However, I want to put my website files under /home/public_html, is that possible with nginx? I can not find many things about nginx conf file explanation,
View 0 Replies View RelatedHas anybody successfully used nginx in a shared web hosting environment?
It seems quite powerful and looks like it would be well suited for such an environment, combined with FastCGI, looks like it could serve a lot of hits on relatively inexpensive servers.
The main problem I'm foreseeing is a demand for mod_rewrite, which may cause some support headaches.
Anything else I'm not thinking of?
(I did search but the last post I found was from 2007 with no replies, and necroposting is bad)
Anyony use nginx as web server in shared hosting enviroment? maybe with some custom made control panel's?
How is about its scalability, php performance and so on?