Skip to content

Instantly share code, notes, and snippets.

@plencovich
Last active August 20, 2018 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plencovich/155f01e22bcd5844149a6818080f83ae to your computer and use it in GitHub Desktop.
Save plencovich/155f01e22bcd5844149a6818080f83ae to your computer and use it in GitHub Desktop.
Agrega nuevo dominio en servidor linux con nginx como servidor web. Y le genera una web de bienvenida en un index.htm
#!/bin/bash
clear
read -p "Ingrese el nombre de usuario:, (ej. dplenco):" USER;
read -p "Ingrese el host del dominio:, (ej. google.com):" DOMAIN;
sudo groupadd $USER
sudo useradd -g $USER -G www-data -m -k /home/diegoplenco/skel_dir/ -s /bin/bash $USER
touch $USER.conf
echo "[$USER]
user = $USER
group = www-data
listen = /run/php/php7.2-fpm-$USER.sock
listen.owner = www-data
listen.group = www-data
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_flag[allow_url_fopen] = off
pm = dynamic
pm.max_children = 15
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /" >> $USER.conf
sudo mv $USER.conf /etc/php/7.2/fpm/pool.d/
touch $DOMAIN
sudo echo "server {
listen 80;
server_name $DOMAIN;
root /home/$USER/public_html;
index index.php index.html index.htm;
include /etc/nginx/snippets/common.conf;
access_log off;
error_log /home/$USER/logs/error.log warn;
location ~ \.php$ {
try_files \$uri \$uri/ /index.php?;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm-diegoplenco.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}" >> $DOMAIN
sudo mv $DOMAIN /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/$DOMAIN /etc/nginx/sites-enabled/$DOMAIN
phpfpm-restart
nginx-restart
echo
echo "El dominio $DOMAIN ha sido creado ok."
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment