Hi all,

Brand new to nginx, but it seems to be the rising star, and suited to hosting high volumes like I'm doing. However, I'm having trouble setting up the config files. A day of google searching hasn't really helped.

My nginx.conf looks like:

events {
    worker_connections 768;
    # multi_accept on;

http {
#   rewrite_log on;

    include mime.types;
    default_type       application/octet-stream;
    access_log         /var/log/nginx/access.log;
    sendfile           on;
#   tcp_nopush         on;
    keepalive_timeout  3;
#   tcp_nodelay        on;
#   gzip               on;
        #php max upload limit cannot be larger than this       
    client_max_body_size 13m;
    index              index.php index.html index.htm;

    # Upstream to abstract backend connection(s) for PHP.
    upstream php {
                #this should match value of "listen" directive in php-fpm pool
        server unix:/tmp/php-fpm.sock;


include sites-enabled/*;

My sites-enabled looks like this:

server {
    listen :80 default_server;
    server_name ubuntutec.cloudapp.net;

    root /var/www/html/;

    index index.php;

    # Additional rules go here.
    include /etc/nginx/conf.d/*.conf;

And the included config file looks like:

# WordPress single site rules.
# Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
    try_files $uri $uri/ /index.php?$args;

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off; log_not_found off; expires max;

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/wordpress-w3-total-cache.conf;

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    # This is a robust solution for path info security issue and works with "cgi.fix_pathinfo = 1" in /etc/php.ini (default)

    include fastcgi.conf;
    fastcgi_index index.php;
#   fastcgi_intercept_errors on;
    fastcgi_pass php;

Everything looks pretty standard. The error I am getting browser side is Connection_Refused. I am getting no error logs in the Nginx logs. But when I restart Nginx I get: Job for Nginx.service failed because the control process exited with error code. See systemctl status nginx.service and journalctl -xe for details

Can someone spot anything out of place?

1 Year
Discussion Span
Last Post by James_43

How do I access those logs? Typing those commands into the console just gives me an unknown command error.


If you don't have access to those commands then you may have to ask to your hosting helpdesk. You can also test the syntax of your configuration files:

nginx -t -c /path/to/nginx.conf

The -c flag is used to test a specific configuration file. Otherwise just run nginx -t

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.