Skip to content

Instantly share code, notes, and snippets.

@xctheo
Forked from MauJFernandez/addwebsite
Last active May 12, 2017 01:49
Show Gist options
  • Select an option

  • Save xctheo/e98ebd3f8d1fd25a5c446494b6721a99 to your computer and use it in GitHub Desktop.

Select an option

Save xctheo/e98ebd3f8d1fd25a5c446494b6721a99 to your computer and use it in GitHub Desktop.

Revisions

  1. xctheo revised this gist May 12, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nginx.template.conf
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ server {
    root PATH/SITENAME/public;

    location / {
    proxy_pass http://178.62.22.7:8080;
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  2. xctheo revised this gist May 12, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nginx.template.conf
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    server {
    listen 80;
    server_name SITENAME www.SITENAME;
    root PATH/SITENAME/public
    root PATH/SITENAME/public;

    location / {
    proxy_pass http://178.62.22.7:8080;
  3. xctheo revised this gist May 12, 2017. 2 changed files with 8 additions and 8 deletions.
    8 changes: 4 additions & 4 deletions apache-vhost-dev.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    #!/bin/sh
    WEBROOT="$HOME/www"
    VHOSTDIR="/etc/apache2/sites-available"
    NGINXDIR="/etc/nginx/sites-available"
    NGINXENABLEDDIR="/etc/nginx/sites-available"
    WEBROOT="$HOME/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    NGINXDIR="/etc/nginx/sites-available/"
    NGINXENABLEDDIR="/etc/nginx/sites-available/"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    RESTARTCMD_NGINX="/usr/bin/sudo service nginx reload"
    8 changes: 4 additions & 4 deletions apache-vhost-production.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    #!/bin/sh
    WEBROOT="$HOME/www"
    VHOSTDIR="/etc/apache2/sites-available"
    NGINXDIR="/etc/nginx/sites-available"
    NGINXENABLEDDIR="/etc/nginx/sites-enabled"
    WEBROOT="$HOME/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    NGINXDIR="/etc/nginx/sites-available/"
    NGINXENABLEDDIR="/etc/nginx/sites-enabled/"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    RESTARTCMD_NGINX="/usr/bin/sudo service nginx reload"
  4. xctheo revised this gist May 12, 2017. 5 changed files with 13 additions and 12 deletions.
    10 changes: 5 additions & 5 deletions apache-vhost-dev.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    #!/bin/sh
    WEBROOT="$HOME/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    NGINXDIR="/etc/nginx/sites-available/"
    NGINXENABLEDDIR="/etc/nginx/sites-available/"
    WEBROOT="$HOME/www"
    VHOSTDIR="/etc/apache2/sites-available"
    NGINXDIR="/etc/nginx/sites-available"
    NGINXENABLEDDIR="/etc/nginx/sites-available"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    RESTARTCMD_NGINX="/usr/bin/sudo service nginx reload"
    @@ -24,7 +24,7 @@ if [ "$1" != '' ]; then
    sudo cp "$NGINXDIR/template.conf" "$NGINXDIR$1$EXTENSION"
    echo "created $NGINXDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    sudo find "$NGINXDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" {} \;
    sudo find "$NGINXDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" -e "s,PATH,$WEBROOT,g" {} \;
    sudo ln -s "$NGINXDIR$1$EXTENSION" "$NGINXENABLEDDIR$1$EXTENSION"
    if [ ! -d "$WEBROOT$1/" ]; then
    sudo mkdir -p "$WEBROOT$1/public"
    10 changes: 5 additions & 5 deletions apache-vhost-production.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    #!/bin/sh
    WEBROOT="$HOME/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    NGINXDIR="/etc/nginx/sites-available/"
    NGINXENABLEDDIR="/etc/nginx/sites-enabled/"
    WEBROOT="$HOME/www"
    VHOSTDIR="/etc/apache2/sites-available"
    NGINXDIR="/etc/nginx/sites-available"
    NGINXENABLEDDIR="/etc/nginx/sites-enabled"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    RESTARTCMD_NGINX="/usr/bin/sudo service nginx reload"
    @@ -24,7 +24,7 @@ if [ "$1" != '' ]; then
    sudo cp "$NGINXDIR/template.conf" "$NGINXDIR$1$EXTENSION"
    echo "created $NGINXDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    sudo find "$NGINXDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" {} \;
    sudo find "$NGINXDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" -e "s,PATH,$WEBROOT,g" {} \;
    sudo ln -s "$NGINXDIR$1$EXTENSION" "$NGINXENABLEDDIR$1$EXTENSION"
    if [ ! -d "$WEBROOT$1/" ]; then
    sudo mkdir -p "$WEBROOT$1/public"
    1 change: 1 addition & 0 deletions nginx.template.conf
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    server {
    listen 80;
    server_name SITENAME www.SITENAME;
    root PATH/SITENAME/public

    location / {
    proxy_pass http://178.62.22.7:8080;
    2 changes: 1 addition & 1 deletion template.conf
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    </Directory>

    DocumentRoot PATH/SITENAME/public
    <Directory PATH//SITENAME/public>
    <Directory PATH/SITENAME/public>
    # enable the .htaccess rewrites
    AllowOverride All
    Require all granted
    2 changes: 1 addition & 1 deletion template.dev.conf
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    </Directory>

    DocumentRoot PATH/SITENAME/public
    <Directory PATH//SITENAME/public>
    <Directory PATH/SITENAME/public>
    # enable the .htaccess rewrites
    AllowOverride All
    Require all granted
  5. xctheo revised this gist Apr 25, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion apache-vhost-production.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    WEBROOT="$HOME/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    NGINXDIR="/etc/nginx/sites-available/"
    NGINXENABLEDDIR="/etc/nginx/sites-available/"
    NGINXENABLEDDIR="/etc/nginx/sites-enabled/"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    RESTARTCMD_NGINX="/usr/bin/sudo service nginx reload"
  6. xctheo revised this gist Apr 25, 2017. 3 changed files with 44 additions and 2 deletions.
    17 changes: 16 additions & 1 deletion apache-vhost-dev.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,11 @@
    #!/bin/sh
    WEBROOT="$HOME/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    NGINXDIR="/etc/nginx/sites-available/"
    NGINXENABLEDDIR="/etc/nginx/sites-available/"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    RESTARTCMD_NGINX="/usr/bin/sudo service nginx reload"
    if [ "$1" != '' ]; then
    if [ ! -f "$VHOSTDIR$1.conf" ]; then
    sudo cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    @@ -13,6 +16,16 @@ if [ "$1" != '' ]; then
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    sudo find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" -e "s,PATH,$WEBROOT,g" {} \;
    if [ ! -f "$NGINXDIR$1.conf" ]; then
    sudo cp "$NGINXDIR/template.conf" "$NGINXDIR$1$EXTENSION"
    echo "created $NGINXDIR$1$EXTENSION"
    else
    sudo mv "$NGINXDIR$1.conf" "$NGINXDIR$1$EXTENSION.bak"
    sudo cp "$NGINXDIR/template.conf" "$NGINXDIR$1$EXTENSION"
    echo "created $NGINXDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    sudo find "$NGINXDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" {} \;
    sudo ln -s "$NGINXDIR$1$EXTENSION" "$NGINXENABLEDDIR$1$EXTENSION"
    if [ ! -d "$WEBROOT$1/" ]; then
    sudo mkdir -p "$WEBROOT$1/public"
    sudo chown -R www-data:www-data "$WEBROOT$1/"
    @@ -22,7 +35,9 @@ if [ "$1" != '' ]; then
    fi
    sudo a2ensite $1
    $RESTARTCMD
    echo "reloaded apache"
    echo "reloaded apache"
    $RESTARTCMD_NGINX
    echo "reloaded nginx"
    elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    echo "usage:"
    echo "sudo addwebsite "
    17 changes: 16 additions & 1 deletion apache-vhost-production.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,11 @@
    #!/bin/sh
    WEBROOT="$HOME/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    NGINXDIR="/etc/nginx/sites-available/"
    NGINXENABLEDDIR="/etc/nginx/sites-available/"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    RESTARTCMD_NGINX="/usr/bin/sudo service nginx reload"
    if [ "$1" != '' ]; then
    if [ ! -f "$VHOSTDIR$1.conf" ]; then
    sudo cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    @@ -13,6 +16,16 @@ if [ "$1" != '' ]; then
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    sudo find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" -e "s,PATH,$WEBROOT,g" {} \;
    if [ ! -f "$NGINXDIR$1.conf" ]; then
    sudo cp "$NGINXDIR/template.conf" "$NGINXDIR$1$EXTENSION"
    echo "created $NGINXDIR$1$EXTENSION"
    else
    sudo mv "$NGINXDIR$1.conf" "$NGINXDIR$1$EXTENSION.bak"
    sudo cp "$NGINXDIR/template.conf" "$NGINXDIR$1$EXTENSION"
    echo "created $NGINXDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    sudo find "$NGINXDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" {} \;
    sudo ln -s "$NGINXDIR$1$EXTENSION" "$NGINXENABLEDDIR$1$EXTENSION"
    if [ ! -d "$WEBROOT$1/" ]; then
    sudo mkdir -p "$WEBROOT$1/public"
    sudo chown -R www-data:www-data "$WEBROOT$1/"
    @@ -22,7 +35,9 @@ if [ "$1" != '' ]; then
    fi
    sudo a2ensite $1
    $RESTARTCMD
    echo "reloaded apache"
    echo "reloaded apache"
    $RESTARTCMD_NGINX
    echo "reloaded nginx"
    elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    echo "usage:"
    echo "sudo addwebsite "
    12 changes: 12 additions & 0 deletions nginx.template.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    server {
    listen 80;
    server_name SITENAME www.SITENAME;

    location / {
    proxy_pass http://178.62.22.7:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }
    }
  7. xctheo revised this gist Feb 9, 2017. 4 changed files with 15 additions and 26 deletions.
    14 changes: 7 additions & 7 deletions apache-vhost-dev.sh
    Original file line number Diff line number Diff line change
    @@ -5,17 +5,17 @@ EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    if [ "$1" != '' ]; then
    if [ ! -f "$VHOSTDIR$1.conf" ]; then
    cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    sudo cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION"
    else
    mv "$VHOSTDIR$1.conf" "$VHOSTDIR$1$EXTENSION.bak"
    cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    sudo mv "$VHOSTDIR$1.conf" "$VHOSTDIR$1$EXTENSION.bak"
    sudo cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" -e "s,PATH,$WEBROOT,g" {} \;
    sudo find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" -e "s,PATH,$WEBROOT,g" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir -p "$WEBROOT$1/public"
    chown -R :www-data "$WEBROOT$1/"
    sudo mkdir -p "$WEBROOT$1/public"
    sudo chown -R www-data:www-data "$WEBROOT$1/"
    echo "created $WEBROOT$1/"
    else
    echo "$WEBROOT$1/ already exists"
    @@ -30,6 +30,6 @@ elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    fi

    sudo chown -R www-data:www-data $WEBROOT
    sudo chgrp -R www-data $WEBROOT
    # sudo chgrp -R www-data $WEBROOT
    sudo chmod -R g+rwxs $WEBROOT
    # sed -i "127.0.0.1 $1.local" /etc/hosts
    14 changes: 7 additions & 7 deletions apache-vhost-production.sh
    Original file line number Diff line number Diff line change
    @@ -5,17 +5,17 @@ EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    if [ "$1" != '' ]; then
    if [ ! -f "$VHOSTDIR$1.conf" ]; then
    cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    sudo cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION"
    else
    mv "$VHOSTDIR$1.conf" "$VHOSTDIR$1$EXTENSION.bak"
    cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    sudo mv "$VHOSTDIR$1.conf" "$VHOSTDIR$1$EXTENSION.bak"
    sudo cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" -e "s,PATH,$WEBROOT,g" {} \;
    sudo find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" -e "s,PATH,$WEBROOT,g" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir -p "$WEBROOT$1/public"
    chown -R :www-data "$WEBROOT$1/"
    sudo mkdir -p "$WEBROOT$1/public"
    sudo chown -R www-data:www-data "$WEBROOT$1/"
    echo "created $WEBROOT$1/"
    else
    echo "$WEBROOT$1/ already exists"
    @@ -30,6 +30,6 @@ elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    fi

    sudo chown -R www-data:www-data $WEBROOT
    sudo chgrp -R www-data $WEBROOT
    # sudo chgrp -R www-data $WEBROOT
    sudo chmod -R g+rwxs $WEBROOT
    # sed -i "127.0.0.1 $1.local" /etc/hosts
    7 changes: 1 addition & 6 deletions template.conf
    Original file line number Diff line number Diff line change
    @@ -17,12 +17,7 @@

    Order allow,deny
    Allow from All

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /app.php [QSA,L]
    </IfModule>

    </Directory>

    <IfModule mod_dir.c>
    6 changes: 0 additions & 6 deletions template.dev.conf
    Original file line number Diff line number Diff line change
    @@ -17,12 +17,6 @@

    Order allow,deny
    Allow from All

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /app.php [QSA,L]
    </IfModule>
    </Directory>

    <IfModule mod_dir.c>
  8. xctheo revised this gist Jan 30, 2017. 4 changed files with 14 additions and 8 deletions.
    7 changes: 5 additions & 2 deletions apache-vhost-dev.sh
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,7 @@ if [ "$1" != '' ]; then
    cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SITENAME/$1/" {} \;
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/VAR/$HOME/" {} \;
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" -e "s,PATH,$WEBROOT,g" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir -p "$WEBROOT$1/public"
    chown -R :www-data "$WEBROOT$1/"
    @@ -29,4 +28,8 @@ elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    echo "sudo addwebsite "
    echo "example: to create hostname.localhost just run the command 'sudo addwebsite hostname.localhost'"
    fi

    sudo chown -R www-data:www-data $WEBROOT
    sudo chgrp -R www-data $WEBROOT
    sudo chmod -R g+rwxs $WEBROOT
    # sed -i "127.0.0.1 $1.local" /etc/hosts
    7 changes: 5 additions & 2 deletions apache-vhost-production.sh
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,7 @@ if [ "$1" != '' ]; then
    cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SITENAME/$1/" {} \;
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/VAR/$HOME/" {} \;
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i -e "s,SITENAME,$1,g" -e "s,PATH,$WEBROOT,g" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir -p "$WEBROOT$1/public"
    chown -R :www-data "$WEBROOT$1/"
    @@ -29,4 +28,8 @@ elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    echo "sudo addwebsite "
    echo "example: to create hostname.localhost just run the command 'sudo addwebsite hostname.localhost'"
    fi

    sudo chown -R www-data:www-data $WEBROOT
    sudo chgrp -R www-data $WEBROOT
    sudo chmod -R g+rwxs $WEBROOT
    # sed -i "127.0.0.1 $1.local" /etc/hosts
    4 changes: 2 additions & 2 deletions template.conf
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@
    AllowOverride None
    </Directory>

    DocumentRoot /VAR/www/SITENAME/public
    <Directory /VAR/www/SITENAME/public>
    DocumentRoot PATH/SITENAME/public
    <Directory PATH//SITENAME/public>
    # enable the .htaccess rewrites
    AllowOverride All
    Require all granted
    4 changes: 2 additions & 2 deletions template.dev.conf
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@
    AllowOverride None
    </Directory>

    DocumentRoot /VAR/www/SITENAME/public
    <Directory /VAR/www/SITENAME/public>
    DocumentRoot PATH/SITENAME/public
    <Directory PATH//SITENAME/public>
    # enable the .htaccess rewrites
    AllowOverride All
    Require all granted
  9. xctheo revised this gist Jan 30, 2017. 4 changed files with 8 additions and 6 deletions.
    3 changes: 2 additions & 1 deletion apache-vhost-dev.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/bin/sh
    WEBROOT="/var/www/"
    WEBROOT="$HOME/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    @@ -13,6 +13,7 @@ if [ "$1" != '' ]; then
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SITENAME/$1/" {} \;
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/VAR/$HOME/" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir -p "$WEBROOT$1/public"
    chown -R :www-data "$WEBROOT$1/"
    3 changes: 2 additions & 1 deletion apache-vhost-production.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/bin/sh
    WEBROOT="/var/www/"
    WEBROOT="$HOME/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    @@ -13,6 +13,7 @@ if [ "$1" != '' ]; then
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SITENAME/$1/" {} \;
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/VAR/$HOME/" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir -p "$WEBROOT$1/public"
    chown -R :www-data "$WEBROOT$1/"
    4 changes: 2 additions & 2 deletions template.conf
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@
    AllowOverride None
    </Directory>

    DocumentRoot /var/www/SITENAME/public
    <Directory /var/www/SITENAME/public>
    DocumentRoot /VAR/www/SITENAME/public
    <Directory /VAR/www/SITENAME/public>
    # enable the .htaccess rewrites
    AllowOverride All
    Require all granted
    4 changes: 2 additions & 2 deletions template.dev.conf
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@
    AllowOverride None
    </Directory>

    DocumentRoot /var/www/SITENAME/public
    <Directory /var/www/SITENAME/public>
    DocumentRoot /VAR/www/SITENAME/public
    <Directory /VAR/www/SITENAME/public>
    # enable the .htaccess rewrites
    AllowOverride All
    Require all granted
  10. xctheo revised this gist Jan 12, 2017. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion template.conf
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ServerAdmin webmaster@SITENAME
    ServerName SITENAME
    ServerAlias SITENAME
    ServerAlias www.SITENAME

    <Directory />
    Options FollowSymLinks
    2 changes: 1 addition & 1 deletion template.dev.conf
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ServerAdmin webmaster@SITENAME
    ServerName SITENAME
    ServerAlias SITENAME
    ServerAlias www.SITENAME

    <Directory />
    Options FollowSymLinks
  11. xctheo revised this gist Jan 12, 2017. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion apache-vhost-dev.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ if [ "$1" != '' ]; then
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SITENAME/$1/" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir "$WEBROOT$1/"
    mkdir -p "$WEBROOT$1/public"
    chown -R :www-data "$WEBROOT$1/"
    echo "created $WEBROOT$1/"
    else
    2 changes: 1 addition & 1 deletion apache-vhost-production.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ if [ "$1" != '' ]; then
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SITENAME/$1/" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir "$WEBROOT$1/"
    mkdir -p "$WEBROOT$1/public"
    chown -R :www-data "$WEBROOT$1/"
    echo "created $WEBROOT$1/"
    else
  12. xctheo revised this gist Jan 12, 2017. 6 changed files with 80 additions and 68 deletions.
    10 changes: 5 additions & 5 deletions addwebsite → apache-vhost-dev.sh
    Original file line number Diff line number Diff line change
    @@ -5,17 +5,17 @@ EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    if [ "$1" != '' ]; then
    if [ ! -f "$VHOSTDIR$1.conf" ]; then
    cp "$VHOSTDIR/skeleton" "$VHOSTDIR$1$EXTENSION"
    cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION"
    else
    mv "$VHOSTDIR$1.conf" "$VHOSTDIR$1$EXTENSION.bak"
    cp "$VHOSTDIR/skeleton" "$VHOSTDIR$1$EXTENSION"
    cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SKELETON/$1/" {} \;
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SITENAME/$1/" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir "$WEBROOT$1/"
    chown -R mauro:mauro "$WEBROOT$1/"
    chown -R :www-data "$WEBROOT$1/"
    echo "created $WEBROOT$1/"
    else
    echo "$WEBROOT$1/ already exists"
    @@ -28,4 +28,4 @@ elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    echo "sudo addwebsite "
    echo "example: to create hostname.localhost just run the command 'sudo addwebsite hostname.localhost'"
    fi
    sed -i "127.0.0.1 $1.local" /etc/hosts
    # sed -i "127.0.0.1 $1.local" /etc/hosts
    18 changes: 9 additions & 9 deletions addwebsitedev → apache-vhost-production.sh
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,31 @@
    #!/bin/sh
    WEBROOT="/var/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    EXTENSION="-dev.conf"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    if [ "$1" != '' ]; then
    if [ ! -f "$VHOSTDIR$1$EXTENSION" ]; then
    cp "$VHOSTDIR/skeletondev" "$VHOSTDIR$1$EXTENSION"
    if [ ! -f "$VHOSTDIR$1.conf" ]; then
    cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION"
    else
    mv "$VHOSTDIR$1.conf" "$VHOSTDIR$1$EXTENSION.bak"
    cp "$VHOSTDIR/skeletondev" "$VHOSTDIR$1$EXTENSION"
    cp "$VHOSTDIR/template.conf" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SKELETON/$1/" {} \;
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SITENAME/$1/" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir "$WEBROOT$1/"
    chown -R mauro:mauro "$WEBROOT$1/"
    chown -R :www-data "$WEBROOT$1/"
    echo "created $WEBROOT$1/"
    else
    echo "$WEBROOT$1/ already exists"
    fi
    sudo a2ensite $1$EXTENSION
    sudo a2ensite $1
    $RESTARTCMD
    echo "reloaded apache"
    elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    echo "usage:"
    echo "sudo addwebsitedev "
    echo "sudo addwebsite "
    echo "example: to create hostname.localhost just run the command 'sudo addwebsite hostname.localhost'"
    fi
    sed -i "127.0.0.1 $1.dev.local" /etc/hosts
    # sed -i "127.0.0.1 $1.local" /etc/hosts
    27 changes: 0 additions & 27 deletions skeleton
    Original file line number Diff line number Diff line change
    @@ -1,27 +0,0 @@
    <VIRTUALHOST *:80>

    ServerAdmin webmaster@localhost
    ServerName SKELETON.local

    <DIRECTORY />
    Options FollowSymLinks
    AllowOverride None
    </DIRECTORY>

    DocumentRoot /var/www/SKELETON/web
    <DIRECTORY /var/www/SKELETON/web>
    # enable the .htaccess rewrites
    AllowOverride All
    Order allow,deny
    Allow from All
    DirectoryIndex app.php

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /app.php [QSA,L]
    </IfModule>
    </DIRECTORY>
    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
    </VIRTUALHOST>
    27 changes: 0 additions & 27 deletions skeletondev
    Original file line number Diff line number Diff line change
    @@ -1,27 +0,0 @@
    <VIRTUALHOST *:80>

    ServerAdmin webmaster@localhost
    ServerName SKELETON.dev.local

    <DIRECTORY />
    Options FollowSymLinks
    AllowOverride None
    </DIRECTORY>

    DocumentRoot /var/www/SKELETON/web
    <DIRECTORY /var/www/SKELETON/web>
    # enable the .htaccess rewrites
    AllowOverride All
    Order allow,deny
    Allow from All
    DirectoryIndex app_dev.php

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /app_dev.php [QSA,L]
    </IfModule>
    </DIRECTORY>
    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
    </VIRTUALHOST>
    33 changes: 33 additions & 0 deletions template.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    <VIRTUALHOST *:80>

    ServerAdmin webmaster@SITENAME
    ServerName SITENAME
    ServerAlias SITENAME

    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>

    DocumentRoot /var/www/SITENAME/public
    <Directory /var/www/SITENAME/public>
    # enable the .htaccess rewrites
    AllowOverride All
    Require all granted

    Order allow,deny
    Allow from All

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /app.php [QSA,L]
    </IfModule>
    </Directory>

    <IfModule mod_dir.c>
    DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
    </IfModule>
    ErrorLog /var/log/apache2/SITENAME_error.log
    CustomLog /var/log/apache2/SITENAME_access.log combined
    </VIRTUALHOST>
    33 changes: 33 additions & 0 deletions template.dev.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    <VIRTUALHOST *:80>

    ServerAdmin webmaster@SITENAME
    ServerName SITENAME
    ServerAlias SITENAME

    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>

    DocumentRoot /var/www/SITENAME/public
    <Directory /var/www/SITENAME/public>
    # enable the .htaccess rewrites
    AllowOverride All
    Require all granted

    Order allow,deny
    Allow from All

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /app.php [QSA,L]
    </IfModule>
    </Directory>

    <IfModule mod_dir.c>
    DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
    </IfModule>
    ErrorLog /var/log/apache2/SITENAME_error.log
    CustomLog /var/log/apache2/SITENAME_access.log combined
    </VIRTUALHOST>
  13. @MauJFernandez MauJFernandez revised this gist Jun 22, 2014. 2 changed files with 4 additions and 2 deletions.
    3 changes: 2 additions & 1 deletion addwebsite
    Original file line number Diff line number Diff line change
    @@ -27,4 +27,5 @@ elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    echo "usage:"
    echo "sudo addwebsite "
    echo "example: to create hostname.localhost just run the command 'sudo addwebsite hostname.localhost'"
    fi
    fi
    sed -i "127.0.0.1 $1.local" /etc/hosts
    3 changes: 2 additions & 1 deletion addwebsitedev
    Original file line number Diff line number Diff line change
    @@ -27,4 +27,5 @@ elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    echo "usage:"
    echo "sudo addwebsitedev "
    echo "example: to create hostname.localhost just run the command 'sudo addwebsite hostname.localhost'"
    fi
    fi
    sed -i "127.0.0.1 $1.dev.local" /etc/hosts
  14. @MauJFernandez MauJFernandez revised this gist Jun 22, 2014. 2 changed files with 57 additions and 0 deletions.
    30 changes: 30 additions & 0 deletions addwebsitedev
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    #!/bin/sh
    WEBROOT="/var/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    EXTENSION="-dev.conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    if [ "$1" != '' ]; then
    if [ ! -f "$VHOSTDIR$1$EXTENSION" ]; then
    cp "$VHOSTDIR/skeletondev" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION"
    else
    mv "$VHOSTDIR$1.conf" "$VHOSTDIR$1$EXTENSION.bak"
    cp "$VHOSTDIR/skeletondev" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SKELETON/$1/" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir "$WEBROOT$1/"
    chown -R mauro:mauro "$WEBROOT$1/"
    echo "created $WEBROOT$1/"
    else
    echo "$WEBROOT$1/ already exists"
    fi
    sudo a2ensite $1$EXTENSION
    $RESTARTCMD
    echo "reloaded apache"
    elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    echo "usage:"
    echo "sudo addwebsitedev "
    echo "example: to create hostname.localhost just run the command 'sudo addwebsite hostname.localhost'"
    fi
    27 changes: 27 additions & 0 deletions skeletondev
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <VIRTUALHOST *:80>

    ServerAdmin webmaster@localhost
    ServerName SKELETON.dev.local

    <DIRECTORY />
    Options FollowSymLinks
    AllowOverride None
    </DIRECTORY>

    DocumentRoot /var/www/SKELETON/web
    <DIRECTORY /var/www/SKELETON/web>
    # enable the .htaccess rewrites
    AllowOverride All
    Order allow,deny
    Allow from All
    DirectoryIndex app_dev.php

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /app_dev.php [QSA,L]
    </IfModule>
    </DIRECTORY>
    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
    </VIRTUALHOST>
  15. @MauJFernandez MauJFernandez created this gist Jun 22, 2014.
    30 changes: 30 additions & 0 deletions addwebsite
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    #!/bin/sh
    WEBROOT="/var/www/"
    VHOSTDIR="/etc/apache2/sites-available/"
    EXTENSION=".conf"
    RESTARTCMD="/usr/bin/sudo service apache2 reload"
    if [ "$1" != '' ]; then
    if [ ! -f "$VHOSTDIR$1.conf" ]; then
    cp "$VHOSTDIR/skeleton" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION"
    else
    mv "$VHOSTDIR$1.conf" "$VHOSTDIR$1$EXTENSION.bak"
    cp "$VHOSTDIR/skeleton" "$VHOSTDIR$1$EXTENSION"
    echo "created $VHOSTDIR$1$EXTENSION and made a backup of the existing conf"
    fi
    find "$VHOSTDIR$1$EXTENSION" -type f -exec sed -i "s/SKELETON/$1/" {} \;
    if [ ! -d "$WEBROOT$1/" ]; then
    mkdir "$WEBROOT$1/"
    chown -R mauro:mauro "$WEBROOT$1/"
    echo "created $WEBROOT$1/"
    else
    echo "$WEBROOT$1/ already exists"
    fi
    sudo a2ensite $1
    $RESTARTCMD
    echo "reloaded apache"
    elif [ "$1" = 'help' ] || [ "$1" = '' ]; then
    echo "usage:"
    echo "sudo addwebsite "
    echo "example: to create hostname.localhost just run the command 'sudo addwebsite hostname.localhost'"
    fi
    27 changes: 27 additions & 0 deletions skeleton
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <VIRTUALHOST *:80>

    ServerAdmin webmaster@localhost
    ServerName SKELETON.local

    <DIRECTORY />
    Options FollowSymLinks
    AllowOverride None
    </DIRECTORY>

    DocumentRoot /var/www/SKELETON/web
    <DIRECTORY /var/www/SKELETON/web>
    # enable the .htaccess rewrites
    AllowOverride All
    Order allow,deny
    Allow from All
    DirectoryIndex app.php

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /app.php [QSA,L]
    </IfModule>
    </DIRECTORY>
    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
    </VIRTUALHOST>