Welcome to Centmin Mod Community
Become a Member

Wordpress Conf Setting for 404 not found permalink error on wordpress?

Discussion in 'Blogs & CMS usage' started by sfs00784, Nov 8, 2017.

  1. sfs00784

    sfs00784 New Member

    23
    3
    3
    Nov 8, 2017
    Ratings:
    +11
    Local Time:
    2:04 PM
    1. newest centinmin mod beta
    2. installed a wordpress in domain: hicentmin.com
    3. /home/nginx/domains/hicentmin.com/

    Problems: Use permalink and go to hicentmin.com/blog, it shows 404 not found

    Solutions?
    followed the setting in
    Nginx Wordpress Configuration - CentminMod.com LEMP Nginx web stack for CentOS
    and still not work.

    Is there any problems in my setting?

    location /hicentmin.com{
    include /usr/local/nginx/conf/wpsecure.conf;
    include /usr/local/nginx/conf/wpnocache.conf;

    try_files $uri $uri/ /index.php?q=$request_uri;
    }


    wpnocache.conf 100% as instructed
    wpsecure.conf 100% as instructed
     
    Last edited: Nov 8, 2017
  2. eva2000

    eva2000 Administrator Staff Member

    30,577
    6,854
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,275
    Local Time:
    4:04 PM
    Nginx 1.13.x
    MariaDB 5.5
    yes that is misconfigured and incorrect .. which guide are you following ? if you're following Nginx Wordpress Configuration - CentminMod.com LEMP Nginx web stack for CentOS for /blog would be

    Code (Text):
           location /blog {
    include /usr/local/nginx/conf/wpsecure.conf;
    include /usr/local/nginx/conf/wpnocache.conf;
    
           try_files $uri $uri/ /blog/index.php?q=$request_uri;
           }
    


    Probably easier to use centmin.sh menu option 22 wordpress installer Wordpress Nginx Auto Installer (WP Super Cache) if you remove the existing install and nginx vhost = How to delete Nginx vhost account for existing domain/subdomain ?

    You can opt to install wordpress in subdirectory /blog when running centmin.sh menu option 22 wordpress installation when asked to install in subdirectory. By default centmin.sh menu option 22 wordpress installation installs to web root / not to subdirectory.

    When you create a new nginx vhost domain via centmin.sh menu option 2 or menu option 22 or via /usr/bin/nv cli command line, you will create the Nginx vhost files and directories. You will get an outputted the path location where it will create the domain name's vhost conf file named newdomain.com.conf (and newdomain.com.ssl.conf if you selected yes to self signed SSL)
    • Nginx vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.conf
    • Nginx HTTP/2 SSL vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
    • Nginx Self-Signed SSL Certificate Directory at /usr/local/nginx/conf/ssl/newdomain.com
    • Vhost public web root will be at /home/nginx/domains/newdomain.com/public
    • Vhost log directory will be at /home/nginx/domains/newdomain.com/log
    Please post the contents of /usr/local/nginx/conf/conf.d/newdomain.com.conf and if applicable /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf wrapped in CODE tags (outlined at How to use forum BBCODE code tags)

    Troubleshooting Centmin Mod Menu Option 22 Wordpress Install Run



    To troubleshoot centmin.sh menu option 22 wordpress installation, you need to check the centmin.sh menu option 22 log located in /root/centminlogs at /root/centminlogs/centminmod_*_wordpress_addvhost.log based log where * is the centminmod version and date timestamp. Edit and mask any actual ftp username/password or wordpress usernames and logins before posting the log contents to Pastebin.com or Gists to share a sanitised version of the contents of the log.

    Example list /root/centminlogs files in date ascending order and grep for wordpress_addvhost.log
    Code (Text):
    ls -lahrt /root/centminlogs | grep wordpress_addvhost.log
    

    example output returns log at /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-112321_wordpress_addvhost.log
    Code (Text):
    ls -lahrt /root/centminlogs | grep wordpress_addvhost.log
    -rw-r--r--  1 root root 2.2M Oct 11 01:40 /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-112321_wordpress_addvhost.log
    

    in SSH use cat to ouput contents of /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-112321_wordpress_addvhost.log. Clear your SSH client window/buffer so only output is the contents of the file
    Code (Text):
    cat /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-112321_wordpress_addvhost.log
    

    Then copy and paste into Pastebin.com or Gists entry. If your SSH window scroll buffer isn't that large to get the whole contents of the install log, you can download file manually and copy and paste contents. But makes sure it's sanitised version of the contents without revealing sensitive info. For example you can replace domain name of the wordpress site with generic dummy entry = domain.com if you want and mask site/server IP revealed in the log with generic dummy entry = 111.222.333.444.

    As per 6 steps to learning more about Centmin Mod, setup a test vps for centmin mod testing so you can learn the ropes without messing with live sites :)
     
  3. sfs00784

    sfs00784 New Member

    23
    3
    3
    Nov 8, 2017
    Ratings:
    +11
    Local Time:
    2:04 PM
    Dear eva2000

    Ok, i made it work. thanks.

    FYI:
    1. Can't use the option 22 as i am switching from vestcp to centminmod. need to restore database, plugin, etc.
    2. Nginx Wordpress Configuration - CentminMod.com LEMP Nginx web stack for CentOS
    this tutorial may need to update, a bit difficult to comprehend

    Working solution:

    Precondition
    :
    WordPress was installed in root domain
    (paths like this: hicentmin.com, hicentmin.com/wp-admin/)

    1. Edit /usr/local/nginx/conf/conf.d/hicentmin.com.conf
    and /usr/local/nginx/conf/conf.d/hicentmin.com.ssl.conf

    add these three lines inside location / { }
    Code:
      include /usr/local/nginx/conf/wpsecure.conf;
      include /usr/local/nginx/conf/wpnocache.conf;
      try_files $uri $uri/ /index.php?q=$uri&$args;
    
    *Note: if your wordpress was installed in hicentmin.com/blog, scroll to the bottom of
    /usr/local/nginx/conf/conf.d/hicentmin.com.conf
    and /usr/local/nginx/conf/conf.d/hicentmin.com.ssl.conf
    and add this
    Code:
          location /blog {
            include /usr/local/nginx/conf/wpsecure.conf;
            include /usr/local/nginx/conf/wpnocache.conf;
            try_files $uri $uri/ /blog/index.php?q=$request_uri;
          }
    
    2. Create a file named wpsecure.conf at /usr/local/nginx/conf/wpsecure.conf and add following lines:
    Code:
    # Deny access to any files with a .php extension in the uploads directory
    # Works in sub-directory installs and also in multisite network
    location ~* /(?:uploads|files)/.*\.php$ {
           deny all;
    }
    
    # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
    location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_
    {
           return 444;
    }
    
    #nocgi
    location ~* \.(pl|cgi|py|sh|lua)\$ {
           return 444;
    }
    
    #disallow
       location ~* (roundcube|webdav|smtp|http\:|soap|w00tw00t) {
           return 444;
    }
    
    location ~ /(\.|wp-config\.php|readme\.html|license\.txt) { deny all; }
    

    3. Create a file named wpnocache.conf at /usr/local/nginx/conf/wpnocache.conf and add following lines:

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

    4. Restart your server

    ngxrestart
     
    Last edited: Nov 9, 2017
    • Informative Informative x 1
  4. eva2000

    eva2000 Administrator Staff Member

    30,577
    6,854
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,275
    Local Time:
    4:04 PM
    Nginx 1.13.x
    MariaDB 5.5
    yes that tutorial is old now that centmin.sh menu option 22 and vhost generator exists Generate Centmin Mod Nginx Vhost - CentminMod.com LEMP Nginx web stack for CentOS

    i see, if old wp installed on web root / you can use centmin.sh menu option 22 and just edit wp-config.php and restore/overwrite web root /home/nginx/domains/domain.com/public files with your old wp files as well
     
  5. sfs00784

    sfs00784 New Member

    23
    3
    3
    Nov 8, 2017
    Ratings:
    +11
    Local Time:
    2:04 PM
    Any fast database restore method for option 22?
    My method is: mysql -u mydbusername -p wp_database < database.sql
     
  6. eva2000

    eva2000 Administrator Staff Member

    30,577
    6,854
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,275
    Local Time:
    4:04 PM
    Nginx 1.13.x
    MariaDB 5.5
    your method is fastest and recommended way :)