Join the community today
Become a Member

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:
    6:14 AM
    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

    30,156
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    6:14 AM
    Nginx 1.13.x
    MariaDB 5.5
    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:
    6:14 AM
    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

    30,156
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    6:14 AM
    Nginx 1.13.x
    MariaDB 5.5
    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:
    6:14 AM
    Good tips. I have two options to think about now, thanks. :)
     
  6. eva2000

    eva2000 Administrator Staff Member

    30,156
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    6:14 AM
    Nginx 1.13.x
    MariaDB 5.5
    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 :)