Join the community today
Become a Member

Xenforo Wordpress and Xenforo 2 configuration

Discussion in 'Forum software usage' started by DaB, Sep 16, 2018.

  1. DaB

    DaB Member

    45
    5
    8
    Aug 10, 2016
    Ratings:
    +6
    Local Time:
    10:11 AM
    Current
    Current
    I have WordPress install in the root directly with friendly URL's working.


    I have installed Xenforo 2 into /domain.com/community

    I want to enable friendly URL's for Xenforo but I am worried about messing up the configuration for WordPress.

    Am I right in saying I need to edit the following file to get friendly URL's working?

    /usr/local/nginx/conf/conf.d/domain.com.ssl.conf

    Thanks!
     
  2. eva2000

    eva2000 Administrator Staff Member

    55,396
    12,255
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,835
    Local Time:
    7:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  3. DaB

    DaB Member

    45
    5
    8
    Aug 10, 2016
    Ratings:
    +6
    Local Time:
    10:11 AM
    Current
    Current
    I get this aerror when I add the code from the Xenforo site....

    Restarting nginx (via systemctl): Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" an d "journalctl -xe" for details.
    [FAILED]
     
  4. eva2000

    eva2000 Administrator Staff Member

    55,396
    12,255
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,835
    Local Time:
    7:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    try nginx config test via command and show what output is shown
    Code (Text):
    nginx -t
    

    for posting code or output from commands to keep the formatting, you might want to use CODE tags for code How to use forum BBCODE code tags :)
     
  5. DaB

    DaB Member

    45
    5
    8
    Aug 10, 2016
    Ratings:
    +6
    Local Time:
    10:11 AM
    Current
    Current
    Code:
    nginx: [emerg] "location" directive is not allowed here in /usr/local/nginx/conf/conf.d/yourdomain.com.ssl.conf:148
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
    
    Here we go.....
     
    Last edited by a moderator: Sep 17, 2018
  6. eva2000

    eva2000 Administrator Staff Member

    55,396
    12,255
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,835
    Local Time:
    7:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    contents of /usr/local/nginx/conf/conf.d/yourdomain.com.ssl.conf ? you can use cat command to spit out contents to your SSH session window and do a copy and paste
    Code (Text):
    cat /usr/local/nginx/conf/conf.d/yourdomain.com.ssl.conf
    

    you can do a search and replace to mask your actual domain name and replace with dummy yourdomain.com too
     
  7. DaB

    DaB Member

    45
    5
    8
    Aug 10, 2016
    Ratings:
    +6
    Local Time:
    10:11 AM
    Current
    Current
    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    #server {
    #            listen   80;
    #            server_name mydomain.com.com www.mydomain.com.com;
    #            return 301 $scheme://www.mydomain.com.com$request_uri;
    #       }
    
    server {
     
      server_name mydomain.com.com www.mydomain.com.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
      #add_header Referrer-Policy "strict-origin-when-cross-origin";
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/mydomain.com.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/mydomain.com.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/mydomain.com.com/autoprotect-mydomain.com.com.conf;
      root /home/nginx/domains/mydomain.com.com/public;
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
    
      #include /usr/local/nginx/conf/wpincludes/mydomain.com.com/wpcacheenabler_mydomain.com.com.conf;
      include /usr/local/nginx/conf/wpincludes/mydomain.com.com/wpsupercache_mydomain.com.com.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/mydomain.com.com/rediscache_mydomain.com.com.conf; 
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
     
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # for wordpress super cache plugin
      try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
    
      # for wp cache enabler plugin
      #try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
    
      # Wordpress Permalinks
      #try_files $uri $uri/ /index.php?q=$uri&$args; 
    
      # Nginx level redis Wordpress
      # https://community.centminmod.com/posts/18828/
      #try_files $uri $uri/ /index.php?$args;
    
      }
    
    location ~* /(wp-login\.php) {
        limit_req zone=xwplogin burst=1 nodelay;
        #limit_conn xwpconlimit 30;
       # auth_basic "Private";
       # auth_basic_user_file /home/nginx/domains/mydomain.com.com/htpasswd_wplogin;   
        include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /(xmlrpc\.php) {
        limit_req zone=xwprpc burst=45 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /wp-admin/(load-scripts\.php) {
        limit_req zone=xwprpc burst=5 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /wp-admin/(load-styles\.php) {
        limit_req zone=xwprpc burst=5 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
      include /usr/local/nginx/conf/wpincludes/mydomain.com.com/wpsecure_mydomain.com.com.conf;
      include /usr/local/nginx/conf/php-wpsc.conf;
     
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/php-rediscache.conf;
      include /usr/local/nginx/conf/pre-staticfiles-local-mydomain.com.com.conf;
      include /usr/local/nginx/conf/pre-staticfiles-global.conf;
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
     
      location /community/ {
        try_files $uri $uri/ /community/index.php?$uri&$args;
        index index.php index.html;
    }
    
    location /community/install/data/ {
        internal;
    }
    location /community/install/templates/ {
        internal;
    }
    location /community/internal_data/ {
        internal;
    }
    location /community/library/ { #legacy
        internal;
    }
    location /community/src/ {
        internal;
    }
    
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params;
    }
    
     
  8. eva2000

    eva2000 Administrator Staff Member

    55,396
    12,255
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,835
    Local Time:
    7:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    you had xenforo rules outside of server{} context and probably need something like below removing the php context which can be done with php.conf include file
    Code (Text):
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    #server {
    #            listen   80;
    #            server_name mydomain.com.com www.mydomain.com.com;
    #            return 301 $scheme://www.mydomain.com.com$request_uri;
    #       }
    
    server {
    
      server_name mydomain.com.com www.mydomain.com.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
      #add_header Referrer-Policy "strict-origin-when-cross-origin";
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/mydomain.com.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/mydomain.com.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/mydomain.com.com/autoprotect-mydomain.com.com.conf;
      root /home/nginx/domains/mydomain.com.com/public;
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
    
      #include /usr/local/nginx/conf/wpincludes/mydomain.com.com/wpcacheenabler_mydomain.com.com.conf;
      include /usr/local/nginx/conf/wpincludes/mydomain.com.com/wpsupercache_mydomain.com.com.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/mydomain.com.com/rediscache_mydomain.com.com.conf;
     
      include /usr/local/nginx/conf/wpincludes/mydomain.com.com/wpsecure_mydomain.com.com.conf;
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # for wordpress super cache plugin
      try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
    
      # for wp cache enabler plugin
      #try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
    
      # Wordpress Permalinks
      #try_files $uri $uri/ /index.php?q=$uri&$args;
    
      # Nginx level redis Wordpress
      # https://community.centminmod.com/posts/18828/
      #try_files $uri $uri/ /index.php?$args;
    
      }
    
    location ~* /(wp-login\.php) {
        limit_req zone=xwplogin burst=1 nodelay;
        #limit_conn xwpconlimit 30;
       # auth_basic "Private";
       # auth_basic_user_file /home/nginx/domains/mydomain.com.com/htpasswd_wplogin;  
        include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /(xmlrpc\.php) {
        limit_req zone=xwprpc burst=45 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /wp-admin/(load-scripts\.php) {
        limit_req zone=xwprpc burst=5 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /wp-admin/(load-styles\.php) {
        limit_req zone=xwprpc burst=5 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
      location /community/ {
        try_files $uri $uri/ /community/index.php?$uri&$args;
        index index.php index.html;
        include /usr/local/nginx/conf/php.conf;
      }
    
      location /community/install/data/ {
          internal;
          include /usr/local/nginx/conf/php.conf;
      }
      location /community/install/templates/ {
          internal;
          include /usr/local/nginx/conf/php.conf;
      }
      location /community/internal_data/ {
          internal;
          include /usr/local/nginx/conf/php.conf;
      }
      location /community/library/ { 
          internal;
          include /usr/local/nginx/conf/php.conf;
      }
      location /community/src/ {
          internal;
          include /usr/local/nginx/conf/php.conf;
      }
    
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/php-rediscache.conf;
      include /usr/local/nginx/conf/pre-staticfiles-local-mydomain.com.com.conf;
      include /usr/local/nginx/conf/pre-staticfiles-global.conf;
      include /usr/local/nginx/conf/staticfiles.conf;
      #include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    
    }
    
     
  9. Breixo

    Breixo New Member

    2
    0
    1
    Feb 10, 2019
    Ratings:
    +1
    Local Time:
    11:11 AM
    Hi! Just registered only to write this.
    Firstly, thanks @eva2000 for your support.
    This post helped me, I was having the same error as DaB.

    Secondly, I recommend you add this solution here:
    Nginx Rewrites for Xenforo Friendly Urls - CentminMod.com LEMP Nginx web stack for CentOS
    Hope it helps and safe time and problems to the ones who just access the official tutorial.
    Thanks a lot!