-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·147 lines (115 loc) · 3.84 KB
/
install.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
#Create by Sergiu Botnarenco
#
#script for complile&install nginx
echo "Init install nginx-1.8.0 script"
echo ""
NGINX_PATH="/etc/nginx"
NGINX_SBIN="/ust/sbin/nginx"
NGINX_PID="/var/run"
NGINX_LOGS="/var/log/nginx"
NGINX_LIBS="/usr/local/nginx/lib"
NGINX_VHOST_PATH="/etc/nginx"
DEPENDENS=(libgd2-xpm-dev checkinstall libssl-dev make openssl automake);
#if [ "dpkg-query -W nginx | awk {'print $1'} = """ ]; then
NGX_INSTALLED_STATUS=$(dpkg -s nginx | grep --regexp='ok installed' | awk {'print $4'});
if [ $NGX_INSTALLED_STATUS == 'installed' ]; then
echo "Nginx package is already installed, for current version install please remove instaled version"
echo " ";
exit;
fi;
if [ ! -d "$NGINX_PATH" ]; then
echo "Create nginx path [$NGINX_PATH]"
sudo mkdir -p "$NGINX_PATH"
fi
if [ ! -d "$NGINX_LIBS" ]; then
echo "Create nginx lib's path [$NGINX_LIBS]"
sudo mkdir -p "$NGINX_LIBS"
fi
if [ ! -d "$NGINX_LOGS" ]; then
echo "Create nginx log path [$NGINX_LOGS]"
sudo mkdir -p "$NGINX_LOGS"
fi
echo "Copy extensions to libs path [$NGINX_LIBS]";
sudo cp -R ./libs/* "$NGINX_LIBS"/
echo "Check required dependences:"
NEED_TO_INSTALL='';
for i in "${DEPENDENS[@]}"
do
dpkg -s "$i" >/dev/null 2>&1 && {
echo "$i is installed."
} || {
NEED_TO_INSTALL="$NEED_TO_INSTALL $i"
}
done;
echo "$NEED_TO_INSTALL"
if [ -n "$NEED_TO_INSTALL" ]; then
echo "Install package dependences: $NEED_TO_INSTALL"
sudo apt-get install $NEED_TO_INSTALL
fi;
ATMK_VERSION=$(automake --version | grep --regexp='\ [0-9].[0-9]\+$' | awk {'print $4'})
if [ "$ATMK_VERSION" != "1.15" ]; then
echo "Upgrade automake 1.15";
cd "./utils/";
tar -xzf automake-1.15.tar.gz
cd "automake-1.15/";
./configure
make && sudo make install
cd ".."
sudo rm -Rf "automake-1.15"
cd ".."
fi;
cd "./nginx-1.8.0/"
./configure --prefix="$NGINX_PATH" \
--user=www-data \
--group=www-data \
--error-log-path="$NGINX_LOGS"/error.log \
--pid-path="$NGINX_PID"/nginx.pid \
--lock-path="$NGINX_PID"/lock/nginx.lock \
--with-http_ssl_module \
--with-http_secure_link_module \
--with-http_image_filter_module \
--with-zlib="$NGINX_LIBS"/zlib-1.2.8 \
--with-pcre="$NGINX_LIBS"/pcre-8.37 \
--add-module="$NGINX_LIBS"/nginx_http_push_module-0.712
sudo make
sudo checkinstall -y --install=yes
cd ..
if [ ! -d "$NGINX_VHOST_PATH/sites-available" ]; then
echo "Create nginx availbe hosts path [$NGINX_VHOST_PATH/sites-available]"
sudo mkdir -p "$NGINX_VHOST_PATH/sites-available"
fi
if [ ! -d "$NGINX_VHOST_PATH/sites-enabled" ]; then
echo "Create nginx enabled hosts path [$NGINX_VHOST_PATH/sites-enabled]"
sudo mkdir -p "$NGINX_VHOST_PATH/sites-enabled"
fi
echo "Prepare start/strop scripts"
sudo cp ./scripts/nginx.conf.init /etc/init/nginx.conf
sudo ln -sf /lib/init/upstart-job /etc/init.d/nginx
sudo ln -sf /etc/nginx/sbin/nginx /usr/sbin/nginx
sudo cp ./scripts/nginx.conf.srv "$NGINX_PATH"/conf/nginx.conf
INCLUDE_PATH="include $NGINX_PATH/sites-enabled/*;"
RPATH="${INCLUDE_PATH//\//\\/}"
sudo sed -i "s/#ENABLED_HOST_PATH#/${RPATH}/g" "$NGINX_PATH"/conf/nginx.conf
sudo cp ./scripts/default_https "$NGINX_PATH"/sites-available/default_https
sudo cp ./scripts/default "$NGINX_PATH"/sites-available/default
RNPATH="${NGINX_PATH//\//\\/}"
sudo cp ./scripts/nginx_aliases ~/.nginx_aliases
sudo sed -i "s/#NGINX_PATH#/${RNPATH}/g" ~/.nginx_aliases
sudo chmod a+x ~/.nginx_aliases
if grep -Fsq "~/.nginx_aliases" ~/.bashrc
then
. ~/.bashrc
else
echo 'if [ -f ~/.nginx_aliases ]; then
. ~/.nginx_aliases
fi' >> ~/.bashrc
. ~/.bashrc
fi
sudo ln -sf $NGINX_PATH/sites-available/default $NGINX_PATH/sites-enabled/default
sudo mkdir -p /var/www/html;
sudo cp -f ./scripts/index.html ./scripts/50x.html -t /var/www/html/;
sudo cp -f ./scripts/index.html ./scripts/50x.html -t /etc/nginx/html/;
sudo service nginx start
sudo update-rc.d nginx defaults
sudo service nginx status