Skip to content

Instantly share code, notes, and snippets.

@DardanIljazi
Created November 11, 2018 16:38
Show Gist options
  • Save DardanIljazi/5d9be384db055e6637d6ac87f1769bb2 to your computer and use it in GitHub Desktop.
Save DardanIljazi/5d9be384db055e6637d6ac87f1769bb2 to your computer and use it in GitHub Desktop.
Extra interface (to run after basicinstall.sh)
#!/bin/bash
#THIS SCRIPT SHOULD BE RUN AFTER the basicinstall.sh (and not before).
#Extra for SharedHosting. This script download the page CreateUser.php
LOGIN_USERNAME="admin"
LOGIN_PASSWORD="admin" #Change this for your safety !
#CURL INSTALL
apt-get install -y curl
#APACHE2-UTILS INSTALL. This is only used to have the htpasswd command
sudo apt-get -y install apache2-utils
curl "https://gist.githubusercontent.com/Dardanboy/febeae745fc6a81ffb773ca10b202806/raw/" --output /var/www/default/CreateUser.php
chmod g+rx /var/www/default/CreateUser.php
chgrp www-data /var/www/default/CreateUser.php
PHP_ACTUAL_VERSION=$(php -r "echo PHP_VERSION;" | sed -n 's/.*\(^[[:digit:]].[[:digit:]]\).*/\1/p')
echo "server {
listen 8080; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/default;
index CreateUser.php;
server_name _;
location / {
auth_basic \"Restricted\";
auth_basic_user_file /var/www/default/.htpasswd;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php${PHP_ACTUAL_VERSION}-fpm.sock;
fastcgi_index CreateUser.php;
include fastcgi.conf;
}
}
" > "/etc/nginx/sites-available/default"
htpasswd -b -c /var/www/default/.htpasswd ${LOGIN_USERNAME} ${LOGIN_PASSWORD}
service nginx configtest
service nginx restart
service php${PHP_ACTUAL_VERSION}-fpm restart
service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment