Skip to content

Instantly share code, notes, and snippets.

@m3doune
Forked from lelledaniele/cloud9-symfony.md
Created June 8, 2017 10:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save m3doune/50bcc8ef0102bb1e066259b736407ed4 to your computer and use it in GitHub Desktop.
cloud9 symfony apache config server

Symfony on Cloud9

Configuration

  • DB Host: 0.0.0.0 or '' empty string. Result of function getenv('IP')
  • DB Password: YOUR_PASSWORD
  • DB Name: c9
  • DB User: YOUR_USERNAME
  • Generate secret parameter

Setup Apache

Edit the Virtual Host config file

sudo vi /etc/apache2/sites-enabled/001-cloud9.conf

Replace the content with these lines


<VirtualHost *:8080>
    DocumentRoot /home/ubuntu/workspace/web
    ServerName https://${C9_HOSTNAME}:443

    LogLevel info

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /home/ubuntu/workspace/web>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        DirectoryIndex app_dev.php
    </Directory>
</VirtualHost>

ServerName https://${C9_HOSTNAME}
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Allow Cloud9 to run dev environment

Replace these lines

// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
  || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
  || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || php_sapi_name() === 'cli-server')
) {
  header('HTTP/1.0 403 Forbidden');
  exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

with these lines

// Allow Cloud9 IDE to run the dev environment
if(getenv('C9_USER') !== 'YOUR_USERNAME') {

  // This check prevents access to debug front controllers that are deployed by accident to production servers.
  // Feel free to remove this, extend it, or make something more sophisticated.
  if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || php_sapi_name() === 'cli-server')
  ) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
  }

}

Restart Apache

Change .htaccess

Take a backup of .htaccess

cp web/.htaccess web/.htaccess-live.

  • Exclude the .htaccess from your GIT repository
  • Remember to rename .htaccess-live to .htaccess on production

Allow app_dev.php as default enviroment


# Change line 6
# DirectoryIndex app.php
DirectoryIndex app_dev.php

# Change line 57
# RewriteRule ^ %{ENV:BASE}/app.php
RewriteRule ^ %{ENV:BASE}/app_dev.php


Lelle - License

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