Learn about Centmin Mod LEMP Stack today
Register Now

Create Multi Vhost Script

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by TRINH AI QUOC, Jun 1, 2021.

  1. TRINH AI QUOC

    TRINH AI QUOC New Member

    13
    1
    3
    Dec 28, 2020
    Ratings:
    +1
    Local Time:
    1:19 AM
    1.17.3
    10
    Hi All, and @eva2000 ^^


    i must change my web server, i have 250 domains.
    May anyone help me, how to make script to create multi vhost for centmin.sh
    Thanks you so much !!!
     
    Last edited: Jun 1, 2021
  2. eva2000

    eva2000 Administrator Staff Member

    54,363
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:19 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  3. TRINH AI QUOC

    TRINH AI QUOC New Member

    13
    1
    3
    Dec 28, 2020
    Ratings:
    +1
    Local Time:
    1:19 AM
    1.17.3
    10
    Sorry I searched but couldn't find it. Thank you very much eva2000. I am very grateful to you for your enthusiastic support, answering all members' questions.
    Have A Good Day !!!
     
  4. TRINH AI QUOC

    TRINH AI QUOC New Member

    13
    1
    3
    Dec 28, 2020
    Ratings:
    +1
    Local Time:
    1:19 AM
    1.17.3
    10
    hi @eva2000.
    i use nv command to create vhost.
    (I create 500 wordpress websites, but every time I configure website wordpress I have to remove the # tag manually in /usr/local/nginx/conf/conf.d
    file domain.ssl.conf
    Every time I remove the # tag I have to use nprestart (all the web will be paused when nprestart finish.)
    Is there a way to create a vhost then automatically remove the # tag in
    # Wordpress Permalinks example
    # try_files $uri $uri/ /index.php?q=$uri&$args;

    centminmod auto create file domain.ssl.conf

    [​IMG]

    i want to file domain.ssl.conf on /usr/local/nginx/conf/conf.d auto remove tag # like this.
    [​IMG]

    Please help me @eva2000 .
    Thanks Full !!!
     
  5. eva2000

    eva2000 Administrator Staff Member

    54,363
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:19 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  6. eva2000

    eva2000 Administrator Staff Member

    54,363
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:19 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Back on desktop now, so for sed replacement as per that link for yours would be like

    for single domain nginx vhost
    Code (Text):
    domain=yourdomain.com
    sed -i "s|#try_files \$uri \$uri\/ \/index.php?q=\$uri\&\$args;| try_files \$uri \$uri\/ \/index.php?q=\$uri\&\$args;|" /usr/local/nginx/cpnf/conf.d/$domain.ssl.conf
    

    or for bulk domains listed in a file /home/vhostlist.txt
    Code (Text):
    while read -r d; do echo "update /usr/local/nginx/cpnf/conf.d/${d}.ssl.conf"; sed -i "s|#try_files \$uri \$uri\/ \/index.php?q=\$uri\&\$args;| try_files \$uri \$uri\/ \/index.php?q=\$uri\&\$args;|" /usr/local/nginx/cpnf/conf.d/${d}.ssl.conf; done < /home/vhostlist.txt
    

    where /home/vhostlist.txt contains list of domains
    Code (Text):
    domain1.com
    domain2.com
    domain3.com
    

    I'd test this on a separate test bulk nv command run on a test server first
     
  7. eva2000

    eva2000 Administrator Staff Member

    54,363
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:19 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    FYI, I am working on a new advance method for bulk Nginx vhost creation using JSON config files https://community.centminmod.com/th...00beta01-release-discussion.22676/#post-93300

    A very early alpha version can be previewed at GitHub - centminmod/centminmod-config-json not ready for production use, but gives you an idea of what's to come :)
     
  8. TRINH AI QUOC

    TRINH AI QUOC New Member

    13
    1
    3
    Dec 28, 2020
    Ratings:
    +1
    Local Time:
    1:19 AM
    1.17.3
    10
    Thank you so much !!!
    I solved my issue.