Welcome to Centmin Mod Community
Register Now

Wordpress change domain for Option 22 installation

Discussion in 'Blogs & CMS usage' started by hitman, Jul 22, 2016.

  1. hitman

    hitman Member

    126
    11
    18
    Jul 18, 2014
    Ratings:
    +15
    Local Time:
    9:37 PM
    hello
    i have already a wp installation using option 22 on centminmod ---example.com
    and i want to change the domain to example2.com
    could you please suggest what is the best way to change the domain ?

    thank you

     
  2. eva2000

    eva2000 Administrator Staff Member

    55,239
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    4:37 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  3. hitman

    hitman Member

    126
    11
    18
    Jul 18, 2014
    Ratings:
    +15
    Local Time:
    9:37 PM
    thank you
    i have created another domain name (vhost) through option 2 and i rsync the files from the directory of my old-domain, plus i created a duplicate database and configured the new-domain to use this database.
    i then run the wp search-replace command

    almost everything worked fine, i have some problems with css but i think i have resolved them for now.
    Do you see anything wrong with the procedure i followed? Am i missing something?

    Also now that i want to redirect my old-domain to the new-domain i edited the file
    /usr/local/nginx/conf/conf.d/old-domain.com.conf and added on top
    Code:
    server {
              listen   80;
    server_name old-domain.com www.old-domain.com;
    return 301 $scheme://www.new-domain.com$request_uri;
           }
    but my problem is that the redirect for the Old-domain.com - Ready For Development does not work
     
  4. eva2000

    eva2000 Administrator Staff Member

    55,239
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    4:37 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    looks about right you should test with 302 temp redirect and not 301 first to make sure as browser permanent 301 cache gets stuck in browser also test with incognito browser sessions

    clear all browser caches and try curl header to check
    Code (Text):
    curl -I http://www.old-domain.com/


    example test 301/302 for http see Location field should show redirect
    Code (Text):
    curl -I http://sslspdy.com/
    HTTP/1.1 301 Moved Permanently
    Server: nginx centminmod
    Date: Tue, 02 Aug 2016 11:30:53 GMT
    Content-Type: text/html
    Content-Length: 178
    Connection: keep-alive
    Location: https://sslspdy.com/
    X-Powered-By: centminmod
    Expires: Tue, 02 Aug 2016 12:30:53 GMT
    Cache-Control: max-age=3600
    Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate, max-age=3600, s-maxage=3600
     
    Last edited: Aug 2, 2016
  5. hitman

    hitman Member

    126
    11
    18
    Jul 18, 2014
    Ratings:
    +15
    Local Time:
    9:37 PM
    Code:
    [root@hostname conf.d]# curl -I http://old-domain.com
    HTTP/1.1 302 Moved Temporarily
    Date: Tue, 02 Aug 2016 11:47:35 GMT
    Content-Type: text/html
    Content-Length: 154
    Connection: keep-alive
    Location: http://www.new-domain.com/
    X-Powered-By: centminmod
    
    [root@hostname conf.d]# curl -I http://www.old-domain.com
    HTTP/1.1 200 OK
    Date: Tue, 02 Aug 2016 11:47:57 GMT
    Content-Type: text/html; charset=utf-8
    Content-Length: 3801
    Last-Modified: Thu, 19 May 2016 15:54:03 GMT
    Connection: keep-alive
    Vary: Accept-Encoding
    ETag: "573de19b-ed9"
    X-Powered-By: centminmod
    Expires: Wed, 03 Aug 2016 11:47:57 GMT
    Cache-Control: max-age=86400
    Cache-Control: public, must-revalidate, proxy-revalidate
    Accept-Ranges: bytes
    
    
    these are the results with 302 with www and non-www
    any ideas?
     
  6. eva2000

    eva2000 Administrator Staff Member

    55,239
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    4:37 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    check if you have any vhosts with duplicate mention of server_name listed for
    Old-domain.com - Ready For Development
    Code (Text):
    grep -R 'www.old-domain.com' /usr/local/nginx/conf/*

    Code (Text):
    grep -R 'www.old-domain.com' /usr/local/nginx/conf/* | grep server_name
     
  7. hitman

    hitman Member

    126
    11
    18
    Jul 18, 2014
    Ratings:
    +15
    Local Time:
    9:37 PM
    nop tried it , it is only on
    /usr/local/nginx/conf/conf.d/old-domain.conf
     
  8. eva2000

    eva2000 Administrator Staff Member

    55,239
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    4:37 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    strange then no ideas off top of my head
     
  9. hitman

    hitman Member

    126
    11
    18
    Jul 18, 2014
    Ratings:
    +15
    Local Time:
    9:37 PM
    some additional information in case it helps somehow
    when i visit the
    Code:
    www.old-domain.com
    i get the page of centminmod from here /usr/local/nginx/html


    RESOLVED
    i edited the server_name as follows
    Code:
    server_name .old-domain.com;
     
    Last edited: Aug 2, 2016
  10. eva2000

    eva2000 Administrator Staff Member

    55,239
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    4:37 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    ah you had main hostname same as additional hostname. main hostname outlined in Getting Started Guide step 1 needs main hostname unique and not same as any domain added to server
     
  11. hitman

    hitman Member

    126
    11
    18
    Jul 18, 2014
    Ratings:
    +15
    Local Time:
    9:37 PM
    also another weird thing is that if i remove this line from the new-domain.com.conf file
    Code:
     try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
    then i get 404 in every page except home
    please note that i use cdnenabler and not supercache, i had supercache and i removed it
     
  12. eva2000

    eva2000 Administrator Staff Member

    55,239
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    4:37 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    contents of new-domain.com.conf ?
     
  13. hitman

    hitman Member

    126
    11
    18
    Jul 18, 2014
    Ratings:
    +15
    Local Time:
    9:37 PM
    Code:
    server {
     
      server_name newdomain.com www.newdomain.com;
    
      access_log /home/nginx/domains/newdomain.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/newdomain.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/newdomain.com/autoprotect-newdomain.com.conf;
      root /home/nginx/domains/newdomain.com/public;
      include /usr/local/nginx/conf/503include-main.conf;
    
      # prevent access to ./directories and files
      location ~ (?:^|/)\. {
       deny all;
       
      } 
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
       
    # for wordpress super cache plugin
      try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$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/newdomain.com/htpasswd_wplogin;   
        include /usr/local/nginx/conf/php-wpsc.conf;
    }
    
    location ~* /(xmlrpc\.php) {
        limit_req zone=xwprpc burst=45 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
    }
    
    
      include /usr/local/nginx/conf/wpsecure_newdomain.com.conf;
      include /usr/local/nginx/conf/php-wpsc.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;
    }
    i removed most lines which are commented for cleaner looks
     
  14. eva2000

    eva2000 Administrator Staff Member

    55,239
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    4:37 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    there's your 404 problem, you removed 2 commented out lines for keycdn cache which is commented as such

    see Wordpress - WP Cacher Enabler Plugin by KeyCDN folks | Centmin Mod Community (manual switch from wp super cache to keycdn cache enabler)

    123.09beta01 centmin.sh option 22 would have had the following 3 include lines where ${vhostname} is replace with your domain name
    Code (Text):
    #include /usr/local/nginx/conf/wpincludes/${vhostname}/wpcacheenabler_${vhostname}.conf;
      include /usr/local/nginx/conf/wpincludes/${vhostname}/wpsupercache_${vhostname}.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/${vhostname}/rediscache_${vhostname}.conf;  
    

    to enable keycdn cache, you would need to comment out
    Code (Text):
    include /usr/local/nginx/conf/wpincludes/${vhostname}/wpsupercache_${vhostname}.conf

    and uncomment the include line for /usr/local/nginx/conf/wpincludes/${vhostname}/wpcacheenabler_${vhostname}.conf so it becomes
    Code (Text):
    include /usr/local/nginx/conf/wpincludes/${vhostname}/wpcacheenabler_${vhostname}.conf;
    #include /usr/local/nginx/conf/wpincludes/${vhostname}/wpsupercache_${vhostname}.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/${vhostname}/rediscache_${vhostname}.conf;  
    

    similarly, you would also had 3 try_files lines 2 in your case possible commented out for keycdn cache enabler and redis and enabled (uncommented for wpsuper cache).
    Code (Text):
      # 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;  
    

    you'd want to uncomment one for keycdn cache enabler and comment out one for wp super cache
    Code (Text):
      # for wordpress super cache plugin
      #try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ ${WPSUBDIR}/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/ ${WPSUBDIR}/index.php?q=$uri&$args;  
    

    above would assume you have installed keycdn cacher enabler wordpress plugin as outlined Wordpress - WP Cacher Enabler Plugin by KeyCDN folks | Centmin Mod Community

    centmin.sh menu option 22 in 123.09beta01 would of auto defaulted to keycdn cache enabler plugin install and above setup if you let it use defaults. If you at prompt switched to wp super cache during centmin.sh menu option 22 run, then you would of defaulted to wp super cache with the keycdn cache enabler and redis releveant lines commented out.