Skip to content

Instantly share code, notes, and snippets.

@mpilosov
Created March 19, 2018 19:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpilosov/36a2dd6a54b1713ae3f40e0338e85e56 to your computer and use it in GitHub Desktop.
Save mpilosov/36a2dd6a54b1713ae3f40e0338e85e56 to your computer and use it in GitHub Desktop.
apache_howto

(as root)

mkdir /var/www/website.com
chown $SAFEUSER:$SAFEUSER /var/www/website.com
export SAFEUSER=yourname (if $SAFEUSER is not set)

This is where you keep the contents of your website. Inside here should exist a public_html directory that will be what apache searches for.

tell apache this site is available by copying a skeleton file over with an appropriate new name

sudo cp /etc/apache2/sites-available/defaultsite.conf /etc/apache2/sites-available/website.com.conf (this assumes you have a defaultsite.conf script. use the one below if not.)

vim /etc/apache2/sites-available/website.com.conf

edit the settings so that they look like:

<VirtualHost *:80>
    ServerAdmin your_email@host.com
    ServerName website.com
    ServerAlias www.website.com
    DocumentRoot /var/www/website.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

The VirtualHost is saying that we'll be looking for things based on their names when a request hits our server.
The server name and aliases are matched against this file and then redirected to the contents of DocumentRoot.

enable (or disable)

sudo a2ensite website.com.conf (sudo a2dissite website.com.conf)

restart for changes to take effect

sudo systemctl restart apache2

(later on, as $SAFEUSER, do )

mkdir /var/www/website.com/public_html

cd /var/www/website.com/
source activate py3
ivy init
ivy build
vim xfer_files.sh
into which you will paste

#!/bin/bash
source activate py3
# rm -rf var/www/website.com/public_html/*
cd /var/www/website.com/
rm -rf out/*
ivy build
cp -r out/* public_html/
# git commit -am 'rebuilt.'
# git push origin master

Uncomment the bottom two lines once you initialize a git repository in the /var/www/website.com/ directory and set an appropriate remote origin address.

You could alternatively clone a git repo, in which case it would be helpful to add the SAFEUSER as owner of the whole /var/www directory altogether and let them make sites in there.

Save this file and make it executable with chmod +x xfer_files.sh.

Once you do this you can now just run ./xfer_files.sh from the command line to update your site. The changes will be visible immediately.

@mpilosov
Copy link
Author

adding a user:
sudo useradd -m michael
sudo passwd michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment