Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02b3671

Browse filesBrowse files
initial commit
1 parent 1a83a58 commit 02b3671
Copy full SHA for 02b3671

File tree

Expand file treeCollapse file tree

6 files changed

+133
-0
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+133
-0
lines changed

‎README.md

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Laravel 5 CodeDeploy Template
2+
An example template for deploying Laravel applications with AWS CodePipeline across an autoscaling group.
3+
For more information see this tutorial: http://docs.aws.amazon.com/codepipeline/latest/userguide/getting-started-w.html

‎appspec.yml

Copy file name to clipboard
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 0.0
2+
os: linux
3+
hooks:
4+
BeforeInstall:
5+
- location: scripts/install_dependencies
6+
timeout: 300
7+
runas: root
8+
- location: scripts/start_server
9+
timeout: 60
10+
runas: root
11+
Install:
12+
- location: scripts/deploy_laravel
13+
timeout: 300
14+
runas: root
15+
ApplicationStop:
16+
- location: scripts/stop_server
17+
timeout: 300
18+
runas: root

‎scripts/deploy_laravel

Copy file name to clipboard
+52Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
# Cleanup html and clone reposity
4+
cd /var/www/html/
5+
git init
6+
git remote add origin https://github.com/laravel/laravel.git
7+
git clean -f -d # this is required if files in the non-empty directory are in the repo
8+
git fetch
9+
git reset --hard origin/master
10+
11+
# Create cache and chmod folders
12+
mkdir -p /var/www/html/bootstrap/cache
13+
mkdir -p /var/www/html/storage/framework/sessions
14+
mkdir -p /var/www/html/storage/framework/views
15+
mkdir -p /var/www/html/storage/framework/cache
16+
mkdir -p /var/www/html/public/files/
17+
18+
# Configure Env
19+
cp /var/www/html/.env.example /var/www/html/.env
20+
21+
# Install dependencies
22+
cd /var/www/html/ && composer install
23+
24+
# Configure Application Key
25+
php /var/www/html/artisan key:generate
26+
27+
# Migrate all tables
28+
#php /var/www/html/artisan migrate
29+
30+
# Clear any previous cached views and optimize the application
31+
php /var/www/html/artisan cache:clear
32+
php /var/www/html/artisan view:clear
33+
php /var/www/html/artisan config:cache
34+
php /var/www/html/artisan optimize
35+
#php /var/www/html/artisan route:cache
36+
37+
# Change rights
38+
chmod 777 -R /var/www/html/bootstrap/cache
39+
chmod 777 -R /var/www/html/storage
40+
chmod 777 -R /var/www/html/public/files/
41+
42+
# Replace environment variables
43+
sed -e '/\(^APP_URL=\).*/ s//\1http:\/\/localhost/' -i .env
44+
sed -e '/\(^APP_DEBUG=\).*/ s//\1false/' -i .env
45+
sed -e '/\(^APP_NAME=\).*/ s//\1laravel/' -i .env
46+
sed -e '/\(^APP_KEY=\).*/ s//\1base64:awH2+cVts6F2AFbXIcTx0t5nd2GbCkkzkY+Tw\/tYQDM=/' -i .env
47+
sed -e '/\(^DB_DATABASE=\).*/ s//\1database/' -i .env
48+
sed -e '/\(^DB_USERNAME=\).*/ s//\1username/' -i .env
49+
sed -e '/\(^DB_PASSWORD=\).*/ s//\1password/' -i .env
50+
51+
# Bring up application
52+
php /var/www/html/artisan up

‎scripts/install_dependencies

Copy file name to clipboard
+47Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Update yum
4+
yum update -y
5+
6+
# Install packages
7+
yum install -y mysql mysql-server
8+
yum install -y curl
9+
yum install -y git
10+
yum install -y python3-pip
11+
12+
# aws cli
13+
pip3 install awscli
14+
15+
# Remove current apache & php
16+
yum -y remove httpd* php*
17+
18+
# Install PHP 7.1
19+
yum install -y php71 php71-cli php71-fpm php71-mysql php71-xml php71-curl php71-opcache php71-pdo php71-gd php71-pecl-apcu php71-mbstring php71-imap php71-pecl-redis php71-mcrypt php71-mysqlnd mod24_ssl
20+
21+
# Install Apache 2.4
22+
yum -y install httpd24
23+
24+
# Allow URL rewrites
25+
sed -i 's#AllowOverride None#AllowOverride All#' /etc/httpd/conf/httpd.conf
26+
27+
# Change apache document root
28+
sed -i 's#DocumentRoot "/var/www/html"#DocumentRoot "/var/www/html/public"#' /etc/httpd/conf/httpd.conf
29+
30+
# Change apache directory index
31+
sed -e 's/DirectoryIndex.*/DirectoryIndex index.html index.php/' -i /etc/httpd/conf/httpd.conf
32+
33+
# Get Composer, and install to /usr/local/bin
34+
if [ ! -f "/usr/local/bin/composer" ];then
35+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
36+
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
37+
php composer-setup.php --install-dir=/usr/bin --filename=composer
38+
php -r "unlink('composer-setup.php');"
39+
else
40+
/usr/local/bin/composer self-update --stable --no-ansi --no-interaction
41+
fi
42+
43+
# Restart apache
44+
service httpd restart
45+
46+
# Setup apache to start on boot
47+
chkconfig httpd on

‎scripts/start_server

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
service httpd start
3+
service mysqld start

‎scripts/stop_server

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
isExistHttps = `pgrep httpd`
3+
if [[ -n $isExistHttps ]]; then
4+
service httpd stop
5+
fi
6+
7+
isExistMysqld = `pgrep httpd`
8+
if [[ -n $isExistMysqld ]]; then
9+
service mysqld stop
10+
fi

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.