Welcome to Centmin Mod Community
Become a Member

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

    8
    1
    3
    Dec 28, 2020
    Ratings:
    +1
    Local Time:
    9:43 PM
    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

    49,234
    11,291
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,567
    Local Time:
    12:43 AM
    Nginx 1.21.x
    MariaDB 10.x
  3. TRINH AI QUOC

    TRINH AI QUOC New Member

    8
    1
    3
    Dec 28, 2020
    Ratings:
    +1
    Local Time:
    9:43 PM
    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

    8
    1
    3
    Dec 28, 2020
    Ratings:
    +1
    Local Time:
    9:43 PM
    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

    49,234
    11,291
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,567
    Local Time:
    12:43 AM
    Nginx 1.21.x
    MariaDB 10.x
  6. eva2000

    eva2000 Administrator Staff Member

    49,234
    11,291
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,567
    Local Time:
    12:43 AM
    Nginx 1.21.x
    MariaDB 10.x
    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

    49,234
    11,291
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,567
    Local Time:
    12:43 AM
    Nginx 1.21.x
    MariaDB 10.x
    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

    8
    1
    3
    Dec 28, 2020
    Ratings:
    +1
    Local Time:
    9:43 PM
    1.17.3
    10
    Thank you so much !!!
    I solved my issue.