-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.sh
41 lines (36 loc) · 1.39 KB
/
nginx.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
#!/bin/bash
set -e
if [ ! -n "$prj_path" ] ;then
prj_path=$(cd $(dirname $0); pwd -P)
fi
source $prj_path/config.sh
source $prj_path/tools/base.sh
package=$prj_path/package
# openssl
if which yum >/dev/null; then
run_cmd "yum install -y openssl openssl-devel make"
elif which apt-get >/dev/null; then
run_cmd "apt install -y libltdl-dev libssl-dev libpcre3 libpcre3-dev make"
elif which brew >/dev/null; then
echo "Darwin"
fi
ensure_dir "$NGINX_PATH"
ensure_user "$NGINX_USER"
ensure_dir "$package/nginx"
remove_dir "$package/nginx/*"
if [ ! -f "$package/nginx-$NGINX_VERSION.tar.gz" ]; then
wget -O $package/nginx-$NGINX_VERSION.tar.gz $NGINX_DOWNLOAD_URL
fi
tar -zxvf $package/nginx-$NGINX_VERSION.tar.gz -C $package/nginx/ --strip-components 1
cd $package/nginx
./configure --prefix=$NGINX_PATH --user=$NGINX_USER --with-pcre --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-ipv6
make install
if [ $? == 0 ]; then
echo -e "<?php phpinfo();" > $NGINX_PATH/html/index.php
cp -rf $prj_path/nginx-config/* $NGINX_PATH/
run_cmd "`sed -i "s/{{PHP_FASTCGI_LISTEN_PORT}}/$PHP_FASTCGI_LISTEN_PORT/" $NGINX_PATH/conf/nginx.conf`"
run_cmd "`sed -i "s/{{NGINX_LISTEN_PORT}}/$NGINX_LISTEN_PORT/" $NGINX_PATH/conf/nginx.conf`"
run_cmd "ln -s $NGINX_PATH/sbin/* /usr/local/bin/"
else
echo -e nginx install fail. `date` >> install.log
fi