├── README.md ├── locale ├── en │ ├── virtualhost-nginx.pot │ └── virtualhost.pot ├── es-Ar │ ├── virtualhost-nginx.mo │ ├── virtualhost-nginx.po │ ├── virtualhost.mo │ └── virtualhost.po ├── pt_BR │ ├── virtualhost-nginx.mo │ ├── virtualhost-nginx.pot │ ├── virtualhost.mo │ └── virtualhost.pot ├── ru │ ├── virtualhost-nginx.pot │ └── virtualhost.pot └── tr │ ├── virtualhost-nginx.mo │ ├── virtualhost-nginx.po │ ├── virtualhost.mo │ └── virtualhost.po ├── virtualhost-centos.sh ├── virtualhost-nginx.sh └── virtualhost.sh /README.md: -------------------------------------------------------------------------------- 1 | Virtualhost Manage Script 2 | =========== 3 | 4 | Bash Script to allow create or delete apache/nginx virtual hosts on Ubuntu on a quick way. 5 | 6 | ## Installation ## 7 | 8 | 1. Download the script 9 | 2. Apply permission to execute: 10 | 11 | ``` 12 | $ chmod +x /path/to/virtualhost.sh 13 | ``` 14 | 15 | 3. Optional: if you want to use the script globally, then you need to copy the file to your /usr/local/bin directory, is better 16 | if you copy it without the .sh extension: 17 | 18 | ```bash 19 | $ sudo cp /path/to/virtualhost.sh /usr/local/bin/virtualhost 20 | ``` 21 | 22 | ### For Global Shortcut ### 23 | 24 | ```bash 25 | $ cd /usr/local/bin 26 | $ wget -O virtualhost https://raw.githubusercontent.com/RoverWire/virtualhost/master/virtualhost.sh 27 | $ chmod +x virtualhost 28 | $ wget -O virtualhost-nginx https://raw.githubusercontent.com/RoverWire/virtualhost/master/virtualhost-nginx.sh 29 | $ chmod +x virtualhost-nginx 30 | ``` 31 | 32 | ## Usage ## 33 | 34 | Basic command line syntax: 35 | 36 | ```bash 37 | $ sudo sh /path/to/virtualhost.sh [create | delete] [domain] [optional host_dir] 38 | ``` 39 | 40 | With script installed on /usr/local/bin 41 | 42 | ```bash 43 | $ sudo virtualhost [create | delete] [domain] [optional host_dir] 44 | ``` 45 | 46 | ### Examples ### 47 | 48 | to create a new virtual host: 49 | 50 | ```bash 51 | $ sudo virtualhost create mysite.dev 52 | ``` 53 | to create a new virtual host with custom directory name: 54 | 55 | ```bash 56 | $ sudo virtualhost create anothersite.dev my_dir 57 | ``` 58 | to delete a virtual host 59 | 60 | ```bash 61 | $ sudo virtualhost delete mysite.dev 62 | ``` 63 | 64 | to delete a virtual host with custom directory name: 65 | 66 | ``` 67 | $ sudo virtualhost delete anothersite.dev my_dir 68 | ``` 69 | ### Localization 70 | 71 | For Apache: 72 | 73 | ```bash 74 | $ sudo cp /path/to/locale//virtualhost.mo /usr/share/locale//LC_MESSAGES/ 75 | ``` 76 | 77 | For NGINX: 78 | 79 | ```bash 80 | $ sudo cp /path/to/locale//virtualhost-nginx.mo /usr/share/locale//LC_MESSAGES/ 81 | ``` 82 | -------------------------------------------------------------------------------- /locale/en/virtualhost-nginx.pot: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Virtualhost Manage Script NGINX \n" 4 | "Last-Translator: \n" 5 | "MIME-Version: 1.0\n" 6 | "Content-Type: text/plain; charset=UTF-8\n" 7 | "Content-Transfer-Encoding: 8bit\n" 8 | 9 | #: virtualhost-nginx.sh:15 10 | msgid "You have no permission to run $0 as non-root user. Use sudo" 11 | msgstr "" 12 | #: virtualhost-nginx.sh:21 13 | msgid "You need to prompt for action (create or delete) -- Lower-case only" 14 | msgstr "" 15 | #: virtualhost-nginx.sh:27 16 | msgid "Please provide domain. e.g.dev,staging" 17 | msgstr "" 18 | #: virtualhost-nginx.sh:39 19 | msgid "This domain already exists.\\nPlease Try Another one" 20 | msgstr "" 21 | #: virtualhost-nginx.sh:52 22 | msgid "ERROR: Not able to write in file $userDir/$rootdir/phpinfo.php. Please check permissions." 23 | msgstr "" 24 | #: virtualhost-nginx.sh:55 25 | msgid "Added content to $userDir$rootdir/phpinfo.php." 26 | msgstr "" 27 | #: virtualhost-nginx.sh:104 28 | msgid "There is an ERROR create $domain file" 29 | msgstr "" 30 | #: virtualhost-nginx.sh:107 31 | msgid "\\nNew Virtual Host Created\\n" 32 | msgstr "" 33 | #: virtualhost-nginx.sh:113 34 | msgid "ERROR: Not able write in /etc/hosts" 35 | msgstr "" 36 | #: virtualhost-nginx.sh:116 37 | msgid "Host added to /etc/hosts file \\n" 38 | msgstr "" 39 | #: virtualhost-nginx.sh:132 40 | msgid "Complete! \\nYou now have a new Virtual Host \\nYour new host is: http://$domain \\nAnd its located at $userDir$rootdir" 41 | msgstr "" 42 | #: virtualhost-nginx.sh:137 43 | msgid "This domain dont exists.\\nPlease Try Another one" 44 | msgstr "" 45 | #: virtualhost-nginx.sh:156 46 | msgid "Delete host root directory ? (s/n)" 47 | msgstr "" 48 | #: virtualhost-nginx.sh:162 49 | msgid "Directory deleted" 50 | msgstr "" 51 | #: virtualhost-nginx.sh:164 52 | msgid "Host directory conserved" 53 | msgstr "" 54 | #: virtualhost-nginx.sh:167 55 | msgid "Host directory not found. Ignored" 56 | msgstr "" 57 | #: virtualhost-nginx.sh:171 58 | msgid "Complete!\\nYou just removed Virtual Host $domain" 59 | msgstr "" 60 | -------------------------------------------------------------------------------- /locale/en/virtualhost.pot: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Virtualhost Manage Script\n" 4 | "Last-Translator: \n" 5 | "MIME-Version: 1.0\n" 6 | "Content-Type: text/plain; charset=UTF-8\n" 7 | "Content-Transfer-Encoding: 8bit\n" 8 | 9 | #: virtualhost.sh:19 10 | msgid "You have no permission to run $0 as non-root user. Use sudo" 11 | msgstr "" 12 | #: virtualhost.sh:25 13 | msgid "You need to prompt for action (create or delete) -- Lower-case only" 14 | msgstr "" 15 | #: virtualhost.sh:31 16 | msgid "Please provide domain. e.g.dev,staging" 17 | msgstr "" 18 | #: virtualhost.sh:43 19 | msgid "This domain already exists.\\nPlease Try Another one" 20 | msgstr "" 21 | #: virtualhost.sh:56 22 | msgid "ERROR: Not able to write in file $userDir/$rootdir/phpinfo.php. Please check permissions." 23 | msgstr "" 24 | #: virtualhost.sh:59 25 | msgid "Added content to $userDir$rootdir/phpinfo.php." 26 | msgstr "" 27 | #: virtualhost.sh:83 28 | msgid "There is an ERROR create $domain file" 29 | msgstr "" 30 | #: virtualhost.sh:86 31 | msgid "\\nNew Virtual Host Created\\n" 32 | msgstr "" 33 | #: virtualhost.sh:92 34 | msgid "ERROR: Not able write in /etc/hosts" 35 | msgstr "" 36 | #: virtualhost.sh:95 37 | msgid "Host added to /etc/hosts file \\n" 38 | msgstr "" 39 | #: virtualhost.sh:111 40 | msgid "Complete! \\nYou now have a new Virtual Host \\nYour new host is: http://$domain \\nAnd its located at $userDir$rootdir" 41 | msgstr "" 42 | #: virtualhost.sh:116 43 | msgid "This domain dont exists.\\nPlease Try Another one" 44 | msgstr "" 45 | #: virtualhost.sh:135 46 | msgid "Delete host root directory ? (s/n)" 47 | msgstr "" 48 | #: virtualhost.sh:141 49 | msgid "Directory deleted" 50 | msgstr "" 51 | #: virtualhost.sh:143 52 | msgid "Host directory conserved" 53 | msgstr "" 54 | #: virtualhost.sh:146 55 | msgid "Host directory not found. Ignored" 56 | msgstr "" 57 | #: virtualhost.sh:150 58 | msgid "Complete!\\nYou just removed Virtual Host $domain" 59 | msgstr "" 60 | -------------------------------------------------------------------------------- /locale/es-Ar/virtualhost-nginx.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoverWire/virtualhost/8db0f7f2e3fb5dc27deac600d37be6edf1a7b5ef/locale/es-Ar/virtualhost-nginx.mo -------------------------------------------------------------------------------- /locale/es-Ar/virtualhost-nginx.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Virtualhost Manage Script NGINX\n" 4 | "MIME-Version: 1.0\n" 5 | "Content-Type: text/plain; charset=UTF-8\n" 6 | "Content-Transfer-Encoding: 8bit\n" 7 | "POT-Creation-Date: \n" 8 | "PO-Revision-Date: \n" 9 | "Language-Team: \n" 10 | "X-Generator: Poedit 1.8.7.1\n" 11 | "Last-Translator: \n" 12 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 13 | "Language: es_AR\n" 14 | 15 | #: virtualhost-nginx.sh:15 16 | msgid "You have no permission to run $0 as non-root user. Use sudo" 17 | msgstr "" 18 | "Usted no tiene permisos suficientes para correr $0 no es un usuario root. " 19 | "Use sudo" 20 | 21 | #: virtualhost-nginx.sh:21 22 | msgid "You need to prompt for action (create or delete) -- Lower-case only" 23 | msgstr "Es necesario una accion (create o delete) -- minuscula solamente." 24 | 25 | #: virtualhost-nginx.sh:27 26 | msgid "Please provide domain. e.g.dev,staging" 27 | msgstr "Por favor ingrese un dominio. ejemp: g.dev,staging" 28 | 29 | #: virtualhost-nginx.sh:39 30 | msgid "This domain already exists.\\nPlease Try Another one" 31 | msgstr "El Dominio ya existe.\\\\nPor favor ingrese otro." 32 | 33 | #: virtualhost-nginx.sh:52 34 | msgid "" 35 | "ERROR: Not able to write in file $userDir/$rootdir/phpinfo.php. Please check " 36 | "permissions." 37 | msgstr "" 38 | "ERROR: No se puede escribir el archivo en $userDir/$rootdir/phpinfo.php. Por " 39 | "favor chequee sus permisos." 40 | 41 | #: virtualhost-nginx.sh:55 42 | msgid "Added content to $userDir$rootdir/phpinfo.php." 43 | msgstr "Agregando contenido a $userDir$rootdir/phpinfo.php." 44 | 45 | #: virtualhost-nginx.sh:104 46 | msgid "There is an ERROR create $domain file" 47 | msgstr "Ocurrio un ERROR al crear el archivo $domain" 48 | 49 | #: virtualhost-nginx.sh:107 50 | msgid "\\nNew Virtual Host Created\\n" 51 | msgstr "\\\\nSe ha creado el nuevo Virtual Host\\\\n" 52 | 53 | #: virtualhost-nginx.sh:113 54 | msgid "ERROR: Not able write in /etc/hosts" 55 | msgstr "ERROR: No se puede escribir en /etc/hosts" 56 | 57 | #: virtualhost-nginx.sh:116 58 | msgid "Host added to /etc/hosts file \\n" 59 | msgstr "Host agregado a /etc/hosts \\\\n" 60 | 61 | #: virtualhost-nginx.sh:132 62 | msgid "" 63 | "Complete! \\nYou now have a new Virtual Host \\nYour new host is: http://" 64 | "$domain \\nAnd its located at $userDir$rootdir" 65 | msgstr "" 66 | "Completo! \\\\nAhora tienes un nuevo Virtual Host!! \\\\nTu nuevo host es: " 67 | "http://$domain \\\\ny esta localizado en $userDir$rootdir" 68 | 69 | #: virtualhost-nginx.sh:137 70 | msgid "This domain dont exists.\\nPlease Try Another one" 71 | msgstr "El dominio no existe.\\\\nPor favor pruebe con otro" 72 | 73 | #: virtualhost-nginx.sh:156 74 | msgid "Delete host root directory ? (s/n)" 75 | msgstr "Borrar host root directorio ? (s/n)" 76 | 77 | #: virtualhost-nginx.sh:162 78 | msgid "Directory deleted" 79 | msgstr "Directorio Borrado" 80 | 81 | #: virtualhost-nginx.sh:164 82 | msgid "Host directory conserved" 83 | msgstr "Directorio Host Conservado" 84 | 85 | #: virtualhost-nginx.sh:167 86 | msgid "Host directory not found. Ignored" 87 | msgstr "Directorio Host no encontrado. Ignorado" 88 | 89 | #: virtualhost-nginx.sh:171 90 | msgid "Complete!\\nYou just removed Virtual Host $domain" 91 | msgstr "Completado!\\\\nSeha removido el Virtual Host $domain" 92 | -------------------------------------------------------------------------------- /locale/es-Ar/virtualhost.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoverWire/virtualhost/8db0f7f2e3fb5dc27deac600d37be6edf1a7b5ef/locale/es-Ar/virtualhost.mo -------------------------------------------------------------------------------- /locale/es-Ar/virtualhost.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Virtualhost Manage Script\n" 4 | "MIME-Version: 1.0\n" 5 | "Content-Type: text/plain; charset=UTF-8\n" 6 | "Content-Transfer-Encoding: 8bit\n" 7 | "POT-Creation-Date: \n" 8 | "PO-Revision-Date: \n" 9 | "Language-Team: \n" 10 | "X-Generator: Poedit 1.8.7.1\n" 11 | "Last-Translator: \n" 12 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 13 | "Language: es_AR\n" 14 | 15 | #: virtualhost.sh:19 16 | msgid "You have no permission to run $0 as non-root user. Use sudo" 17 | msgstr "" 18 | "Usted no tiene permisos suficientes para correr $0 no es un usuario root. " 19 | "Use sudo" 20 | 21 | #: virtualhost.sh:25 22 | msgid "You need to prompt for action (create or delete) -- Lower-case only" 23 | msgstr "Es necesario una accion (create o delete) -- minuscula solamente." 24 | 25 | #: virtualhost.sh:31 26 | msgid "Please provide domain. e.g.dev,staging" 27 | msgstr "Por favor ingrese un dominio. ejemp: g.dev,staging" 28 | 29 | #: virtualhost.sh:43 30 | msgid "This domain already exists.\\nPlease Try Another one" 31 | msgstr "El Dominio ya existe.\\nPor favor ingrese otro." 32 | 33 | #: virtualhost.sh:56 34 | msgid "" 35 | "ERROR: Not able to write in file $userDir/$rootdir/phpinfo.php. Please check " 36 | "permissions." 37 | msgstr "" 38 | "ERROR: No se puede escribir el archivo en $userDir/$rootdir/phpinfo.php. Por " 39 | "favor chequee sus permisos." 40 | 41 | #: virtualhost.sh:59 42 | msgid "Added content to $userDir$rootdir/phpinfo.php." 43 | msgstr "Agregando contenido a $userDir$rootdir/phpinfo.php." 44 | 45 | #: virtualhost.sh:83 46 | msgid "There is an ERROR create $domain file" 47 | msgstr "Ocurrio un ERROR al crear el archivo $domain" 48 | 49 | #: virtualhost.sh:86 50 | msgid "\\nNew Virtual Host Created\\n" 51 | msgstr "\\\\nSe ha creado el nuevo Virtual Host\\\\n" 52 | 53 | #: virtualhost.sh:92 54 | msgid "ERROR: Not able write in /etc/hosts" 55 | msgstr "ERROR: No se puede escribir en /etc/hosts" 56 | 57 | #: virtualhost.sh:95 58 | msgid "Host added to /etc/hosts file \\n" 59 | msgstr "Host agregado a /etc/hosts \\\\n" 60 | 61 | #: virtualhost.sh:111 62 | msgid "" 63 | "Complete! \\nYou now have a new Virtual Host \\nYour new host is: http://" 64 | "$domain \\nAnd its located at $userDir$rootdir" 65 | msgstr "" 66 | "Completo! \\\\nAhora tienes un nuevo Virtual Host!! \\\\nTu nuevo host es: " 67 | "http://$domain \\\\ny esta localizado en $userDir$rootdir" 68 | 69 | #: virtualhost.sh:116 70 | msgid "This domain dont exists.\\nPlease Try Another one" 71 | msgstr "El dominio no existe.\\\\nPor favor pruebe con otro" 72 | 73 | #: virtualhost.sh:135 74 | msgid "Delete host root directory ? (s/n)" 75 | msgstr "Borrar host root directorio ? (s/n)" 76 | 77 | #: virtualhost.sh:141 78 | msgid "Directory deleted" 79 | msgstr "Directorio Borrado" 80 | 81 | #: virtualhost.sh:143 82 | msgid "Host directory conserved" 83 | msgstr "Directorio Host Conservado" 84 | 85 | #: virtualhost.sh:146 86 | msgid "Host directory not found. Ignored" 87 | msgstr "Directorio Host no encontrado. Ignorado" 88 | 89 | #: virtualhost.sh:150 90 | msgid "Complete!\\nYou just removed Virtual Host $domain" 91 | msgstr "Completado!\\\\nSeha removido el Virtual Host $domain" 92 | -------------------------------------------------------------------------------- /locale/pt_BR/virtualhost-nginx.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoverWire/virtualhost/8db0f7f2e3fb5dc27deac600d37be6edf1a7b5ef/locale/pt_BR/virtualhost-nginx.mo -------------------------------------------------------------------------------- /locale/pt_BR/virtualhost-nginx.pot: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Virtualhost Manage Script NGINX\n" 4 | "Last-Translator: Cynthia Pereira \n" 5 | "MIME-Version: 1.0\n" 6 | "Content-Type: text/plain; charset=UTF-8\n" 7 | "Content-Transfer-Encoding: 8bit\n" 8 | "POT-Creation-Date: \n" 9 | "PO-Revision-Date: \n" 10 | "Language-Team: Cynthia Pereira \n" 11 | "X-Generator: Poedit 1.5.4\n" 12 | "Language: pt_BR\n" 13 | 14 | #: virtualhost-nginx.sh:15 15 | msgid "You have no permission to run $0 as non-root user. Use sudo" 16 | msgstr "" 17 | "Você não tem permissão para executar $0 como usuário não-root. Use sudo" 18 | 19 | #: virtualhost-nginx.sh:21 20 | msgid "You need to prompt for action (create or delete) -- Lower-case only" 21 | msgstr "" 22 | "Você precisa inserir uma ação (create or delete) -- apenas letras minúsculas" 23 | 24 | #: virtualhost-nginx.sh:27 25 | msgid "Please provide domain. e.g.dev,staging" 26 | msgstr "Por favor, insira um domínio. Exemplo: meudominio" 27 | 28 | #: virtualhost-nginx.sh:39 29 | msgid "This domain already exists.\\nPlease Try Another one" 30 | msgstr "Este domínio já existe.\\nPor favor, tente outro" 31 | 32 | #: virtualhost-nginx.sh:52 33 | msgid "" 34 | "ERROR: Not able to write in file $userDir/$rootdir/phpinfo.php. Please check " 35 | "permissions." 36 | msgstr "" 37 | "ERRO: Não é possível escrever no arquivo $userDir/$rootdir/phpinfo.php. Por " 38 | "favor, verifique as permissões." 39 | 40 | #: virtualhost-nginx.sh:55 41 | msgid "Added content to $userDir$rootdir/phpinfo.php." 42 | msgstr "Conteúdo adicionado ao $userDir$rootdir/phpinfo.php." 43 | 44 | #: virtualhost-nginx.sh:104 45 | msgid "There is an ERROR create $domain file" 46 | msgstr "Há um ERRO ao criar o arquivo $domain" 47 | 48 | #: virtualhost-nginx.sh:107 49 | msgid "\\nNew Virtual Host Created\\n" 50 | msgstr "\\nNovo Virtual Host Criado\\n" 51 | 52 | #: virtualhost-nginx.sh:113 53 | msgid "ERROR: Not able write in /etc/hosts" 54 | msgstr "ERRO: Não é possível escrever no arquivo /etc/hosts" 55 | 56 | #: virtualhost-nginx.sh:116 57 | msgid "Host added to /etc/hosts file \\n" 58 | msgstr "Host adicionado ao arquivo /etc/hosts \\n" 59 | 60 | #: virtualhost-nginx.sh:132 61 | msgid "" 62 | "Complete! \\nYou now have a new Virtual Host \\nYour new host is: http://" 63 | "$domain \\nAnd its located at $userDir$rootdir" 64 | msgstr "" 65 | "Completo! \\nAgora você tem um novo Virtual Host \\nSeu novo host é: http://" 66 | "$domain \\nE está localizado em $userDir$rootdir" 67 | 68 | #: virtualhost-nginx.sh:137 69 | msgid "This domain dont exists.\\nPlease Try Another one" 70 | msgstr "Este domínio não existe.\\nPor favor, tente outro" 71 | 72 | #: virtualhost-nginx.sh:156 73 | msgid "Delete host root directory ? (s/n)" 74 | msgstr "Excluir diretório raiz do Host ? (s/n)" 75 | 76 | #: virtualhost-nginx.sh:162 77 | msgid "Directory deleted" 78 | msgstr "Diretório excluído" 79 | 80 | #: virtualhost-nginx.sh:164 81 | msgid "Host directory conserved" 82 | msgstr "Diretório do Host mantido" 83 | 84 | #: virtualhost-nginx.sh:167 85 | msgid "Host directory not found. Ignored" 86 | msgstr "Diretório do Host não encontrado. ignorado" 87 | 88 | #: virtualhost-nginx.sh:171 89 | msgid "Complete!\\nYou just removed Virtual Host $domain" 90 | msgstr "Completo!\\nVocê acabou de remover o Virtual Host $domain" 91 | -------------------------------------------------------------------------------- /locale/pt_BR/virtualhost.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoverWire/virtualhost/8db0f7f2e3fb5dc27deac600d37be6edf1a7b5ef/locale/pt_BR/virtualhost.mo -------------------------------------------------------------------------------- /locale/pt_BR/virtualhost.pot: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Virtualhost Manage Script\n" 4 | "Last-Translator: Cynthia Pereira \n" 5 | "MIME-Version: 1.0\n" 6 | "Content-Type: text/plain; charset=UTF-8\n" 7 | "Content-Transfer-Encoding: 8bit\n" 8 | "POT-Creation-Date: \n" 9 | "PO-Revision-Date: \n" 10 | "Language-Team: Cynthia Pereira \n" 11 | "X-Generator: Poedit 1.5.4\n" 12 | "Language: pt_BR\n" 13 | 14 | #: virtualhost.sh:19 15 | msgid "You have no permission to run $0 as non-root user. Use sudo" 16 | msgstr "" 17 | "Você não tem permissão para executar $0 como usuário não-root. Use sudo" 18 | 19 | #: virtualhost.sh:25 20 | msgid "You need to prompt for action (create or delete) -- Lower-case only" 21 | msgstr "" 22 | "Você precisa inserir uma ação (create or delete) -- apenas letras minúsculas" 23 | 24 | #: virtualhost.sh:31 25 | msgid "Please provide domain. e.g.dev,staging" 26 | msgstr "Por favor, insira um domínio. Exemplo: meudominio" 27 | 28 | #: virtualhost.sh:43 29 | msgid "This domain already exists.\\nPlease Try Another one" 30 | msgstr "Este domínio já existe.\\nPor favor, tente outro" 31 | 32 | #: virtualhost.sh:56 33 | msgid "" 34 | "ERROR: Not able to write in file $userDir/$rootdir/phpinfo.php. Please check " 35 | "permissions." 36 | msgstr "" 37 | "ERRO: Não é possível escrever no arquivo $userDir/$rootdir/phpinfo.php. Por " 38 | "favor, verifique as permissões." 39 | 40 | #: virtualhost.sh:59 41 | msgid "Added content to $userDir$rootdir/phpinfo.php." 42 | msgstr "Conteúdo adicionado ao $userDir$rootdir/phpinfo.php." 43 | 44 | #: virtualhost.sh:83 45 | msgid "There is an ERROR create $domain file" 46 | msgstr "Há um ERRO ao criar o arquivo $domain" 47 | 48 | #: virtualhost.sh:86 49 | msgid "\\nNew Virtual Host Created\\n" 50 | msgstr "\\nNovo Virtual Host Criado\\n" 51 | 52 | #: virtualhost.sh:92 53 | msgid "ERROR: Not able write in /etc/hosts" 54 | msgstr "ERRO: Não é possível escrever no arquivo /etc/hosts" 55 | 56 | #: virtualhost.sh:95 57 | msgid "Host added to /etc/hosts file \\n" 58 | msgstr "Host adicionado ao arquivo /etc/hosts \\n" 59 | 60 | #: virtualhost.sh:111 61 | msgid "" 62 | "Complete! \\nYou now have a new Virtual Host \\nYour new host is: http://" 63 | "$domain \\nAnd its located at $userDir$rootdir" 64 | msgstr "" 65 | "Completo! \\nAgora você tem um novo Virtual Host \\nSeu novo host é: http://" 66 | "$domain \\nE está localizado em $userDir$rootdir" 67 | 68 | #: virtualhost.sh:116 69 | msgid "This domain dont exists.\\nPlease Try Another one" 70 | msgstr "Este domínio não existe.\\nPor favor, tente outro" 71 | 72 | #: virtualhost.sh:135 73 | msgid "Delete host root directory ? (s/n)" 74 | msgstr "Excluir diretório raiz do Host ? (s/n)" 75 | 76 | #: virtualhost.sh:141 77 | msgid "Directory deleted" 78 | msgstr "Diretório excluído" 79 | 80 | #: virtualhost.sh:143 81 | msgid "Host directory conserved" 82 | msgstr "Diretório do Host mantido" 83 | 84 | #: virtualhost.sh:146 85 | msgid "Host directory not found. Ignored" 86 | msgstr "Diretório do Host não encontrado. ignorado" 87 | 88 | #: virtualhost.sh:150 89 | msgid "Complete!\\nYou just removed Virtual Host $domain" 90 | msgstr "Completo!\\nVocê acabou de remover o Virtual Host $domain" 91 | -------------------------------------------------------------------------------- /locale/ru/virtualhost-nginx.pot: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Virtualhost Manage Script NGINX \n" 4 | "Last-Translator: Eugene Chechulin \n" 5 | "MIME-Version: 1.0\n" 6 | "Content-Type: text/plain; charset=UTF-8\n" 7 | "Content-Transfer-Encoding: 8bit\n" 8 | "Language: ru_RU\n" 9 | 10 | #: virtualhost-nginx.sh:15 11 | msgid "You have no permission to run $0 as non-root user. Use sudo" 12 | msgstr "Вы не root пользователь и у Вас нет прав для запуска $0. Используйте sudo." 13 | #: virtualhost-nginx.sh:21 14 | msgid "You need to prompt for action (create or delete) -- Lower-case only" 15 | msgstr "Вам необходимо выбрать действие (create или delete) -- Набирать в нижнем регистре." 16 | #: virtualhost-nginx.sh:27 17 | msgid "Please provide domain. e.g.dev,staging" 18 | msgstr "Пожалуйста укажите доменное имя. Например test.dev" 19 | #: virtualhost-nginx.sh:39 20 | msgid "This domain already exists.\\nPlease Try Another one" 21 | msgstr "Это доменное имя уже используется, пожалуйста укажите другое." 22 | #: virtualhost-nginx.sh:52 23 | msgid "ERROR: Not able to write in file $userDir/$rootdir/phpinfo.php. Please check permissions." 24 | msgstr "ОШИБКА: Нельзя выполнить запись в $userDir/$rootdir/phpinfo.php. Проверьте права." 25 | #: virtualhost-nginx.sh:55 26 | msgid "Added content to $userDir$rootdir/phpinfo.php." 27 | msgstr "Контент добавлен в $userDir$rootdir/phpinfo.php." 28 | #: virtualhost-nginx.sh:104 29 | msgid "There is an ERROR create $domain file" 30 | msgstr "Ошибка при создании $domain" 31 | #: virtualhost-nginx.sh:107 32 | msgid "\\nNew Virtual Host Created\\n" 33 | msgstr "\\nНовый виртуальный хост создан.\\n" 34 | #: virtualhost-nginx.sh:113 35 | msgid "ERROR: Not able write in /etc/hosts" 36 | msgstr "ОШИБКА: Нельзя записать в /etc/hosts. Проверьте права." 37 | #: virtualhost-nginx.sh:116 38 | msgid "Host added to /etc/hosts file \\n" 39 | msgstr "Домен добавлен в /etc/hosts file \\n" 40 | #: virtualhost-nginx.sh:132 41 | msgid "Complete! \\nYou now have a new Virtual Host \\nYour new host is: http://$domain \\nAnd its located at $userDir$rootdir" 42 | msgstr "Готово! \\nУ Вас есть новый виртуальный хост \\nВаш новый хост: http://$domain \\nКоторый распологается в $userDir$rootdir" 43 | #: virtualhost-nginx.sh:137 44 | msgid "This domain dont exists.\\nPlease Try Another one" 45 | msgstr "Этот домен не создан.\\nПопробуйте другой" 46 | #: virtualhost-nginx.sh:156 47 | msgid "Delete host root directory ? (s/n)" 48 | msgstr "Удалить директорию хоста ? (s/n)" 49 | #: virtualhost-nginx.sh:162 50 | msgid "Directory deleted" 51 | msgstr "Директория удалена" 52 | #: virtualhost-nginx.sh:164 53 | msgid "Host directory conserved" 54 | msgstr "Каталог хоста сохранен" 55 | #: virtualhost-nginx.sh:167 56 | msgid "Host directory not found. Ignored" 57 | msgstr "Директория хоста не найдена. Проигнорировано" 58 | #: virtualhost-nginx.sh:171 59 | msgid "Complete!\\nYou just removed Virtual Host $domain" 60 | msgstr "Готово!\\nВы только что удалили $domain" 61 | -------------------------------------------------------------------------------- /locale/ru/virtualhost.pot: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Virtualhost Manage Script \n" 4 | "Last-Translator: Eugene Chechulin \n" 5 | "MIME-Version: 1.0\n" 6 | "Content-Type: text/plain; charset=UTF-8\n" 7 | "Content-Transfer-Encoding: 8bit\n" 8 | "Language: ru_RU\n"" 9 | 10 | #: virtualhost.sh:19 11 | msgid "You have no permission to run $0 as non-root user. Use sudo" 12 | msgstr "Вы не root пользователь и у Вас нет прав для запуска $0. Используйте sudo." 13 | #: virtualhost.sh:25 14 | msgid "You need to prompt for action (create or delete) -- Lower-case only" 15 | msgstr "Вам необходимо выбрать действие (create или delete) -- Набирать в нижнем регистре." 16 | #: virtualhost.sh:31 17 | msgid "Please provide domain. e.g.dev,staging" 18 | msgstr "Пожалуйста укажите доменное имя. Например test.dev" 19 | #: virtualhost.sh:43 20 | msgid "This domain already exists.\\nPlease Try Another one" 21 | msgstr "Это доменное имя уже используется, пожалуйста укажите другое." 22 | #: virtualhost.sh:56 23 | msgid "ERROR: Not able to write in file $userDir/$rootdir/phpinfo.php. Please check permissions." 24 | msgstr "ОШИБКА: Нельзя выполнить запись в $userDir/$rootdir/phpinfo.php. Проверьте права." 25 | #: virtualhost.sh:59 26 | msgid "Added content to $userDir$rootdir/phpinfo.php." 27 | msgstr "Контент добавлен в $userDir$rootdir/phpinfo.php." 28 | #: virtualhost.sh:83 29 | msgid "There is an ERROR create $domain file" 30 | msgstr "Ошибка при создании $domain" 31 | #: virtualhost.sh:86 32 | msgid "\\nNew Virtual Host Created\\n" 33 | msgstr "\\nНовый виртуальный хост создан.\\n" 34 | #: virtualhost.sh:92 35 | msgid "ERROR: Not able write in /etc/hosts" 36 | msgstr "ОШИБКА: Нельзя записать в /etc/hosts. Проверьте права." 37 | #: virtualhost.sh:95 38 | msgid "Host added to /etc/hosts file \\n" 39 | msgstr "Домен добавлен в /etc/hosts file \\n" 40 | #: virtualhost.sh:111 41 | msgid "Complete! \\nYou now have a new Virtual Host \\nYour new host is: http://$domain \\nAnd its located at $userDir$rootdir" 42 | msgstr "Готово! \\nУ Вас есть новый виртуальный хост \\nВаш новый хост: http://$domain \\nКоторый распологается в $userDir$rootdir" 43 | #: virtualhost.sh:116 44 | msgid "This domain dont exists.\\nPlease Try Another one" 45 | msgstr "Этот домен не создан.\\nПопробуйте другой" 46 | #: virtualhost.sh:135 47 | msgid "Delete host root directory ? (s/n)" 48 | msgstr "Удалить директорию хоста ? (s/n)" 49 | #: virtualhost.sh:141 50 | msgid "Directory deleted" 51 | msgstr "Директория удалена" 52 | #: virtualhost.sh:143 53 | msgid "Host directory conserved" 54 | msgstr "Каталог хоста сохранен" 55 | #: virtualhost.sh:146 56 | msgid "Host directory not found. Ignored" 57 | msgstr "Директория хоста не найдена. Проигнорировано" 58 | #: virtualhost.sh:150 59 | msgid "Complete!\\nYou just removed Virtual Host $domain" 60 | msgstr "Готово!\\nВы только что удалили $domain" 61 | -------------------------------------------------------------------------------- /locale/tr/virtualhost-nginx.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoverWire/virtualhost/8db0f7f2e3fb5dc27deac600d37be6edf1a7b5ef/locale/tr/virtualhost-nginx.mo -------------------------------------------------------------------------------- /locale/tr/virtualhost-nginx.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Virtualhost Manage Script NGINX\n" 4 | "MIME-Version: 1.0\n" 5 | "Content-Type: text/plain; charset=UTF-8\n" 6 | "Content-Transfer-Encoding: 8bit\n" 7 | "POT-Creation-Date: \n" 8 | "PO-Revision-Date: \n" 9 | "Language-Team: Tanju Yıldız \n" 10 | "X-Generator: Poedit 1.8.7.1\n" 11 | "Last-Translator: \n" 12 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 13 | "Language: tr_TR\n" 14 | "X-Poedit-Basepath: ../..\n" 15 | "X-Poedit-SearchPath-0: virtualhost-nginx.sh\n" 16 | 17 | #: virtualhost-nginx.sh:15 18 | msgid "You have no permission to run $0 as non-root user. Use sudo" 19 | msgstr "$0 komutunu, yönetici olmadan çalıştırma izniniz yok. 'sudo' kullanın." 20 | 21 | #: virtualhost-nginx.sh:21 22 | msgid "You need to prompt for action (create or delete) -- Lower-case only" 23 | msgstr "İşlem için komut (create veya delete) gerekir -- yalnızca küçük harf" 24 | 25 | #: virtualhost-nginx.sh:27 26 | msgid "Please provide domain. e.g.dev,staging" 27 | msgstr "Lütfen alan adı giriniz. Örn: ornekproje.dev" 28 | 29 | #: virtualhost-nginx.sh:39 30 | msgid "This domain already exists.\\nPlease Try Another one" 31 | msgstr "Bu alan adı zaten var.\\nLütfen farklı bir alan adı giriniz." 32 | 33 | #: virtualhost-nginx.sh:52 34 | msgid "" 35 | "ERROR: Not able to write in file $userDir/$rootdir/phpinfo.php. Please check " 36 | "permissions." 37 | msgstr "" 38 | "HATA: $userDir/$rootdir/phpinfo.php dosyası yazılabilir değil. Lütfen " 39 | "izinleri kontrol ediniz." 40 | 41 | #: virtualhost-nginx.sh:55 42 | msgid "Added content to $userDir$rootdir/phpinfo.php." 43 | msgstr "$userDir$rootdir/phpinfo.php dosyasına içerik eklendi." 44 | 45 | #: virtualhost-nginx.sh:104 46 | msgid "There is an ERROR create $domain file" 47 | msgstr "$domain dosyası oluşturulurken bir HATA oluştu." 48 | 49 | #: virtualhost-nginx.sh:107 50 | msgid "\\nNew Virtual Host Created\\n" 51 | msgstr "\\nYeni Sanal Sunucu Oluşturuldu\\n" 52 | 53 | #: virtualhost-nginx.sh:113 54 | msgid "ERROR: Not able write in /etc/hosts" 55 | msgstr "HATA: /etc/hosts yazılabilir değil." 56 | 57 | #: virtualhost-nginx.sh:116 58 | msgid "Host added to /etc/hosts file \\n" 59 | msgstr "Sanal sunucu, /etc/hosts dosyasına eklendi.\\n" 60 | 61 | #: virtualhost-nginx.sh:132 62 | msgid "" 63 | "Complete! \\nYou now have a new Virtual Host \\nYour new host is: http://" 64 | "$domain \\nAnd its located at $userDir$rootdir" 65 | msgstr "" 66 | "İşlem tamamlandı!\\nYeni bir sanal sunucunuz var.\\nSanal sunucu adresiniz: " 67 | "http://$domain\\nSanal sunucu dizini: $userDir$rootdir" 68 | 69 | #: virtualhost-nginx.sh:137 70 | msgid "This domain dont exists.\\nPlease Try Another one" 71 | msgstr "Bu alan adı mevcut değil.\\nLütfen farklı bir alan adı giriniz." 72 | 73 | #: virtualhost-nginx.sh:156 74 | msgid "Delete host root directory ? (s/n)" 75 | msgstr "anal sunucu kök dizini silinsin mi? (y/n)" 76 | 77 | #: virtualhost-nginx.sh:162 78 | msgid "Directory deleted" 79 | msgstr "Dizin silindi." 80 | 81 | #: virtualhost-nginx.sh:164 82 | msgid "Host directory conserved" 83 | msgstr "Sanal sunucu dizini bırakıldı." 84 | 85 | #: virtualhost-nginx.sh:167 86 | msgid "Host directory not found. Ignored" 87 | msgstr "Sanal sunucu dizini bulunamadı. İşlem yok sayıldı." 88 | 89 | #: virtualhost-nginx.sh:171 90 | msgid "Complete!\\nYou just removed Virtual Host $domain" 91 | msgstr "İşlem tamamlandı!\\\\n$domain sanal sunucusu kaldırıldı." 92 | -------------------------------------------------------------------------------- /locale/tr/virtualhost.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoverWire/virtualhost/8db0f7f2e3fb5dc27deac600d37be6edf1a7b5ef/locale/tr/virtualhost.mo -------------------------------------------------------------------------------- /locale/tr/virtualhost.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Virtualhost Manage Script\n" 4 | "POT-Creation-Date: 2017-09-17 13:13+0300\n" 5 | "PO-Revision-Date: \n" 6 | "Last-Translator: \n" 7 | "Language-Team: Tanju Yıldız \n" 8 | "Language: tr_TR\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "X-Generator: Poedit 1.8.7.1\n" 13 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 14 | "X-Poedit-Basepath: ../..\n" 15 | "X-Poedit-SearchPath-0: virtualhost.sh\n" 16 | 17 | #: virtualhost.sh:19 18 | msgid "You have no permission to run $0 as non-root user. Use sudo" 19 | msgstr "$0 komutunu, yönetici olmadan çalıştırma izniniz yok. 'sudo' kullanın." 20 | 21 | #: virtualhost.sh:25 22 | msgid "You need to prompt for action (create or delete) -- Lower-case only" 23 | msgstr "İşlem için komut (create veya delete) gerekir -- yalnızca küçük harf" 24 | 25 | #: virtualhost.sh:31 26 | msgid "Please provide domain. e.g.dev,staging" 27 | msgstr "Lütfen alan adı giriniz. Örn: ornekproje.dev" 28 | 29 | #: virtualhost.sh:50 30 | msgid "This domain already exists.\\nPlease Try Another one" 31 | msgstr "Bu alan adı zaten var.\\nLütfen farklı bir alan adı giriniz." 32 | 33 | #: virtualhost.sh:63 34 | #, sh-format 35 | msgid "" 36 | "ERROR: Not able to write in file $rootDir/phpinfo.php. Please check " 37 | "permissions" 38 | msgstr "" 39 | "HATA: $rootDir/phpinfo.php dosyası yazılabilir değil. Lütfen izinleri " 40 | "kontrol ediniz." 41 | 42 | #: virtualhost.sh:66 43 | #, sh-format 44 | msgid "Added content to $rootDir/phpinfo.php" 45 | msgstr "$rootDir/phpinfo.php dosyasına içerik eklendi." 46 | 47 | #: virtualhost.sh:90 48 | #, sh-format 49 | msgid "There is an ERROR creating $domain file" 50 | msgstr "$domain dosyası oluşturulurken bir HATA oluştu." 51 | 52 | #: virtualhost.sh:93 53 | msgid "\\nNew Virtual Host Created\\n" 54 | msgstr "\\nYeni Sanal Sunucu Oluşturuldu\\n" 55 | 56 | #: virtualhost.sh:99 57 | msgid "ERROR: Not able to write in /etc/hosts" 58 | msgstr "HATA: /etc/hosts yazılabilir değil." 59 | 60 | #: virtualhost.sh:102 61 | msgid "Host added to /etc/hosts file \\n" 62 | msgstr "Sanal sunucu, /etc/hosts dosyasına eklendi.\\n" 63 | 64 | #: virtualhost.sh:118 65 | #, sh-format 66 | msgid "" 67 | "Complete! \\nYou now have a new Virtual Host \\nYour new host is: http://" 68 | "$domain \\nAnd its located at $rootDir" 69 | msgstr "" 70 | "İşlem tamamlandı!\\nYeni bir sanal sunucunuz var.\\nSanal sunucu adresiniz: " 71 | "http://$domain\\nSanal sunucu dizini: $rootDir" 72 | 73 | #: virtualhost.sh:123 74 | msgid "This domain does not exist.\\nPlease try another one" 75 | msgstr "Bu alan adı mevcut değil.\\nLütfen farklı bir alan adı giriniz." 76 | 77 | #: virtualhost.sh:142 78 | msgid "Delete host root directory ? (y/n)" 79 | msgstr "Sanal sunucu kök dizini silinsin mi? (y/n)" 80 | 81 | #: virtualhost.sh:148 82 | msgid "Directory deleted" 83 | msgstr "Dizin silindi." 84 | 85 | #: virtualhost.sh:150 86 | msgid "Host directory conserved" 87 | msgstr "Sanal sunucu dizini bırakıldı." 88 | 89 | #: virtualhost.sh:153 90 | msgid "Host directory not found. Ignored" 91 | msgstr "Sanal sunucu dizini bulunamadı. İşlem yok sayıldı." 92 | 93 | #: virtualhost.sh:157 94 | #, sh-format 95 | msgid "Complete!\\nYou just removed Virtual Host $domain" 96 | msgstr "İşlem tamamlandı!\\n$domain sanal sunucusu kaldırıldı." 97 | -------------------------------------------------------------------------------- /virtualhost-centos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### Set Language 3 | TEXTDOMAIN=virtualhost 4 | 5 | ### Set default parameters 6 | action=$1 7 | domain=$2 8 | rootDir=$3 9 | owner=$(who am i | awk '{print $1}') 10 | email='webmaster@localhost' 11 | sitesEnable='/etc/httpd/sites-enabled/' 12 | sitesAvailable='/etc/httpd/sites-available/' 13 | userDir='/var/www/' 14 | sitesAvailabledomain=$sitesAvailable$domain.conf 15 | 16 | ### don't modify from here unless you know what you are doing #### 17 | 18 | if [ "$(whoami)" != 'root' ]; then 19 | echo $"You have no permission to run $0 as non-root user. Use sudo" 20 | exit 1; 21 | fi 22 | 23 | if [ "$action" != 'create' ] && [ "$action" != 'delete' ] 24 | then 25 | echo $"You need to prompt for action (create or delete) -- Lower-case only" 26 | exit 1; 27 | fi 28 | 29 | while [ "$domain" == "" ] 30 | do 31 | echo -e $"Please provide domain. e.g.dev,staging" 32 | read domain 33 | done 34 | 35 | if [ "$rootDir" == "" ]; then 36 | rootDir=${domain//./} 37 | fi 38 | 39 | ### if root dir starts with '/', don't use /var/www as default starting point 40 | if [[ "$rootDir" =~ ^/ ]]; then 41 | userDir='' 42 | fi 43 | 44 | rootDir=$userDir$rootDir 45 | 46 | if [ "$action" == 'create' ] 47 | then 48 | ### check if domain already exists 49 | if [ -e $sitesAvailabledomain ]; then 50 | echo -e $"This domain already exists.\nPlease Try Another one" 51 | exit; 52 | fi 53 | 54 | ### check if directory exists or not 55 | if ! [ -d $rootDir ]; then 56 | ### create the directory 57 | mkdir $rootDir 58 | ### give permission to root dir 59 | chmod 755 $rootDir 60 | ### write test file in the new domain dir 61 | if ! echo "" > $rootDir/phpinfo.php 62 | then 63 | echo $"ERROR: Not able to write in file $rootDir/phpinfo.php. Please check permissions" 64 | exit; 65 | else 66 | echo $"Added content to $rootDir/phpinfo.php" 67 | fi 68 | fi 69 | 70 | ### create virtual host rules file 71 | if ! echo " 72 | 73 | ServerAdmin $email 74 | ServerName $domain 75 | ServerAlias $domain 76 | DocumentRoot $rootDir 77 | 78 | AllowOverride All 79 | 80 | 81 | Options Indexes FollowSymLinks MultiViews 82 | AllowOverride all 83 | Require all granted 84 | 85 | ErrorLog /var/log/httpd/$domain-error.log 86 | LogLevel error 87 | CustomLog /var/log/httpd/$domain-access.log combined 88 | " > $sitesAvailabledomain 89 | then 90 | echo -e $"There is an ERROR creating $domain file" 91 | exit; 92 | else 93 | echo -e $"\nNew Virtual Host Created\n" 94 | fi 95 | 96 | ### Add domain in /etc/hosts 97 | if ! echo "127.0.0.1 $domain" >> /etc/hosts 98 | then 99 | echo $"ERROR: Not able to write in /etc/hosts" 100 | exit; 101 | else 102 | echo -e $"Host added to /etc/hosts file \n" 103 | fi 104 | 105 | if [ "$owner" == "" ]; then 106 | chown -R $(whoami):$(whoami) $rootDir 107 | else 108 | chown -R $owner:$owner $rootDir 109 | fi 110 | 111 | ### enable website 112 | cp $sitesAvailabledomain $sitesEnable/$domain.conf 113 | 114 | ### restart Apache 115 | systemctl restart httpd 116 | 117 | ### show the finished message 118 | echo -e $"Complete! \nYou now have a new Virtual Host \nYour new host is: http://$domain \nAnd its located at $rootDir" 119 | exit; 120 | else 121 | ### check whether domain already exists 122 | if ! [ -e $sitesAvailabledomain ]; then 123 | echo -e $"This domain does not exist.\nPlease try another one" 124 | exit; 125 | else 126 | ### Delete domain in /etc/hosts 127 | newhost=${domain//./\\.} 128 | sed -i "/$newhost/d" /etc/hosts 129 | 130 | ### disable website 131 | rm -f $sitesEnable/$domain.conf 132 | 133 | ### restart Apache 134 | systemctl restart httpd 135 | 136 | ### Delete virtual host rules files 137 | rm $sitesAvailabledomain 138 | fi 139 | 140 | ### check if directory exists or not 141 | if [ -d $rootDir ]; then 142 | echo -e $"Delete host root directory ? (y/n)" 143 | read deldir 144 | 145 | if [ "$deldir" == 'y' -o "$deldir" == 'Y' ]; then 146 | ### Delete the directory 147 | rm -rf $rootDir 148 | echo -e $"Directory deleted" 149 | else 150 | echo -e $"Host directory conserved" 151 | fi 152 | else 153 | echo -e $"Host directory not found. Ignored" 154 | fi 155 | 156 | ### show the finished message 157 | echo -e $"Complete!\nYou just removed Virtual Host $domain" 158 | exit 0; 159 | fi 160 | -------------------------------------------------------------------------------- /virtualhost-nginx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### Set Language 3 | TEXTDOMAIN=virtualhost 4 | 5 | ### Set default parameters 6 | action=$1 7 | domain=$2 8 | rootDir=$3 9 | owner=$(who am i | awk '{print $1}') 10 | sitesEnable='/etc/nginx/sites-enabled/' 11 | sitesAvailable='/etc/nginx/sites-available/' 12 | userDir='/var/www/' 13 | 14 | if [ "$(whoami)" != 'root' ]; then 15 | echo $"You have no permission to run $0 as non-root user. Use sudo" 16 | exit 1; 17 | fi 18 | 19 | if [ "$action" != 'create' ] && [ "$action" != 'delete' ] 20 | then 21 | echo $"You need to prompt for action (create or delete) -- Lower-case only" 22 | exit 1; 23 | fi 24 | 25 | while [ "$domain" == "" ] 26 | do 27 | echo -e $"Please provide domain. e.g.dev,staging" 28 | read domain 29 | done 30 | 31 | if [ "$rootDir" == "" ]; then 32 | rootDir=${domain//./} 33 | fi 34 | 35 | ### if root dir starts with '/', don't use /var/www as default starting point 36 | if [[ "$rootDir" =~ ^/ ]]; then 37 | userDir='' 38 | fi 39 | 40 | rootDir=$userDir$rootDir 41 | 42 | if [ "$action" == 'create' ] 43 | then 44 | ### check if domain already exists 45 | if [ -e $sitesAvailable$domain ]; then 46 | echo -e $"This domain already exists.\nPlease Try Another one" 47 | exit; 48 | fi 49 | 50 | ### check if directory exists or not 51 | if ! [ -d $rootDir ]; then 52 | ### create the directory 53 | mkdir $rootDir 54 | ### give permission to root dir 55 | chmod 755 $rootDir 56 | ### write test file in the new domain dir 57 | if ! echo "" > $rootDir/phpinfo.php 58 | then 59 | echo $"ERROR: Not able to write in file $rootDir/phpinfo.php. Please check permissions." 60 | exit; 61 | else 62 | echo $"Added content to $rootDir/phpinfo.php." 63 | fi 64 | fi 65 | 66 | ### create virtual host rules file 67 | if ! echo "server { 68 | listen 80; 69 | root $rootDir; 70 | index index.php index.html index.htm; 71 | server_name $domain; 72 | 73 | # serve static files directly 74 | location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ { 75 | access_log off; 76 | expires max; 77 | } 78 | 79 | # removes trailing slashes (prevents SEO duplicate content issues) 80 | if (!-d \$request_filename) { 81 | rewrite ^/(.+)/\$ /\$1 permanent; 82 | } 83 | 84 | # unless the request is for a valid file (image, js, css, etc.), send to bootstrap 85 | if (!-e \$request_filename) { 86 | rewrite ^/(.*)\$ /index.php?/\$1 last; 87 | break; 88 | } 89 | 90 | # removes trailing 'index' from all controllers 91 | if (\$request_uri ~* index/?\$) { 92 | rewrite ^/(.*)/index/?\$ /\$1 permanent; 93 | } 94 | 95 | # catch all 96 | error_page 404 /index.php; 97 | 98 | location ~ \.php$ { 99 | fastcgi_split_path_info ^(.+\.php)(/.+)\$; 100 | fastcgi_pass 127.0.0.1:9000; 101 | fastcgi_index index.php; 102 | include fastcgi_params; 103 | } 104 | 105 | location ~ /\.ht { 106 | deny all; 107 | } 108 | 109 | }" > $sitesAvailable$domain 110 | then 111 | echo -e $"There is an ERROR create $domain file" 112 | exit; 113 | else 114 | echo -e $"\nNew Virtual Host Created\n" 115 | fi 116 | 117 | ### Add domain in /etc/hosts 118 | if ! echo "127.0.0.1 $domain" >> /etc/hosts 119 | then 120 | echo $"ERROR: Not able write in /etc/hosts" 121 | exit; 122 | else 123 | echo -e $"Host added to /etc/hosts file \n" 124 | fi 125 | 126 | ### Add domain in /mnt/c/Windows/System32/drivers/etc/hosts (Windows Subsytem for Linux) 127 | if [ -e /mnt/c/Windows/System32/drivers/etc/hosts ] 128 | then 129 | if ! echo -e "\r127.0.0.1 $domain" >> /mnt/c/Windows/System32/drivers/etc/hosts 130 | then 131 | echo $"ERROR: Not able to write in /mnt/c/Windows/System32/drivers/etc/hosts (Hint: Try running Bash as administrator)" 132 | else 133 | echo -e $"Host added to /mnt/c/Windows/System32/drivers/etc/hosts file \n" 134 | fi 135 | fi 136 | 137 | if [ "$owner" == "" ]; then 138 | chown -R $(whoami):www-data $rootDir 139 | else 140 | chown -R $owner:www-data $rootDir 141 | fi 142 | 143 | ### enable website 144 | ln -s $sitesAvailable$domain $sitesEnable$domain 145 | 146 | ### restart Nginx 147 | systemctl reload nginx 148 | 149 | ### show the finished message 150 | echo -e $"Complete! \nYou now have a new Virtual Host \nYour new host is: http://$domain \nAnd its located at $rootDir" 151 | exit; 152 | else 153 | ### check whether domain already exists 154 | if ! [ -e $sitesAvailable$domain ]; then 155 | echo -e $"This domain dont exists.\nPlease Try Another one" 156 | exit; 157 | else 158 | ### Delete domain in /etc/hosts 159 | newhost=${domain//./\\.} 160 | sed -i "/$newhost/d" /etc/hosts 161 | 162 | ### Delete domain in /mnt/c/Windows/System32/drivers/etc/hosts (Windows Subsytem for Linux) 163 | if [ -e /mnt/c/Windows/System32/drivers/etc/hosts ] 164 | then 165 | newhost=${domain//./\\.} 166 | sed -i "/$newhost/d" /mnt/c/Windows/System32/drivers/etc/hosts 167 | fi 168 | 169 | ### disable website 170 | rm $sitesEnable$domain 171 | 172 | ### restart Nginx 173 | systemctl reload nginx 174 | 175 | ### Delete virtual host rules files 176 | rm $sitesAvailable$domain 177 | fi 178 | 179 | ### check if directory exists or not 180 | if [ -d $rootDir ]; then 181 | echo -e $"Delete host root directory ? (s/n)" 182 | read deldir 183 | 184 | if [ "$deldir" == 's' -o "$deldir" == 'S' ]; then 185 | ### Delete the directory 186 | rm -rf $rootDir 187 | echo -e $"Directory deleted" 188 | else 189 | echo -e $"Host directory conserved" 190 | fi 191 | else 192 | echo -e $"Host directory not found. Ignored" 193 | fi 194 | 195 | ### show the finished message 196 | echo -e $"Complete!\nYou just removed Virtual Host $domain" 197 | exit 0; 198 | fi 199 | -------------------------------------------------------------------------------- /virtualhost.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### Set Language 3 | TEXTDOMAIN=virtualhost 4 | 5 | ### Set default parameters 6 | action=$1 7 | domain=$2 8 | rootDir=$3 9 | owner=$(who am i | awk '{print $1}') 10 | apacheUser=$(ps -ef | egrep '(httpd|apache2|apache)' | grep -v root | head -n1 | awk '{print $1}') 11 | email='webmaster@localhost' 12 | sitesEnabled='/etc/apache2/sites-enabled/' 13 | sitesAvailable='/etc/apache2/sites-available/' 14 | userDir='/var/www/' 15 | sitesAvailabledomain=$sitesAvailable$domain.conf 16 | 17 | ### don't modify from here unless you know what you are doing #### 18 | 19 | if [ "$(whoami)" != 'root' ]; then 20 | echo $"You have no permission to run $0 as non-root user. Use sudo" 21 | exit 1; 22 | fi 23 | 24 | if [ "$action" != 'create' ] && [ "$action" != 'delete' ] 25 | then 26 | echo $"You need to prompt for action (create or delete) -- Lower-case only" 27 | exit 1; 28 | fi 29 | 30 | while [ "$domain" == "" ] 31 | do 32 | echo -e $"Please provide domain. e.g.dev,staging" 33 | read domain 34 | done 35 | 36 | if [ "$rootDir" == "" ]; then 37 | rootDir=${domain//./} 38 | fi 39 | 40 | ### if root dir starts with '/', don't use /var/www as default starting point 41 | if [[ "$rootDir" =~ ^/ ]]; then 42 | userDir='' 43 | fi 44 | 45 | rootDir=$userDir$rootDir 46 | 47 | if [ "$action" == 'create' ] 48 | then 49 | ### check if domain already exists 50 | if [ -e $sitesAvailabledomain ]; then 51 | echo -e $"This domain already exists.\nPlease Try Another one" 52 | exit; 53 | fi 54 | 55 | ### check if directory exists or not 56 | if ! [ -d $rootDir ]; then 57 | ### create the directory 58 | mkdir $rootDir 59 | ### give permission to root dir 60 | chmod 755 $rootDir 61 | ### write test file in the new domain dir 62 | if ! echo "" > $rootDir/phpinfo.php 63 | then 64 | echo $"ERROR: Not able to write in file $rootDir/phpinfo.php. Please check permissions" 65 | exit; 66 | else 67 | echo $"Added content to $rootDir/phpinfo.php" 68 | fi 69 | fi 70 | 71 | ### create virtual host rules file 72 | if ! echo " 73 | 74 | ServerAdmin $email 75 | ServerName $domain 76 | ServerAlias $domain 77 | DocumentRoot $rootDir 78 | 79 | AllowOverride All 80 | 81 | 82 | Options Indexes FollowSymLinks MultiViews 83 | AllowOverride all 84 | Require all granted 85 | 86 | ErrorLog /var/log/apache2/$domain-error.log 87 | LogLevel error 88 | CustomLog /var/log/apache2/$domain-access.log combined 89 | " > $sitesAvailabledomain 90 | then 91 | echo -e $"There is an ERROR creating $domain file" 92 | exit; 93 | else 94 | echo -e $"\nNew Virtual Host Created\n" 95 | fi 96 | 97 | ### Add domain in /etc/hosts 98 | if ! echo "127.0.0.1 $domain" >> /etc/hosts 99 | then 100 | echo $"ERROR: Not able to write in /etc/hosts" 101 | exit; 102 | else 103 | echo -e $"Host added to /etc/hosts file \n" 104 | fi 105 | 106 | ### Add domain in /mnt/c/Windows/System32/drivers/etc/hosts (Windows Subsytem for Linux) 107 | if [ -e /mnt/c/Windows/System32/drivers/etc/hosts ] 108 | then 109 | if ! echo -e "\r127.0.0.1 $domain\r::1 $domain" >> /mnt/c/Windows/System32/drivers/etc/hosts 110 | then 111 | echo $"ERROR: Not able to write in /mnt/c/Windows/System32/drivers/etc/hosts (Hint: Try running Bash as administrator)" 112 | else 113 | echo -e $"Host added to /mnt/c/Windows/System32/drivers/etc/hosts file \n" 114 | fi 115 | fi 116 | 117 | if [ "$owner" == "" ]; then 118 | iam=$(whoami) 119 | if [ "$iam" == "root" ]; then 120 | chown -R $apacheUser:$apacheUser $rootDir 121 | else 122 | chown -R $iam:$iam $rootDir 123 | fi 124 | else 125 | chown -R $owner:$owner $rootDir 126 | fi 127 | 128 | ### enable website 129 | a2ensite $domain 130 | 131 | ### restart Apache 132 | /etc/init.d/apache2 reload 133 | 134 | ### show the finished message 135 | echo -e $"Complete! \nYou now have a new Virtual Host \nYour new host is: http://$domain \nAnd its located at $rootDir" 136 | exit; 137 | else 138 | ### check whether domain already exists 139 | if ! [ -e $sitesAvailabledomain ]; then 140 | echo -e $"This domain does not exist.\nPlease try another one" 141 | exit; 142 | else 143 | ### Delete domain in /etc/hosts 144 | newhost=${domain//./\\.} 145 | sed -i "/$newhost/d" /etc/hosts 146 | 147 | ### Delete domain in /mnt/c/Windows/System32/drivers/etc/hosts (Windows Subsytem for Linux) 148 | if [ -e /mnt/c/Windows/System32/drivers/etc/hosts ] 149 | then 150 | newhost=${domain//./\\.} 151 | sed -i "/$newhost/d" /mnt/c/Windows/System32/drivers/etc/hosts 152 | fi 153 | 154 | ### disable website 155 | a2dissite $domain 156 | 157 | ### restart Apache 158 | /etc/init.d/apache2 reload 159 | 160 | ### Delete virtual host rules files 161 | rm $sitesAvailabledomain 162 | fi 163 | 164 | ### check if directory exists or not 165 | if [ -d $rootDir ]; then 166 | echo -e $"Delete host root directory ? (y/n)" 167 | read deldir 168 | 169 | if [ "$deldir" == 'y' -o "$deldir" == 'Y' ]; then 170 | ### Delete the directory 171 | rm -rf $rootDir 172 | echo -e $"Directory deleted" 173 | else 174 | echo -e $"Host directory conserved" 175 | fi 176 | else 177 | echo -e $"Host directory not found. Ignored" 178 | fi 179 | 180 | ### show the finished message 181 | echo -e $"Complete!\nYou just removed Virtual Host $domain" 182 | exit 0; 183 | fi 184 | --------------------------------------------------------------------------------