-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathconfigure_amz_linux_sample_app.sh
64 lines (54 loc) · 1.83 KB
/
configure_amz_linux_sample_app.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
55
56
57
58
59
60
61
62
63
64
#!/bin/bash -xe
# Read the first parameter into $SAMPLE_APP
if [[ "$1" != "" ]]; then
SAMPLE_APP="$1"
else
echo "Please specify the location of web application you are trying to deploy."
exit 1
fi
# # Read the second parameter into $UWSGI_SERVICE_FILE
# if [[ "$2" != "" ]]; then
# UWSGI_SERVICE_FILE="$2"
# else
# echo "Please specify the location of the uWSGI systemd service unit file."
# exit 1
# fi
# # Read the third parameter into $NGINX_CONFIG
# if [[ "$3" != "" ]]; then
# NGINX_CONFIG="$3"
# else
# echo "Please specify the location of the nginx config file."
# exit 1
# fi
# Install OS packages
yum update -y
yum groupinstall -y "Development Tools"
amazon-linux-extras install -y nginx1
yum install -y nginx python3 python3-pip python3-devel
pip3 install pipenv wheel
pip3 install uwsgi
# Install my-web-app into the /home/ec2-user/SampleApp directory
mkdir -p /var/www/SampleApp
cp $SAMPLE_APP /var/www/SampleApp/SampleApp.zip
cd /var/www/SampleApp
unzip -o SampleApp.zip
rm SampleApp.zip
/usr/local/bin/pipenv install
chown nginx:nginx -R ./*
chown nginx:nginx /var/www
chown nginx:nginx /var/www/SampleApp
# Install uWSGI as a systemd service, enable it to run at boot, then start it
#cp $UWSGI_SERVICE_FILE /etc/systemd/system/mywebapp.uwsgi.service
cp sample-app.uwsgi.service /etc/systemd/system/mywebapp.uwsgi.service
mkdir -p /var/log/uwsgi
chown nginx:nginx /var/log/uwsgi
systemctl enable mywebapp.uwsgi.service
systemctl start mywebapp.uwsgi.service
# Copy the nginx config file, then ensure nginx starts at boot, and restart it to load the config
cp nginx-app.conf /etc/nginx/conf.d/nginx-app.conf
mkdir -p /var/log/nginx
chown nginx:nginx /var/log/nginx
systemctl enable nginx.service
systemctl stop nginx.service
systemctl restart nginx.service
echo "Custom configuration for sample application complete."