[emerg] "set" directive is not allowed here in /etc/nginx/common/w3tc.conf:4


#1

Hi i’m trying to create new website with command

ee site create example.com --wp

then i got this error message “Running pre-update checks, please wait… NGINX configuration check failed.”

then i run “nginx -t” it says :

“nginx: [emerg] “set” directive is not allowed here in /etc/nginx/common/w3tc.conf:4 nginx: configuration file /etc/nginx/nginx.conf test failed”

What happened? then how to fix this?

Thank’s


#2

Are you sure you did “–wp”? (because it’s trying to include the W3 Total Cache include file, i.e. w3tc.conf).


#4

Sure i did. Here a shot from today when im trying to create new site.


#5

Ah, OK. I suspect these 2 things are unrelated (or indirectly related!). That is, the nginx ‘set directive error’ is probably related to another domain on this server (I’m presuming there are others?).

What’s the history on this? Was ee installed on a fresh os image? Have any manual config changes been made to nginx, or other domain conf files?


#6

Yes, theres other domain on this server. The other domain i created using “ee site create example.com --w3tc”

I never change anything, cause im not geek, im just following tutorial page :slight_smile:

What i need to do to fix this?


#7

Which tutorial page have you been following?

Because it sounds like there is something wrong in the conf file for the domain you created with the --w3tc option. If you’re following a guide that made changes to that sites config then the guide may be out of date. To get a working Wordpress site you need do nothing more than the ‘ee site create’.


#8

im followed this “https://easyengine.io/docs/commands/site/create/

with this command “ee site create example.com --w3tc”

Im also thinking something wrong, but i try to open the config file from my other server its looks exactly same thing nothing changed not even a single dot.


#9

OK, so not a tutorial then - that’s just the command list :slight_smile:

The config file for your domain is here: /etc/nginx/sites-available/your-w3tc-domain.com

I think there’s something wrong in this file.

That file then ‘includes’ others such as the one mentioned in the error, i.e. /etc/nginx/common/w3tc.conf - but I don’t think there is anything wrong with w3tc.conf.

But if this a new server with no live sites, then it may just be easier to zap everything and start over with a clean Ubuntu 16.04, and fresh ee install.


#10

thats the reason im asking here, i need to install new site with 1 site live :frowning:


#11

OK, so what’s in /etc/nginx/sites-available/your-w3tc-domain.com


#12

this

> server {
>     server_name domain.com   www.domain.com;
>     access_log /var/log/nginx/domain.com.access.log rt_cache;
>     error_log /var/log/nginx/domain.com.error.log;
>     root /var/www/domain.com/htdocs;
>     index index.php index.html index.htm;
> set $cache_uri $request_uri;
>         # POST requests and urls with a query string should always go to PHP
>         if ($request_method = POST) {
>                 set $cache_uri 'null cache';
>         }
>         if ($query_string != "") {
>                 set $cache_uri 'null cache';
>         }
>         # Don't cache uris containing the following segments
>         if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index$
>                 set $cache_uri 'null cache';
>         }
>         # Don't use the cache for logged in users or recent commenters
>         if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
>                 set $cache_uri 'null cache';
>         }
>         # Use cached or actual file if they exists, otherwise pass request to WordPress
>         location / {
>         set $cache_uri 'null cache';
>         }
>         if ($query_string != "") {
>                 set $cache_uri 'null cache';
>         }
>         # Don't cache uris containing the following segments
>         if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index$
>                 set $cache_uri 'null cache';
>         }
>         # Don't use the cache for logged in users or recent commenters
>         if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
>                 set $cache_uri 'null cache';
>         }
>         # Use cached or actual file if they exists, otherwise pass request to WordPress
>         location / {
>                 try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$ar$
>         }
>         location ~ ^/wp-content/cache/minify/[^/]+/(.*)$ {
>                 try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
>         }
>         location = /favicon.ico { log_not_found off; access_log off; }
>         location = /robots.txt  { log_not_found off; access_log off; }
>         location ~ \.php$ {
>                 try_files $uri =404;
>                 include fastcgi_params;
>                 fastcgi_pass 127.0.0.1:9000;
>         }
>         # Cache static files for as long as possible
>         location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz$
>                expires max; log_not_found off; access_log off;
>       location ~ ^/wp-content/cache/minify/[^/]+/(.*)$ {
>                 try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
>         }
>         location = /favicon.ico { log_not_found off; access_log off; }
>         location = /robots.txt  { log_not_found off; access_log off; }
>         location ~ \.php$ {
>                 try_files $uri =404;
>                 include fastcgi_params;
>                 fastcgi_pass 127.0.0.1:9000;
>         }
>         # Cache static files for as long as possible
>         location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz$
>                expires max; log_not_found off; access_log off;
>         }
> }
>     include common/w3tc.conf;
>     include common/wpcommon.conf;
>     include common/locations.conf;
>     include /var/www/domain.com/conf/nginx/*.conf;
> }

#13

Well that’s your problem :slight_smile:

I don’t know where all this extra code related to caching etc came from (I thought you hadn’t amended any config files?) - but that’s what the include files at the bottom are for.

The specific error however is because you’ve got mismatched open/close brackets. So the include files are not inside your server block where they should be. Remove that extra closing bracket above include common/w3tc.conf; then at least nginx -t should work.

But there’s a lot of duplicated code here needs removing/sorting out. Right now this version of the config is not even being used by the live site because it would never have been passed as valid.


#14

Now nginx -t give me this message

nginx: [emerg] duplicate location "/" in /etc/nginx/common/w3tc.conf:21
nginx: configuration file /etc/nginx/nginx.conf test failed

#15

As I said, there’s a lot of duplicated code in there that needs removing/sorting out. This is all there should be:-

server {
   server_name yourdomain.com www.yourdomain.com;
   access_log /var/log/nginx/domain.com.access.log rt_cache;
   error_log /var/log/nginx/domain.com.error.log;
   root /var/www/domain.com/htdocs;
   index index.php index.html index.htm;
   include common/w3tc.conf;
   include common/wpcommon.conf;
   include common/locations.conf;
   include /var/www/domain.com/conf/nginx/*.conf;
}

If you want to add anything else you need to be careful, and make sure it’s not duplicating what is already in those include files listed at the end :slight_smile:


#16

I run “nginx -t” syntax OK and successful then i tried to create new site

Running pre-update checks, please wait...
Setting up NGINX configuration  [Done]
Setting up webroot              [Done]
Downloading WordPress           [Done]
Setting up database             [Done]
Installing plugin nginx-helper, please wait...
Reload : nginx     [Failed]
Oops Something went wrong !!
Calling cleanup actions ...
Reload : nginx     [Failed]
service nginx reload failed. check issues with `nginx -t` command.
Check logs for reason `tail /var/log/ee/ee.log` & Try Again!!!

then i run “tail /var/log/ee/ee.log” i got this message

2018-09-18 00:36:01,026 (INFO) ee : [Failed]
2018-09-18 00:36:01,059 (DEBUG) ee : Removing /var/www/testsite.com
2018-09-18 00:36:01,059 (DEBUG) ee : Removing /var/www/testsite.com
2018-09-18 00:36:01,095 (DEBUG) ee : dropping database `testsite_com`
2018-09-18 00:36:01,097 (DEBUG) ee : Exceuting MySQL Statement : drop database `testsite_com`
2018-09-18 00:36:01,211 (DEBUG) ee : dropping user `testsite_com`
2018-09-18 00:36:01,213 (DEBUG) ee : Exceuting MySQL Statement : drop user `testsite_com`@`localhost`
2018-09-18 00:36:01,216 (DEBUG) ee : Exceuting MySQL Statement : flush privileges
2018-09-18 00:36:01,229 (INFO) ee : service nginx reload failed. check issues with `nginx -t` command.
2018-09-18 00:36:01,229 (ERROR) ee : Check logs for reason `tail /var/log/ee/ee.log` & Try Again!!!

Whats wrong again?


#17

If nginx -t reports OK, you need to then run nginx -s reload which actually reloads the config changes you’ve made (without restarting nginx). nginx -t just tests that the changes are valid, nothing more.

So try that first - then make sure your live site is still working OK as this is changing the config for that site.

This may resolve the site create problem you’re now seeing. But if not you might then want to try restarting nginx and/or checking /var/log/nginx/error.log


#18

@mrbaldson Did that resolve the problem?


#19

Nope, it didnt resolve the problem. My live site also down, and im getting tired then i started all over again.

Thank’s Marty for your help and your time, appreciate it.


#20

Make sure you start from a clean point (fresh OS install with no extras), then add ee to that.

And when/if you make any site config changes (none are necessary to get a fully working WP site), always test and reload the nginx config to verify it still works before moving on. And keep a backup copy so you can always go back to a working version :slight_smile:


#21