diff --git a/lamp-22-04/files/etc/apache2/sites-available/000-default.conf b/lamp-22-04/files/etc/apache2/sites-available/000-default.conf new file mode 100644 index 0000000..3c923aa --- /dev/null +++ b/lamp-22-04/files/etc/apache2/sites-available/000-default.conf @@ -0,0 +1,18 @@ + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + + DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm + + + diff --git a/lamp-22-04/files/etc/update-motd.d/99-one-click b/lamp-22-04/files/etc/update-motd.d/99-one-click new file mode 100755 index 0000000..251198c --- /dev/null +++ b/lamp-22-04/files/etc/update-motd.d/99-one-click @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Configured as part of the DigitalOcean 1-Click Image build process + +myip=$(hostname -I | awk '{print$1}') +cat < /root/.digitalocean_password < /etc/mysql/debian.cnf < + + + + +
+ + +
+ +
+ +

Please log into your Droplet with SSH to configure the LAMP installation.

+
+

See the LAMP 1-Click Quickstart guide for detailed assistance.

+ Quickstart Guide +
+
+

Problem? Submit a question to our Q&A platform and get help from the community.

+ Ask a Question +
+
+ + diff --git a/lamp-22-04/scripts/011-lamp.sh b/lamp-22-04/scripts/011-lamp.sh new file mode 100755 index 0000000..49b6552 --- /dev/null +++ b/lamp-22-04/scripts/011-lamp.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +chown -R www-data: /etc/apache2 +chown -R www-data: /var/log/apache2 +chown -R www-data: /var/www +chown -R www-data: /var/www/html + +# if applicable, configure lamp to use & wait for a mysql dbaas instance. +if [ -f "/root/.digitalocean_dbaas_credentials" ] && [ "$(sed -n "s/^db_protocol=\"\([^:]*\):.*\"$/\1/p" /root/.digitalocean_dbaas_credentials)" = "mysql" ]; then + # grab host & port to block until database connection is ready + host=$(sed -n "s/^db_host=\"\(.*\)\"$/\1/p" /root/.digitalocean_dbaas_credentials) + port=$(sed -n "s/^db_port=\"\(.*\)\"$/\1/p" /root/.digitalocean_dbaas_credentials) + + # wait for db to become available + echo -e "\nWaiting for your database to become available (this may take a few minutes)" + while ! mysqladmin ping -h "$host" -P "$port" --silent; do + printf . + sleep 2 + done + echo -e "\nDatabase available!\n" + + # disable the local MySQL instance + systemctl stop mysql.service + systemctl disable mysql.service + + # cleanup + unset host port + rm -rf /etc/mysql +fi diff --git a/lamp-22-04/template.json b/lamp-22-04/template.json new file mode 100644 index 0000000..37370f3 --- /dev/null +++ b/lamp-22-04/template.json @@ -0,0 +1,79 @@ + +{ + "variables": { + "do_api_token": "{{env `DIGITALOCEAN_API_TOKEN`}}", + "image_name": "lamp-22-04-snapshot-{{timestamp}}", + "apt_packages": "apache2 expect fail2ban lamp-server^ libapache2-mod-php8.2 mysql-server php8.2 php8.2-apcu php8.2-gd php8.2-mysql postfix python3-certbot-apache software-properties-common", + "application_name": "LAMP", + "application_version": "" + }, + "sensitive-variables": ["do_api_token"], + "builders": [ + { + "type": "digitalocean", + "api_token": "{{user `do_api_token`}}", + "image": "ubuntu-22-04-x64", + "region": "nyc3", + "size": "s-1vcpu-1gb", + "ssh_username": "root", + "snapshot_name": "{{user `image_name`}}" + } + ], + "provisioners": [ + { + "type": "shell", + "inline": [ + "cloud-init status --wait" + ] + }, + { + "type": "file", + "source": "common/files/var/", + "destination": "/var/" + }, + { + "type": "file", + "source": "lamp-22-04/files/etc/", + "destination": "/etc/" + }, + { + "type": "file", + "source": "lamp-22-04/files/var/", + "destination": "/var/" + }, + { + "type": "shell", + "environment_vars": [ + "DEBIAN_FRONTEND=noninteractive", + "LC_ALL=C", + "LANG=en_US.UTF-8", + "LC_CTYPE=en_US.UTF-8" + ], + "inline": [ + "apt -qqy update", + "apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' full-upgrade", + "add-apt-repository -y ppa:ondrej/php", + "apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install {{user `apt_packages`}}", + "apt-get -qqy clean" + ] + }, + { + "type": "shell", + "environment_vars": [ + "application_name={{user `application_name`}}", + "application_version={{user `application_version`}}", + "DEBIAN_FRONTEND=noninteractive", + "LC_ALL=C", + "LANG=en_US.UTF-8", + "LC_CTYPE=en_US.UTF-8" + ], + "scripts": [ + "lamp-22-04/scripts/011-lamp.sh", + "common/scripts/014-ufw-apache.sh", + "common/scripts/018-force-ssh-logout.sh", + "common/scripts/020-application-tag.sh", + "common/scripts/900-cleanup.sh" + ] + } + ] +}