Update 'config/nextcloud-config.sh'

This commit is contained in:
bprieshof
2019-02-13 12:50:28 +01:00
parent 433ae8bdb7
commit 46da9e4596

View File

@@ -1,3 +1,34 @@
cd /var/www/$domain/html
sudo -u www-data php occ db:convert-filecache-bigint
wget https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Web/raw/branch/master/config/nextcloud/php-fpm.ini -O /etc/php/7.2/fpm/php.ini
service php7.2-fpm restart
db_suffix=`expr $(ls -l /var/www | grep -c ^d) - 1`
db_name="nextcloud_$db_suffix"
db_user="nextcloud_$db_suffix"
db_pass=$(date +%s|sha256sum|base64|head -c 32)
mysql -u root -p"$password" -e "CREATE DATABASE "$db_name" DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;"
mysql -u root -p"$password" -e "GRANT ALL ON "$db_name".* TO '"$db_user"'@'localhost' IDENTIFIED BY '"$db_pass"';"
mysql -u root -p"$password" -e "FLUSH PRIVILEGES;"
wget https://download.nextcloud.com/server/releases/nextcloud-15.0.4.tar.bz2 -O /tmp/nextcloud.tar.bz2
tar xzvf /tmp/nextcloud.tar.bz2 -C /tmp
cp -a /tmp/nextcloud/. /var/www/"$domain"/html
cat <<EOF > /var/www/$domain/html/config/autoconfig.php
<?php
$AUTOCONFIG = array(
"dbtype" => "mysql",
"dbname" => "${db_name}",
"dbuser" => "${db_user}",
"dbpass" => "${db_pass}",
"dbhost" => "localhost",
"dbtableprefix" => "",
"directory" => "/var/www/$domain/html/data",
);
EOF
rm -f /etc/nginx/sites-available/"$domain"
cat <<EOF > /etc/nginx/sites-available/"$domain" cat <<EOF > /etc/nginx/sites-available/"$domain"
server { server {
root /var/www/$domain/html; root /var/www/$domain/html;
@@ -29,10 +60,10 @@ server {
# rewrite ^/.well-known/webfinger /public.php?service=webfinger last; # rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
location = /.well-known/carddav { location = /.well-known/carddav {
return 301 $scheme://$host/remote.php/dav; return 301 \$scheme://\$host/remote.php/dav;
} }
location = /.well-known/caldav { location = /.well-known/caldav {
return 301 $scheme://$host/remote.php/dav; return 301 \$scheme://\$host/remote.php/dav;
} }
# set max upload size # set max upload size
@@ -48,7 +79,7 @@ server {
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
location / { location / {
rewrite ^ /index.php$request_uri; rewrite ^ /index.php\$request_uri;
} }
location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ { location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
@@ -58,13 +89,13 @@ server {
deny all; deny all;
} }
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+)\.php(?:$|\/) { location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+)\.php(?:\$|\/) {
include snippets/fastcgi-php.conf; include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$; fastcgi_split_path_info ^(.+?\.php)(\/.*|)\$;
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_INFO \$fastcgi_path_info;
fastcgi_param HTTPS on; fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true; fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true; fastcgi_param front_controller_active true;
@@ -72,15 +103,15 @@ server {
fastcgi_request_buffering off; fastcgi_request_buffering off;
} }
location ~ ^\/(?:updater|ocs-provider)(?:$|\/) { location ~ ^\/(?:updater|ocs-provider)(?:\$|\/) {
try_files $uri/ =404; try_files \$uri/ =404;
index index.php; index index.php;
} }
# Adding the cache control header for js and css files # Adding the cache control header for js and css files
# Make sure it is BELOW the PHP block # Make sure it is BELOW the PHP block
location ~ \.(?:css|js|woff2?|svg|gif)$ { location ~ \.(?:css|js|woff2?|svg|gif)\$ {
try_files $uri /index.php$request_uri; try_files \$uri /index.php\$request_uri;
add_header Cache-Control "public, max-age=15778463"; add_header Cache-Control "public, max-age=15778463";
add_header X-Content-Type-Options nosniff; add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block"; add_header X-XSS-Protection "1; mode=block";
@@ -93,8 +124,8 @@ server {
access_log off; access_log off;
} }
location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ { location ~ \.(?:png|html|ttf|ico|jpg|jpeg)\$ {
try_files $uri /index.php$request_uri; try_files \$uri /index.php\$request_uri;
# Optional: Don't log access to other assets # Optional: Don't log access to other assets
access_log off; access_log off;
} }