Skip to content

Instantly share code, notes, and snippets.

@dyoungwd
Created April 3, 2018 21:12
Show Gist options
  • Save dyoungwd/f346a2de73dc5111179ece928da34831 to your computer and use it in GitHub Desktop.
Save dyoungwd/f346a2de73dc5111179ece928da34831 to your computer and use it in GitHub Desktop.
General Script For Setting Up Your Ubuntu / Debian OpenStack Instance or Server for Website Hosting
# General Script For Setting Up Your Ubuntu / Debian OpenStack Instance or Server for Website Hosting
# You Must Edit 'newuser' And 'example.com' To Desired username And domain
# Install Apache
sudo apt-get update
sudo apt-get install -y apache2
# Install Lamp Instead ( apache, php, mysql )
# sudo apt-get install lamp-server^
# Create New User For Website
sudo adduser newuser
#Switch to NewUser
sudo su newuser
# Change back to server admin
exit
# Assign sudo to NewUser
sudo usermod -aG sudo newuser
#switch to NewUser
sudo su newuser
#Check groups to ensure user has sudo
groups
# Change to Server admin
exit
# Enable ssh for Newuser
sudo nano /etc/ssh/sshd_config
# look for the setting named 'PasswordAuthentication'. To the right of # it, change 'no' to 'yes'.
sudo service sshd restart
# Add Domain
# Create Website Folder Under NewUser
sudo mkdir /home/newuser/example.com
#Configure VirtualHost ( name the file after your domain )
sudo touch /etc/apache2/sites-available/example.com.conf
# Edit File
sudo nano /etc/apache2/sites-available/example.com.conf
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias www.example.com
# ServerAdmin admin@example.com
# DocumentRoot /home/newuser/example.com
# <Directory /home/newuser/example.com>
# AllowOverride all
# Require all granted
# </Directory>
#
# ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
# CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
#</VirtualHost>
# Enable Site
sudo a2ensite example.com
# Reload Apache
sudo service apache2 reload
# Enabeling User Directories (userdir module )
sudo a2enmod userdir
sudo service apache2 restart
# View userdir module
ls -la /etc/apache2/mods-enabled
# Edit File And Change <Directory /home/*/public_html> to <Directory /home/*/> and save
sudo nano /etc/apache2/mods-enabled/userdir.conf
# Restart Apache
sudo service apache2 reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment