-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx-php
executable file
·58 lines (50 loc) · 1.04 KB
/
nginx-php
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
#!/bin/sh
NGINX="/usr/local/bin/nginx"
PHP5533="$HOME/.phpbrew/php/php-5.5.33/sbin/php-fpm"
PHP7006="$HOME/.phpbrew/php/php-7.0.6/sbin/php-fpm"
PID_PATH="/usr/local/var/run/"
start_app() {
command=$1
ver=$2
pid="$PID_PATH$ver.pid"
if [ -f $pid ]; then
echo "> ×× $ver is running ..."
else
`sudo $command`
fi
}
stop_app() {
ver=$1
pid="$PID_PATH$ver.pid"
if [ -f $pid ]; then
sudo kill `cat $pid`
else
echo "> ×× $ver is not running."
fi
}
start () {
echo "Start php-fpm ..."
start_app "$PHP5533" "php5533-fpm"
start_app "$PHP7006" "php7006-fpm"
echo "Start Nginx ..."
start_app $NGINX "nginx"
echo "Done!"
}
stop() {
echo "Stop Nginx ..."
stop_app "nginx"
echo "Stop php-fpm ..."
stop_app "php5533-fpm"
stop_app "php7006-fpm"
echo "Done!"
}
if [[ $1 = "start" ]]; then
start
elif [[ $1 = "stop" ]]; then
stop
elif [[ $1 = "restart" ]]; then
stop
start
else
echo "Valid commands: {start|stop|restart}"
fi