Last active
July 18, 2022 16:26
-
-
Save yoX64/ba1812d8e6dde5158562af25dc059c83 to your computer and use it in GitHub Desktop.
DigitalOcean LEMP User Data provisioning script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Configure NGNIX | |
sudo mkdir -p /var/www/api.notify.biz/html | |
sudo mkdir -p /var/www/api-stage.notify.biz/html | |
sudo chown -R $USER:$USER /var/www/api.notify.biz/html | |
sudo chown -R $USER:$USER /var/www/api-stage.notify.biz/html | |
sudo chmod -R 755 /var/www | |
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/api.notify.biz | |
cat > /etc/nginx/sites-available/api.notify.biz <<EOF | |
server { | |
root /var/www/api.notify.biz/html; | |
index index.php index.html index.htm index.nginx-debian.html; | |
server_name api.notify.biz; | |
error_log /var/log/nginx/error.api.notify.biz.log; | |
access_log /var/log/nginx/access.api.notify.biz.log; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; | |
} | |
} | |
EOF | |
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/api-stage.notify.biz | |
cat > /etc/nginx/sites-available/api-stage.notify.biz <<EOF | |
server { | |
root /var/www/api-stage.notify.biz/html; | |
index index.php index.html index.htm index.nginx-debian.html; | |
server_name api-stage.notify.biz; | |
error_log /var/log/nginx/error.api-stage.notify.biz.log; | |
access_log /var/log/nginx/access.api-stage.notify.biz.log; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; | |
} | |
} | |
EOF | |
sudo ln -s /etc/nginx/sites-available/api.notify.biz /etc/nginx/sites-enabled/ | |
sudo ln -s /etc/nginx/sites-available/api-stage.notify.biz /etc/nginx/sites-enabled/ | |
sudo systemctl restart nginx | |
# Configure nginx.conf | |
sudo nano /etc/nginx/nginx.conf | |
# Uncomment server_names_hash_bucket_size 64; | |
# Install PHP extensions | |
sudo apt install php-gmp | |
sudo apt-get install php-zip | |
sudo apt-get install php-xml | |
# Set permissions for file caching | |
sudo chmod -R 777 /var/www/api-stage.notify.biz/html/system/storage/ | |
# (optional) Stop MySQL service | |
sudo /etc/init.d/mysql stop | |
# (optional) Restart Droplet | |
sudo shutdown -r now | |
# (optional) Update Droplet packages | |
sudo apt-get update && sudo apt-get dist-upgrade |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment