Code Monkey home page Code Monkey logo

nginx-subdomain-generator-script's Introduction

nginx-subdomain-generator-script

A bash script that is creating subdomain with given parameters with Nginx in the directory /var/www. The original script and a tutorial on how to manually create server blocks can be found in here:

http://clubmate.fi/how-to-make-an-nginx-server-block-manually-or-with-a-shell-script/

I updated and modified the code in order to use it for adding subdomains to an existing system by using Nginx server blocks.

Usage

Download the file using wget:

# Download the file and save as SubdomainGenerator.sh
wget -O SubdomainGenerator.sh https://raw.githubusercontent.com/karakanb/nginx-subdomain-generator-script/master/SubdomainGenerator.sh

# Change mode of the script to executable.
chmod +x SubdomainGenerator.sh

# Run the script with the subdomain and the parent domain as the parameters.
sudo ./SubdomainGenerator.sh foo example.com

This will generate a subdomain as foo.example.com. Don't forget to create the subdomain from your DNS provider to point the same IP address of the server itself, this is out of Nginx's scope.

It uses standard Nginx config files, and creates the files to be served under the folder /var/www with the structure as /var/www/foo/public_html, or /var/www/mySubDomain/public_html. The choice of folder where to create the serving files can be edited with the $WEB_DIR variable in the beginning of the program.

For the sake of simplicity, a more basic syntax may be created with alias GenerateSubdomain='sudo ./SubdomainGenerator.sh', which allows you to call the command as GenerateSubdomain mysubdomain mymaindomain.com.


License

This script is licensed under the MIT License.

nginx-subdomain-generator-script's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.