-
Notifications
You must be signed in to change notification settings - Fork 39
/
add-vhost.sh
70 lines (56 loc) · 1.92 KB
/
add-vhost.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
read -p "Write the host name, eg. google:" HOST;
read -p "Write the 1st level domain name without starting dot (.), eg. com.au:" DOMAIN;
mkdir -p /var/www/vhosts/$HOST.$DOMAIN/web
mkdir -p /var/www/vhosts/$HOST.$DOMAIN/logs
mkdir -p /var/www/vhosts/$HOST.$DOMAIN/ssl
groupadd $HOST
useradd -g $HOST -d /var/www/vhosts/$HOST.$DOMAIN $HOST
passwd $HOST
usermod -s /bin/bash $HOST
chown -R $HOST:$HOST /var/www/vhosts/$HOST.$DOMAIN
chmod -R 0775 /var/www/vhosts/$HOST.$DOMAIN
touch /etc/php/7.4/fpm/pool.d/$HOST.$DOMAIN.conf
echo "[$HOST]
user = $HOST
group = $HOST
listen = /run/php/php7.4-fpm-$HOST.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 = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /" >> /etc/php/7.4/fpm/pool.d/$HOST.$DOMAIN.conf
service php7.4-fpm restart
ps aux | grep $HOST
touch /etc/nginx/sites-available/$HOST.$DOMAIN
echo "server {
listen 80;
server_name $HOST.$DOMAIN;
location ~ ^/\.well-known/(.*) {}
location / {
return 302 http://www.$HOST.$DOMAIN$request_uri;
}
}
server {
listen 80;
root /var/www/vhosts/$HOST.$DOMAIN/web;
index index.php index.html index.htm;
server_name www.$HOST.$DOMAIN;
include /etc/nginx/conf.d/server/1-common.conf;
access_log /var/www/vhosts/$HOST.$DOMAIN/logs/access.log;
error_log /var/www/vhosts/$HOST.$DOMAIN/logs/error.log warn;
location ~ \.php$ {
try_files \$uri \$uri/ /index.php?$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm-$HOST.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}" >> /etc/nginx/sites-available/$HOST.$DOMAIN
ln -s /etc/nginx/sites-available/$HOST.$DOMAIN /etc/nginx/sites-enabled/$HOST.$DOMAIN
service nginx restart ; systemctl status nginx.service