Discover Centmin Mod today
Register Now

Ability to rename vhost

Discussion in 'Feature Requests & Suggestions' started by matt.king, Sep 10, 2015.

Tags:
  1. matt.king

    matt.king New Member

    6
    0
    1
    Aug 27, 2015
    Ratings:
    +0
    Local Time:
    8:32 PM
    I did a search and didn't see the ability so I thought i might submit this here.

    I thought it would be grand to be able to rename a vhost after it has been created.


    For example i generally like to build a rough framework of a build and then replicate it as needed. (I use Amazon) I frequently have to spin up new websites built on Wordpress so currently I clone my Centmin mod AMI, then I create a new vhost. Then I add all my Wordpress customizations to the new vhost.
    If I could rename the vhost every time I launched a new one I would not have to redo all the Wordpress customization's I need to add to the NGINX configs.

    I'm open to suggestions too if you all might have another idea I might be missing.

    -matt
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,860
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    8:32 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    It's pretty easy to do, just edit the nginx vhost config files and directory structure paths outlined at Centmin Mod Configuration Files - CentminMod.com LEMP Nginx web stack for CentOS

    so rename the following directories and config file references to the old domain to new domain for

    • /usr/local/nginx/conf/conf.d/virtual.conf - for main hostname
    • /home/nginx/domains/yourdomain.com/
    • /usr/local/nginx/conf/conf.d/yourdomain.com.conf - http Nginx vhost configuration file for your site.
    • /usr/local/nginx/conf/conf.d/yourdomain.com.ssl.conf - https Nginx vhost configuration file for your site if you elected to setup self-signed SSL certificate at Nginx vhost creation time via centmin.sh menu option 2
    • /usr/local/nginx/conf/ssl/yourdomain.com/
    however, Wordpress database itself will have references to the old domain still so would need something like WordPress Serialized PHP Search Replace Tool | Interconnect IT - WordPress Consultants, Web Development and Web Design

    edit: might be a problem with pure-ftpd virtual ftp user setup though Pure-FTPD Virtual FTP Users - CentminMod.com LEMP Nginx web stack for CentOS as it would be tied to old domain name so would need resetting up for new domain name. Easy way would be create a new domain vhost via centmin.sh 2 first. Then just move your existing old domain structure to override the new domain and redit the config files for new domain
     
    Last edited: Sep 10, 2015
  3. matt.king

    matt.king New Member

    6
    0
    1
    Aug 27, 2015
    Ratings:
    +0
    Local Time:
    8:32 PM
    True, I was just hoping to save a few steps. I suppose I could write a script to hit all those folders. It looks like nothing needs changed inside files so that helps a lot.

    Thanks. :)
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,860
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    8:32 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    well if those custom nginx vhost conf changes are common to all sites just use an include file like i do for default nginx vhosts as you can see Nginx Vhost & NSD DNS Setup - CentminMod.com LEMP Nginx web stack for CentOS

    common include file for static files at /usr/local/nginx/conf/staticfiles.conf included in every vhost, so to edit your vhost it would be include line referencing a custom file with all your custom edits
    Code:
    include /usr/local/nginx/conf/staticfiles.conf;
     
  5. matt.king

    matt.king New Member

    6
    0
    1
    Aug 27, 2015
    Ratings:
    +0
    Local Time:
    8:32 PM
    Good tips. I have two options to think about now, thanks. :)
     
  6. eva2000

    eva2000 Administrator Staff Member

    54,860
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    8:32 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yeah and if you're lazy, just use one of existing include files and add your custom edits.. i.e. add your custom config settings into /usr/local/nginx/conf/staticfiles.conf which is already included by all vhosts by default :)