Skip to content

Instantly share code, notes, and snippets.

View vandorjw's full-sized avatar

Joost van Dorp vandorjw

View GitHub Profile
@vandorjw
vandorjw / gist:6190376
Last active December 20, 2015 20:28
This is an example configuration for an apache-2.2 web-server. Some directives are optional. EnvVariables have been removed.
<VirtualHost *:80>
ServerName trunk.vandorjw.me
Redirect permanent / https://trunk.vandorjw.me/
</VirtualHost>
<Virtualhost *:443>
ServerAdmin admin@xxxxxxxxxxx
ServerName trunk.vandorjw.me
DirectoryIndex index.html
@vandorjw
vandorjw / Django Envvars
Created August 27, 2013 15:13
3 sections of config files.
#
# -- DJANGO ENVIRONMENT VARIABLES --
#
. /home/user-name/denvvars
#
# .bashrc
#
export WORKON_HOME=/var/virtualenvs
@vandorjw
vandorjw / gist:7032025
Last active December 25, 2015 19:59
Virtual Host Configuration file for Apache-2.4 and mod_wsgi
<VirtualHost *:80>
ServerName notes.vandorjw.me
Redirect permanent / https://notes.vandorjw.me
</VirtualHost>
<Virtualhost *:443>
ServerAdmin [email protected]
ServerName notes.vandorjw.me
# indexes + Directory Root, Mandatory but never used.
@vandorjw
vandorjw / httpd.apache notes
Last active December 25, 2015 20:08
Apache Notes, these are applicable to both 2.4 and 2.2
Check if which vhosts are running:
# httpd -S
Check your version of apache httpd
# httpd -v
If you are running centos, RHEL5,6 or 7, Fedora, remember to put
@vandorjw
vandorjw / gist:7032355
Created October 17, 2013 21:18
Generate a self signed certificate using openssl
#!/bin/bash
openssl genrsa -aes256 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
rm server.pass.key
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 30 -in server.csr -signkey server.key -out server.crt
@vandorjw
vandorjw / gist:7032471
Created October 17, 2013 21:27
Reset the permissions on /var/www/
###DO NOT USE AS IS, please read the comments###
# Debian based systems
chown -R www-data:dev-ops /var/www/
chmod -R u+rX-w,g+rwX,o-rwx /var/www/
# RHEL based
@vandorjw
vandorjw / gist:7046434
Last active December 25, 2015 21:59
SELinux for /var/www and /var/virtualenvs
As root, set everything under /var/www to httpd_sys_content_t
(sh) # semanage fcontext -a -t httpd_sys_content_t "/var/www(/.*)?"
(sh) # restorecon -R /var/www/
As root, set everything under /var/virtualenvs to lib_t
(sh) # semanage fcontext -a -t lib_t "/var/virtualenvs(/.*)?"
(sh) # restorecon -R /var/virtualenvs/
If you want to apply this to a single file, just specify the file, and on restorecon, remove the "-R"
For a server not running X we need to have setools-console and optionally fpaste installed.
fpaste will put the results on the fedora pastebin
(| fpaste optional in each command)
(shell) # yum install setools-console
The following seems to check if booleans are set.
(shell) sesearch -ASCT -s httpd_t -t postgresqld_port_t -c tcp_socket -p name_connect | fpaste
@vandorjw
vandorjw / File-Folder Permissions
Last active January 1, 2016 05:39
File and Folder Permision
sudo groupadd $GRP-NAME
sudo usermod -G $GRP-NAME -a $USR-NAME
setfacl -Rm g:$GRP-NAME,d:g:$GRP-NAME:rwX /top/level/directory/location
sudo yum install uwsgi uwsgi-plugins-python3
uwsgi.ini
[uwsgi]
#variables
projectname = vandorjw
base = /var/sites/me/vandorjw