-
Notifications
You must be signed in to change notification settings - Fork 0
/
c9-setup.sh
54 lines (44 loc) · 1.6 KB
/
c9-setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# THIS SCRIPT WILL SET UP APACHE2 SO THAT THE BACKEND WORKS
# TO RUN IT, USE THIS COMMAND:
# bash c9-setup.sh
# make Apache2 use the public folder as the website's root directory
fileDirectory="/etc/apache2/sites-enabled/001-cloud9.conf";
original="DocumentRoot /home/ubuntu/workspace";
corrected="DocumentRoot /home/ubuntu/workspace/public";
if grep -q "$corrected" $fileDirectory; then # if $corrected is already there...
echo "Apache2 is already setup";
else
echo "Apache2 is being configured to use the public/ folder";
sed -i "s#$original#$corrected#g" $fileDirectory; # replace the text
echo "Apache2 is now configured to use the public/ folder"
fi;
# install the dependencies using PHP's Composer
sudo composer self-update; # make sure that it's up-to-date
composer install; # install all dependencies
# make an environment file to manage MySQL
# $C9_USER is your Cloud9 username
# there is no password because no one else can use the database
rm .env -f; # forcefully remove the current settings file if it exists
touch .env; # make an empty file
# this StackOverflow thread explains what is happening: http://goo.gl/Gf9L8Q
# tl;dr saves the settings into the .env file
printf "%s\n" "
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
DB_HOST: 127.0.0.1
DB_DATABASE= c9
DB_USERNAME=$C9_USER
DB_PASSWORD=
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
" >> .env;
echo "Setup process COMPLETE";
echo "To start the server, run public/index.php in the right-click menu on C9";