]> BookStack Code Mirror - devops/blobdiff - scripts/installation-ubuntu-18.04.sh
Updated 18.04 install script to use php7.4
[devops] / scripts / installation-ubuntu-18.04.sh
index af398e6ccc6cb3b0ace34d3b096868832bd12943..3ac52f0301b0682d1e71a757d83b906a5bd57e05 100644 (file)
@@ -2,16 +2,25 @@
 # This script will install a new BookStack instance on a fresh Ubuntu 18.04 server.
 # This script is experimental and does not ensure any security.
 
+# Fetch domain to use from first provided parameter,
+# Otherwise request the user to input their domain
+DOMAIN=$1
+if [ -z $1 ]
+then
 echo ""
 printf "Enter the domain you want to host BookStack and press [ENTER]\nExamples: my-site.com or docs.my-site.com\n"
 read DOMAIN
+fi
 
+# Get the current machine IP address
 CURRENT_IP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1  -d'/')
 
+# Install core system packages
 export DEBIAN_FRONTEND=noninteractive
-apt update
-apt install -y git apache2 curl php7.2-fpm php7.2-curl php7.2-mbstring php7.2-ldap \
-php7.2-tidy php7.2-xml php7.2-zip php7.2-gd php7.2-mysql mysql-server-5.7 libapache2-mod-php7.2
+add-apt-repository universe
+add-apt-repository -yu ppa:ondrej/php
+apt install -y git apache2 php7.4 curl php7.4-fpm php7.4-curl php7.4-mbstring php7.4-ldap \
+php7.4-xml php7.4-zip php7.4-gd php7.4-mysql mysql-server-5.7 libapache2-mod-php7.4
 
 # Set up database
 DB_PASS="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13)"
@@ -41,15 +50,17 @@ else
     exit 1
 fi
 
-# Install BookStack composer dependancies
-php composer.phar install
+# Install BookStack composer dependencies
+export COMPOSER_ALLOW_SUPERUSER=1
+php composer.phar install --no-dev --no-plugins
 
 # Copy and update BookStack environment variables
 cp .env.example .env
+sed -i.bak "s@APP_URL=.*\$@APP_URL=http://$DOMAIN@" .env
 sed -i.bak 's/DB_DATABASE=.*$/DB_DATABASE=bookstack/' .env
 sed -i.bak 's/DB_USERNAME=.*$/DB_USERNAME=bookstack/' .env
 sed -i.bak "s/DB_PASSWORD=.*\$/DB_PASSWORD=$DB_PASS/" .env
-echo "APP_URL="
+
 # Generate the application key
 php artisan key:generate --no-interaction --force
 # Migrate the databases
@@ -60,7 +71,7 @@ chown www-data:www-data -R bootstrap/cache public/uploads storage && chmod -R 75
 
 # Set up apache
 a2enmod rewrite
-a2enmod php7.2
+a2enmod php7.4
 
 cat >/etc/apache2/sites-available/bookstack.conf <<EOL
 <VirtualHost *:80>
@@ -96,8 +107,8 @@ cat >/etc/apache2/sites-available/bookstack.conf <<EOL
         </IfModule>
     </Directory>
 
-       ErrorLog ${APACHE_LOG_DIR}/error.log
-       CustomLog ${APACHE_LOG_DIR}/access.log combined
+       ErrorLog \${APACHE_LOG_DIR}/error.log
+       CustomLog \${APACHE_LOG_DIR}/access.log combined
 
 </VirtualHost>
 EOL