54 lines
1.5 KiB
Bash
Executable File
54 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
apt-get -y install apg php-fpm php-json php-mysql php-curl php-dom php-imagick php-mbstring php-xml php-zip
|
|
mkdir -p /var/www
|
|
cd /var/www
|
|
wget -O wordpress.tar.gz https://wordpress.org/latest.tar.gz
|
|
tar xf wordpress.tar.gz
|
|
rm wordpress.tar.gz
|
|
chown -R www-data: wordpress
|
|
read -p 'Website domain without www: ' webdomain
|
|
mv wordpress "$webdomain"
|
|
|
|
printf \
|
|
"server {
|
|
error_log /var/log/nginx/${webdomain}_error.log;
|
|
#include snippets/acme.conf
|
|
#include snippets/ssl.conf
|
|
index index.php;
|
|
listen 80;
|
|
#listen 443 ssl;
|
|
root /var/www/$webdomain;
|
|
server_name $webdomain www.$webdomain;
|
|
#ssl_certificate /var/lib/acme/$webdomain/cert.pem;
|
|
#ssl_certificate_key /var/lib/acme/private/$webdomain/key.pem;
|
|
|
|
location / {
|
|
try_files \$uri \$uri/ /index.php?\$args;
|
|
}
|
|
|
|
location ~ \.php$ {
|
|
#NOTE: You should have \"cgi.fix_pathinfo = 0;\" in php.ini
|
|
include fastcgi.conf;
|
|
fastcgi_intercept_errors on;
|
|
fastcgi_pass unix:/run/php/php-fpm.sock;
|
|
}
|
|
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
|
|
expires max;
|
|
}
|
|
}" > /etc/nginx/sites-enabled/"$webdomain"
|
|
systemctl restart nginx
|
|
|
|
dbname="$(printf $webdomain | sed 's/\([a-z0-9_\-]\+\)\.[a-z]\+/\1/i')"
|
|
dbpass="$(apg -a 1 -m 24 -x 64 -M cln -n 1)"
|
|
printf \
|
|
"CREATE DATABASE wp_$dbname COLLATE utf8mb4_general_ci;
|
|
CREATE USER wp_$dbname@localhost IDENTIFIED BY '$dbpass';
|
|
GRANT ALL PRIVILEGES ON wp_$dbname.* TO wp_$dbname@localhost;
|
|
FLUSH PRIVILEGES;" | mariadb
|
|
|
|
printf "\nDATABASE INFO\nHost: localhost\nName: wp_$dbname\nPassword: $dbpass\nUser: wp_$dbname\n"
|