Create a WordPress site data with Nginx app data automatically

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
3
down vote

favorite
2












The following script is aimed for Ubuntu >=16.04 LEMP environments with PHP-FPM >=7.0, MySQL, WP-CLI, Certbot, and WordPress apps.



The script get's one domain as an argument and creates the following aspects based on that argument (drt=document-root):



  1. WP_app directory in drt.

  2. WP_installation in drt/domain.

  3. WP_conf in drt/domain.

  4. NX_app conf in /etc/nginx/sites-available/

  5. NX_symlink in /etc/nginx/sites-enabled/

  6. NX_certbot configuration.

$drt = document root.




One could then add a database stack via MySQL, accordingly (and also edit the website files, accordingly).



#!/bin/bash
domain="$1" && test -z $domain && return
read -sp "DB user password:" dbuserp

wp core download --path=$drt/$domain/ --allow-root # REDUNDANTS MKDIR
wp config create --path=$drt/$domain/ --dbname=$domain --dbuser=$domain --dbpass=$dbuserp --dbhost="localhost" --allow-root

cat ~/myAddons/nginx_app > $sava/$domain.conf
sed -i "s/$domain/$1/g" /$sava/$domain.conf

ln -sf $sava/$domain.conf $sena
certbot --nginx -d $domain -d www.$domain

chown -R www-data:www-data $drt/
chmod -R a-x,a=rX,u+w $drt/
/etc/init.d/php*-fpm restart && systemctl restart nginx.service

echo "Please configure DBstack in phpmyadmin."
echo "Please change permissions as you prefer and restart the Nginx server."


Clarification



The conf template I redirect from ~/nginx_app, for the Nginx app conf, is this one:



server ttf



Please share your opinion on the above script and adjacent conf file.







share|improve this question



























    up vote
    3
    down vote

    favorite
    2












    The following script is aimed for Ubuntu >=16.04 LEMP environments with PHP-FPM >=7.0, MySQL, WP-CLI, Certbot, and WordPress apps.



    The script get's one domain as an argument and creates the following aspects based on that argument (drt=document-root):



    1. WP_app directory in drt.

    2. WP_installation in drt/domain.

    3. WP_conf in drt/domain.

    4. NX_app conf in /etc/nginx/sites-available/

    5. NX_symlink in /etc/nginx/sites-enabled/

    6. NX_certbot configuration.

    $drt = document root.




    One could then add a database stack via MySQL, accordingly (and also edit the website files, accordingly).



    #!/bin/bash
    domain="$1" && test -z $domain && return
    read -sp "DB user password:" dbuserp

    wp core download --path=$drt/$domain/ --allow-root # REDUNDANTS MKDIR
    wp config create --path=$drt/$domain/ --dbname=$domain --dbuser=$domain --dbpass=$dbuserp --dbhost="localhost" --allow-root

    cat ~/myAddons/nginx_app > $sava/$domain.conf
    sed -i "s/$domain/$1/g" /$sava/$domain.conf

    ln -sf $sava/$domain.conf $sena
    certbot --nginx -d $domain -d www.$domain

    chown -R www-data:www-data $drt/
    chmod -R a-x,a=rX,u+w $drt/
    /etc/init.d/php*-fpm restart && systemctl restart nginx.service

    echo "Please configure DBstack in phpmyadmin."
    echo "Please change permissions as you prefer and restart the Nginx server."


    Clarification



    The conf template I redirect from ~/nginx_app, for the Nginx app conf, is this one:



    server ttf



    Please share your opinion on the above script and adjacent conf file.







    share|improve this question























      up vote
      3
      down vote

      favorite
      2









      up vote
      3
      down vote

      favorite
      2






      2





      The following script is aimed for Ubuntu >=16.04 LEMP environments with PHP-FPM >=7.0, MySQL, WP-CLI, Certbot, and WordPress apps.



      The script get's one domain as an argument and creates the following aspects based on that argument (drt=document-root):



      1. WP_app directory in drt.

      2. WP_installation in drt/domain.

      3. WP_conf in drt/domain.

      4. NX_app conf in /etc/nginx/sites-available/

      5. NX_symlink in /etc/nginx/sites-enabled/

      6. NX_certbot configuration.

      $drt = document root.




      One could then add a database stack via MySQL, accordingly (and also edit the website files, accordingly).



      #!/bin/bash
      domain="$1" && test -z $domain && return
      read -sp "DB user password:" dbuserp

      wp core download --path=$drt/$domain/ --allow-root # REDUNDANTS MKDIR
      wp config create --path=$drt/$domain/ --dbname=$domain --dbuser=$domain --dbpass=$dbuserp --dbhost="localhost" --allow-root

      cat ~/myAddons/nginx_app > $sava/$domain.conf
      sed -i "s/$domain/$1/g" /$sava/$domain.conf

      ln -sf $sava/$domain.conf $sena
      certbot --nginx -d $domain -d www.$domain

      chown -R www-data:www-data $drt/
      chmod -R a-x,a=rX,u+w $drt/
      /etc/init.d/php*-fpm restart && systemctl restart nginx.service

      echo "Please configure DBstack in phpmyadmin."
      echo "Please change permissions as you prefer and restart the Nginx server."


      Clarification



      The conf template I redirect from ~/nginx_app, for the Nginx app conf, is this one:



      server ttf



      Please share your opinion on the above script and adjacent conf file.







      share|improve this question













      The following script is aimed for Ubuntu >=16.04 LEMP environments with PHP-FPM >=7.0, MySQL, WP-CLI, Certbot, and WordPress apps.



      The script get's one domain as an argument and creates the following aspects based on that argument (drt=document-root):



      1. WP_app directory in drt.

      2. WP_installation in drt/domain.

      3. WP_conf in drt/domain.

      4. NX_app conf in /etc/nginx/sites-available/

      5. NX_symlink in /etc/nginx/sites-enabled/

      6. NX_certbot configuration.

      $drt = document root.




      One could then add a database stack via MySQL, accordingly (and also edit the website files, accordingly).



      #!/bin/bash
      domain="$1" && test -z $domain && return
      read -sp "DB user password:" dbuserp

      wp core download --path=$drt/$domain/ --allow-root # REDUNDANTS MKDIR
      wp config create --path=$drt/$domain/ --dbname=$domain --dbuser=$domain --dbpass=$dbuserp --dbhost="localhost" --allow-root

      cat ~/myAddons/nginx_app > $sava/$domain.conf
      sed -i "s/$domain/$1/g" /$sava/$domain.conf

      ln -sf $sava/$domain.conf $sena
      certbot --nginx -d $domain -d www.$domain

      chown -R www-data:www-data $drt/
      chmod -R a-x,a=rX,u+w $drt/
      /etc/init.d/php*-fpm restart && systemctl restart nginx.service

      echo "Please configure DBstack in phpmyadmin."
      echo "Please change permissions as you prefer and restart the Nginx server."


      Clarification



      The conf template I redirect from ~/nginx_app, for the Nginx app conf, is this one:



      server ttf



      Please share your opinion on the above script and adjacent conf file.









      share|improve this question












      share|improve this question




      share|improve this question








      edited Feb 5 at 10:27
























      asked Feb 5 at 7:40









      user9303970

      1456




      1456




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          Shellcheck.net



          I strongly recommend to start using https://shellcheck.net/.
          Simply copy-paste your script,
          and it will tell you many issues with this code.



          Don't use return outside of functions



          The return statement only works within functions.
          You probably meant exit instead:



          domain="$1" && test -z "$domain" && exit


          Variables in command arguments



          Always double-quote variables in command arguments to prevent glob expansion and word splitting, for example:



          cat ~/myAddons/nginx_app > "$sava/$domain.conf"


          Inconsistent paths



          Here, the last argument of the second command starts with a /, but not the last argument of the first command:



          cat ~/myAddons/nginx_app > $sava/$domain.conf
          sed -i "s/$domain/$1/g" /$sava/$domain.conf


          I suspect the last arguments are intended to be the same in both of these commands. This is confusing.






          share|improve this answer























          • Oh thanks! sorry for not editing the question. About the inconsistent path. You meant that it's /$sava/$domain.conf instead $sava/$domain.conf? Yes, that's a mistake. About the chmod, interesting, I just counted on this example by Stephen Kitt. See this and also this, please.
            – user9303970
            Feb 10 at 8:26











          • Yeah it’s subtle but the a-x isn’t redundant, it ensures the X only sees directories.
            – Stephen Kitt
            Feb 10 at 16:15










          • @StephenKitt I see, I read the linked posts. As you mention in one of them, on Mac OS X the X is only applied in + operations. That's why I didn't notice in my tests with the a-x example here. Thanks!
            – janos
            Feb 10 at 17:17











          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f186788%2fcreate-a-wordpress-site-data-with-nginx-app-data-automatically%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          Shellcheck.net



          I strongly recommend to start using https://shellcheck.net/.
          Simply copy-paste your script,
          and it will tell you many issues with this code.



          Don't use return outside of functions



          The return statement only works within functions.
          You probably meant exit instead:



          domain="$1" && test -z "$domain" && exit


          Variables in command arguments



          Always double-quote variables in command arguments to prevent glob expansion and word splitting, for example:



          cat ~/myAddons/nginx_app > "$sava/$domain.conf"


          Inconsistent paths



          Here, the last argument of the second command starts with a /, but not the last argument of the first command:



          cat ~/myAddons/nginx_app > $sava/$domain.conf
          sed -i "s/$domain/$1/g" /$sava/$domain.conf


          I suspect the last arguments are intended to be the same in both of these commands. This is confusing.






          share|improve this answer























          • Oh thanks! sorry for not editing the question. About the inconsistent path. You meant that it's /$sava/$domain.conf instead $sava/$domain.conf? Yes, that's a mistake. About the chmod, interesting, I just counted on this example by Stephen Kitt. See this and also this, please.
            – user9303970
            Feb 10 at 8:26











          • Yeah it’s subtle but the a-x isn’t redundant, it ensures the X only sees directories.
            – Stephen Kitt
            Feb 10 at 16:15










          • @StephenKitt I see, I read the linked posts. As you mention in one of them, on Mac OS X the X is only applied in + operations. That's why I didn't notice in my tests with the a-x example here. Thanks!
            – janos
            Feb 10 at 17:17















          up vote
          2
          down vote



          accepted










          Shellcheck.net



          I strongly recommend to start using https://shellcheck.net/.
          Simply copy-paste your script,
          and it will tell you many issues with this code.



          Don't use return outside of functions



          The return statement only works within functions.
          You probably meant exit instead:



          domain="$1" && test -z "$domain" && exit


          Variables in command arguments



          Always double-quote variables in command arguments to prevent glob expansion and word splitting, for example:



          cat ~/myAddons/nginx_app > "$sava/$domain.conf"


          Inconsistent paths



          Here, the last argument of the second command starts with a /, but not the last argument of the first command:



          cat ~/myAddons/nginx_app > $sava/$domain.conf
          sed -i "s/$domain/$1/g" /$sava/$domain.conf


          I suspect the last arguments are intended to be the same in both of these commands. This is confusing.






          share|improve this answer























          • Oh thanks! sorry for not editing the question. About the inconsistent path. You meant that it's /$sava/$domain.conf instead $sava/$domain.conf? Yes, that's a mistake. About the chmod, interesting, I just counted on this example by Stephen Kitt. See this and also this, please.
            – user9303970
            Feb 10 at 8:26











          • Yeah it’s subtle but the a-x isn’t redundant, it ensures the X only sees directories.
            – Stephen Kitt
            Feb 10 at 16:15










          • @StephenKitt I see, I read the linked posts. As you mention in one of them, on Mac OS X the X is only applied in + operations. That's why I didn't notice in my tests with the a-x example here. Thanks!
            – janos
            Feb 10 at 17:17













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          Shellcheck.net



          I strongly recommend to start using https://shellcheck.net/.
          Simply copy-paste your script,
          and it will tell you many issues with this code.



          Don't use return outside of functions



          The return statement only works within functions.
          You probably meant exit instead:



          domain="$1" && test -z "$domain" && exit


          Variables in command arguments



          Always double-quote variables in command arguments to prevent glob expansion and word splitting, for example:



          cat ~/myAddons/nginx_app > "$sava/$domain.conf"


          Inconsistent paths



          Here, the last argument of the second command starts with a /, but not the last argument of the first command:



          cat ~/myAddons/nginx_app > $sava/$domain.conf
          sed -i "s/$domain/$1/g" /$sava/$domain.conf


          I suspect the last arguments are intended to be the same in both of these commands. This is confusing.






          share|improve this answer















          Shellcheck.net



          I strongly recommend to start using https://shellcheck.net/.
          Simply copy-paste your script,
          and it will tell you many issues with this code.



          Don't use return outside of functions



          The return statement only works within functions.
          You probably meant exit instead:



          domain="$1" && test -z "$domain" && exit


          Variables in command arguments



          Always double-quote variables in command arguments to prevent glob expansion and word splitting, for example:



          cat ~/myAddons/nginx_app > "$sava/$domain.conf"


          Inconsistent paths



          Here, the last argument of the second command starts with a /, but not the last argument of the first command:



          cat ~/myAddons/nginx_app > $sava/$domain.conf
          sed -i "s/$domain/$1/g" /$sava/$domain.conf


          I suspect the last arguments are intended to be the same in both of these commands. This is confusing.







          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited Feb 10 at 17:15


























          answered Feb 10 at 6:07









          janos

          95.6k12120343




          95.6k12120343











          • Oh thanks! sorry for not editing the question. About the inconsistent path. You meant that it's /$sava/$domain.conf instead $sava/$domain.conf? Yes, that's a mistake. About the chmod, interesting, I just counted on this example by Stephen Kitt. See this and also this, please.
            – user9303970
            Feb 10 at 8:26











          • Yeah it’s subtle but the a-x isn’t redundant, it ensures the X only sees directories.
            – Stephen Kitt
            Feb 10 at 16:15










          • @StephenKitt I see, I read the linked posts. As you mention in one of them, on Mac OS X the X is only applied in + operations. That's why I didn't notice in my tests with the a-x example here. Thanks!
            – janos
            Feb 10 at 17:17

















          • Oh thanks! sorry for not editing the question. About the inconsistent path. You meant that it's /$sava/$domain.conf instead $sava/$domain.conf? Yes, that's a mistake. About the chmod, interesting, I just counted on this example by Stephen Kitt. See this and also this, please.
            – user9303970
            Feb 10 at 8:26











          • Yeah it’s subtle but the a-x isn’t redundant, it ensures the X only sees directories.
            – Stephen Kitt
            Feb 10 at 16:15










          • @StephenKitt I see, I read the linked posts. As you mention in one of them, on Mac OS X the X is only applied in + operations. That's why I didn't notice in my tests with the a-x example here. Thanks!
            – janos
            Feb 10 at 17:17
















          Oh thanks! sorry for not editing the question. About the inconsistent path. You meant that it's /$sava/$domain.conf instead $sava/$domain.conf? Yes, that's a mistake. About the chmod, interesting, I just counted on this example by Stephen Kitt. See this and also this, please.
          – user9303970
          Feb 10 at 8:26





          Oh thanks! sorry for not editing the question. About the inconsistent path. You meant that it's /$sava/$domain.conf instead $sava/$domain.conf? Yes, that's a mistake. About the chmod, interesting, I just counted on this example by Stephen Kitt. See this and also this, please.
          – user9303970
          Feb 10 at 8:26













          Yeah it’s subtle but the a-x isn’t redundant, it ensures the X only sees directories.
          – Stephen Kitt
          Feb 10 at 16:15




          Yeah it’s subtle but the a-x isn’t redundant, it ensures the X only sees directories.
          – Stephen Kitt
          Feb 10 at 16:15












          @StephenKitt I see, I read the linked posts. As you mention in one of them, on Mac OS X the X is only applied in + operations. That's why I didn't notice in my tests with the a-x example here. Thanks!
          – janos
          Feb 10 at 17:17





          @StephenKitt I see, I read the linked posts. As you mention in one of them, on Mac OS X the X is only applied in + operations. That's why I didn't notice in my tests with the a-x example here. Thanks!
          – janos
          Feb 10 at 17:17













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f186788%2fcreate-a-wordpress-site-data-with-nginx-app-data-automatically%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Greedy Best First Search implementation in Rust

          Function to Return a JSON Like Objects Using VBA Collections and Arrays

          C++11 CLH Lock Implementation