I just played around with nginx + HHVM + Wordpress, but can't get it to work correctly. Apache + HHVM and nginx + PHP-FPM works, but when using nginx and HHVM together, some global PHP variables are empty.
For example, there is a global called nice_options in my theme.
When trying this:
global $nice_options;
echo '###';
print_r($nice_options);
print_r($_GLOBALS['nice_options']);
echo '###';
I get this: ######.
I even tried to print_r($GLOBALS)and noticed, that [nice_options] is empty, but fully available in wp_object_cache.
I'm using Ubuntu 14.04, nginx 1.6.0 and HHVM 3.
My nginx configuration files:
/etc/nginx/nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-available/chefgrill (name of my domain)
server {
listen 80 default_server;
root /var/www/chefgrill.de/public_html;
access_log /var/www/chefgrill.de/logs/access.log;
error_log /var/www/chefgrill.de/logs/error.log;
index index.php;
server_name dev.chefgrill.de;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
location ~ /\.ht {
deny all;
}
include hhvm.conf;
}
/etc/nginx/hhvm.conf
location ~ \.(hh|php)$ {
fastcgi_keep_conn on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 1000;
include fastcgi_params;
}
Related
I seem to be having an issue with my Nginx (version 1.11.9) installation. I have set up a LEMP stack on my Ubuntu 16.04 LTS server, and also have mail services running on it as well. I'm using the following agents :- Postfix and Dovecot. Now the reason for setting up LEMP is to facilitate webmail using Roundcube. I have set up symbolic links within sites-enabled, deleted link to default and added site config file called roundcube. The problem I am having is the default_server document root is not loading any pages from that location, it only seems to be loading pages from the Nginx default location /usr/share/nginx/html
I have specified root to be /usr/share/nginx/roundcube but no pages load from that location. I been going over this a 3 weeks now and I'm just getting frustrated as I cant see the issue. I will list the Nginx config files I have amended.
Any help would be very much appreciated.
P.S I am using Cloudflare DNS
Thanks Rob
nginx.conf :-
user www-data;
worker_processes 2;
pid /run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10 10;
types_hash_max_size 2048;
server_tokens off;
port_in_redirect off;
client_max_body_size 4096k;
client_body_timeout 10;
client_header_timeout 10;
send_timeout 10;
#server_names_hash_bucket_size 64;
#server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_min_length 1100;
gzip_vary on;
gzip_proxied any;
# gzip_comp_level 6;
gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml application/x-font-ttf font/opentype application/ vnd.ms-fontobject;
##
# SSL Settings
##
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
#ssl_prefer_server_ciphers on;
# Sitewide SSL settings
ssl_session_cache shared:SSL:10m;
ssl_buffer_size 4k;
# Sitewide proxy settings
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
Sites-available config file "roundcube" contents :-
server {
listen 80;
server_name example.com;
if ($http_cf_visitor ~ '{"scheme":"http"}') {
return 301 https://example.com$request_uri;
}
}
server {
listen 80;
server_name example.com;
if ($http_cf_visitor ~ '{"scheme":"http"}') {
return 301 https://$host$request_uri;
}
}
# HTTPS server
server {
listen 443 ssl http2 default_server;
server_name example.com;
root /usr/share/nginx/roundcube;
index index.html index.php;
autoindex off;
ssl on;
ssl_certificate /etc/ssl/private/ssl-chain-mail-example.com.pem;
ssl_certificate_key /etc/ssl/private/ssl-key-decrypted-mail-example.com.key;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES :RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS;
ssl_prefer_server_ciphers on;
ssl_ecdh_curve secp521r1;
# Client auth via certs
# ssl_client_certificate /etc/ssl/private/example.com.crt;
# ssl_trusted_certificate /etc/ssl/private/example.com.crt;
# ssl_verify_client on;
location / {
# if ($ssl_client_s_dn !~* "user#example.com") {
# return 301 http://www.jurassicsystems.com/;
# }
# error_page 403 #fallback;
}
location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
deny all;
}
location ~ ^/(config|bin|SQL|logs|temp)/ {
deny all;
}
location ~ ^/.*\.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php7.1-fpm-sock;
fastcgi_param HTTPS on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
location #fallback {
return 301 http://www.jurassicsystems.com/;
}
}
First of all let me tell you that I am not an expert on web-servers and things like that.
I'm trying to set-up a cloud system on raspi following this link:
RasPi Owncloud
However, when I try to connect at my IP I get a fantastic 502 Bad Gateway. I googoled (a lot) and all solution given they didn't work for me :(
Also, I checked apache, nginx and php5 logs and they don't show error whatsoever.
Can you please help me to narrow down the problem?
cat /etc/nginx/nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#
}
cat /etc/nginx/sites-available/default
upstream php-handler {
server 127.0.0.1:9000;
#server unix:/var/run/php5-fpm.sock;
}
#server {
# listen 80;
# server_name 172.16.0.2;
# return 301 https://$server_name$request_uri; # enforce https
#}
server {
listen 443 ssl;
server_name 172.16.0.2;
ssl_certificate /etc/nginx/cert.pem;
ssl_certificate_key /etc/nginx/cert.key;
# Path to the root of your installation
root /var/www/owncloud;
client_max_body_size 1000M; # set max upload size
fastcgi_buffers 64 4K;
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
deny all;
}
location / {
# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
try_files $uri $uri/ index.php;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass php-handler;
}
# Optional: set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
# Optional: Don't log access to assets
access_log off;
}
}
At random intervals my site will become unresponsive and the only way to make it load is to do this is the console. Of course this is an easy task but I can't be constantly monitoring my site.
service php5-fpm restart
I don't know how to fix this, but here's my configuration files.
/etc/nginx/sites-available/default
server {
listen 80;
listen 443 ssl;
default_type text/html;
server_name epicmc.us;
root /usr/share/nginx/html;
index index.php index.html index.htm;
error_page 404 /404.php;
# pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
/etc/nginx/nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
client_max_body_size 8M;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 8000;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
/etc/php5/fpm/php.ini
This is hosted remotely because it's too large to host. http://pastebin.pw/683h6n
Here is my Nginx error log - It was too big to paste in here (or anywhere) without crashing my whole browser. The .log is available for download here though: http://uploads.pw/v/480801/
I'm having a problem with nginx where my ip address points to my website but when i point my domain to that ip address, and try to access my webstie with my domain name (www.example.com) nginx returns a 404 error. Here is my code.
user www-data;
worker_processes 4;
worker_rlimit_nofile 100000;
pid /run/nginx.pid;
events {
use epoll;
worker_connections 1024;
multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 200;
reset_timedout_connection on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
#gzip on;
gzip_disable "msie6";
gzip_min_length 256;
# gzip_vary on;
# gzip_proxied any;
gzip_comp_level 3;
gzip_buffers 16 32k;
# gzip_http_version 1.1;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
server{
listen 80;
server_name vidzapp.com www.vidzapp.com;
client_max_body_size 500m;
location /{
add_header 'Access-Control-Allow-Origin' "*";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Content-Type,accept,x-wsse,origin';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
root /var/www;
index index.php;
}
location ~ \.php$ {
root /var/www/;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# # With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
}
In your virtual Host file located # /etc/nginx/sites-available/yourdomain.com
FIND AND ADD : DOMAIN.com www.DOMAIN.com *.DOMAIN.com; to server name
root /var/www/egaffar.com/datazone;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name DOMAIN.com www.DOMAIN.com *.DOMAIN.com;
location / {
# First attempt to serve request as file, then
Then type the below command
nginx -t && service nginx restart
I have an application written with CodeIgniter, that runs perfectly on my local server (MAMP).
Now I'm trying to use an Ubuntu server 13.10, but I always get the 405 error when I click on the login button.
Screenshot of the problem.
http://i42.tinypic.com/14e3sjc.png
This is my nginx.conf file:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
Do you have any ideas?
A few simple tweaks will get it working. First in your codeigniter config file set your index page to be empty, and your uri_protocol to be REQUEST_URI.
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Then check your root location. My app has a trailing slash, and most example Codeigniter/nginx server blocks do as well.
Lastly in your try_files line, make sure you take off the =404 portion and just have this:
try_files $uri $uri/ /index.php;.
And if you get stuck, below is my working nginx sites file (and my config file is stock from the ubuntu install).
#Working server block below.
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/my_app/current/;
index index.php;
server_name staging.myapp.com;
location / {
# First attempt to serve request as file, then
# as directory, but codeigniter will handle the 404.
try_files $uri $uri/ /index.php;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}