Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pseudokool/6ec6266c7a71fe84c49f84a1b26829fa to your computer and use it in GitHub Desktop.
Save pseudokool/6ec6266c7a71fe84c49f84a1b26829fa to your computer and use it in GitHub Desktop.

Revisions

  1. pseudokool renamed this gist Aug 30, 2019. 1 changed file with 0 additions and 0 deletions.
  2. pseudokool revised this gist Jun 27, 2019. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions create-subdomain-on-aws-ec2
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Create a subdomain on aws EC2 (Apache2)
    # Create a subdomain on AWS EC2 (Apache2)

    sudo mkdir -vp /var/www/vhosts/myapp.io/httpdocs
    sudo chown -R ec2-user:apache /var/www/vhosts/myapp.io/httpdocs
    @@ -12,11 +12,17 @@ sudo touch /etc/httpd/sites-enabled/myapp.io.conf
    ServerName myapp.io
    ServerAlias *.myapp.io
    DocumentRoot /var/www/vhosts/myapp.io/httpdocs/


    RewriteEngine On
    # especially where AWS ALB is used
    RewriteCond %{HTTP:X-Forwarded-Proto} =http
    RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

    <Directory /var/www/vhosts/myapp.io/httpdocs/>
    Options -Indexes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
    # revisit this config
    php_admin_value open_basedir "/var/www/vhosts/myapp.io/httpdocs/:/tmp/:/"
    </Directory>

  3. @pinstorm pinstorm revised this gist Jun 20, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions create-subdomain-on-aws-ec2
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@ sudo touch /etc/httpd/sites-enabled/myapp.io.conf
    ```
    <VirtualHost *:80>
    ServerName myapp.io
    ServerAlias *.myapp.io
    DocumentRoot /var/www/vhosts/myapp.io/httpdocs/

    <Directory /var/www/vhosts/myapp.io/httpdocs/>
  4. @pinstorm pinstorm created this gist Mar 21, 2018.
    33 changes: 33 additions & 0 deletions create-subdomain-on-aws-ec2
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    # Create a subdomain on aws EC2 (Apache2)

    sudo mkdir -vp /var/www/vhosts/myapp.io/httpdocs
    sudo chown -R ec2-user:apache /var/www/vhosts/myapp.io/httpdocs
    mkdir -vp /var/www/vhosts/myapp.io/logs
    sudo chown -R ec2-user:apache /var/www/vhosts/myapp.io/logs

    sudo touch /etc/httpd/sites-enabled/myapp.io.conf

    ```
    <VirtualHost *:80>
    ServerName myapp.io
    DocumentRoot /var/www/vhosts/myapp.io/httpdocs/

    <Directory /var/www/vhosts/myapp.io/httpdocs/>
    Options -Indexes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
    php_admin_value open_basedir "/var/www/vhosts/myapp.io/httpdocs/:/tmp/:/"
    </Directory>

    ErrorLog /var/www/vhosts/myapp.io/logs/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/www/vhosts/myapp.io/logs/access.log combined
    </VirtualHost>
    ```
    sudo touch /var/www/vhosts/myapp.io/httpdocs/index.html
    sudo printf 'myapp.io' > /var/www/vhosts/myapp.io/httpdocs/index.html
    sudo service httpd restart