ubuntu-wordpress/setup_wordpress.sh

48 lines
2.5 KiB
Bash

#!/bin/bash
sh /setup_programs.sh
# Install soft
apt install -y nginx php php-fpm php-mysql php-gd
apt install -y uuid-runtime
# Configure php
phpVersion="$(php --version | cat -n | sort -nr | cut -f2 | tail -n 1 | cut -d " " -f 2 | cut -c 1,2,3)"
#phpVersion=7.4
sed -i 's|listen = /run/php/php.\+\?-fpm.sock|listen = 127.0.0.1:9000|g' /etc/php/$phpVersion/fpm/pool.d/www.conf
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php/$phpVersion/fpm/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 8M/g' /etc/php/$phpVersion/fpm/php.ini
# Install wordpress
cd /tmp
wget https://wordpress.org/latest.tar.gz
mkdir /opt/bitnami/
tar xfvz latest.tar.gz -C /opt/bitnami/
# Configure wordpress conf
wget https://git.dfosd.synology.me/docker/ubuntu-wordpress/raw/branch/master/wp-config.php -O /opt/bitnami/wordpress/wp-config.php
#uuid=$(sed 's/-//g' <<< $(uuidgen))
#uuid=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 40 | head -n 1)
sed -i "s/secure_auth_key_value/$(sed 's/-//g' <<< $(uuidgen))/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/auth_key_value/$(sed 's/-//g' <<< $(uuidgen))/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/logged_in_key_value/$(sed 's/-//g' <<< $(uuidgen))/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/nonce_key_value/$(sed 's/-//g' <<< $(uuidgen))/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/secure_auth_salt_value/$(sed 's/-//g' <<< $(uuidgen))/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/auth_salt_value/$(sed 's/-//g' <<< $(uuidgen))/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/logged_in_salt_value/$(sed 's/-//g' <<< $(uuidgen))/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/nonce_salt_value/$(sed 's/-//g' <<< $(uuidgen))/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/wordpress_db_name/$wordress_db/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/wordpress_user/$wordpress_user/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/wordress_pwd/$wordpress_pwd/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/wordpress_host/$wordpress_host/g" /opt/bitnami/wordpress/wp-config.php
sed -i "s/wordpress_https/$wordpress_https/g" /opt/bitnami/wordpress/wp-config.php
# Configure wordpress permission
chown -R www-data:www-data /opt/bitnami/wordpress
find /opt/bitnami/wordpress -type f -print0|xargs -0 chmod 644
find /opt/bitnami/wordpress -type d -print0 |xargs -0 chmod 755
chmod 440 /opt/bitnami/wordpress/wp-config.php
# Configure nginx
rm /etc/nginx/sites-enabled/default
wget https://git.dfosd.synology.me/docker/ubuntu-wordpress/raw/branch/master/nginx-ssl.conf -O /etc/nginx/sites-enabled/nginx-ssl.conf