79 lines
2.0 KiB
Bash
79 lines
2.0 KiB
Bash
#!/bin/sh
|
|
|
|
# TODO: set max upload size in PHP configuration (php.ini).
|
|
|
|
os=$(cat "${__global:?}/explorer/os")
|
|
if [ "$os" != "alpine" ]; then
|
|
echo "This type is expected to run on Alpine Linux, not $os. Exiting." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Type parameters.
|
|
mysql_password="$(cat "${__object:?}/parameter/mysql-password")"
|
|
nginx_domain="$(cat "${__object:?}/parameter/nginx-domain")"
|
|
|
|
max_upload_size=100M
|
|
php_fpm_socket=/run/php-fpm7/php-fpm.sock
|
|
|
|
# Wordpress user.
|
|
__user wordpress --home /var/www/wordpress
|
|
|
|
# Basic PHP FPM setup + Wordpress dependencies.
|
|
require="__user/wordpress" __recycledcloud_php \
|
|
--pool-user wordpress \
|
|
--pool-group wordpress \
|
|
--pool-listen-addr $php_fpm_socket \
|
|
--pool-listen-owner nginx \
|
|
--upload-max-filesize $max_upload_size
|
|
|
|
wordpress_dependencies="php7-fpm php7-iconv php7-json php7-gd php7-curl \
|
|
php7-xml php7-mysqli php7-imap php7-cgi php7-pdo php7-pdo_mysql php7-soap \
|
|
php7-xmlrpc php7-posix php7-mcrypt php7-gettext php7-ldap php7-mbstring \
|
|
php7-ctype php7-dom php7-zip php7-fileinfo php7-exif php7-session"
|
|
|
|
for dependency in $wordpress_dependencies;
|
|
do
|
|
__package "$dependency"
|
|
done
|
|
|
|
# MySQL/MariaDB database
|
|
__recycledcloud_mysql
|
|
require="__recycledcloud_mysql" __mysql_database wordpress \
|
|
--user wordpress --password "$mysql_password"
|
|
|
|
# NGINX vhost for wordpress hosting.
|
|
__package nginx
|
|
require="__package/nginx" __recycledcloud_nginx "$nginx_domain" \
|
|
--config - <<- EOF
|
|
root /var/www/wordpress;
|
|
index index.php;
|
|
client_max_body_size $max_upload_size;
|
|
|
|
location / {
|
|
try_files \$uri \$uri/ /index.php?\$args;
|
|
}
|
|
|
|
location ~ \.php$ {
|
|
include fastcgi_params;
|
|
fastcgi_intercept_errors on;
|
|
fastcgi_pass unix:$php_fpm_socket;
|
|
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
|
|
}
|
|
|
|
location = /favicon.ico {
|
|
log_not_found off;
|
|
access_log off;
|
|
}
|
|
|
|
location = /robots.txt {
|
|
allow all;
|
|
log_not_found off;
|
|
access_log off;
|
|
}
|
|
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
|
|
expires max;
|
|
log_not_found off;
|
|
}
|
|
EOF
|