-
-
Save YourFriendCaspian/a7c72335058f5cfac809bf5f6e164223 to your computer and use it in GitHub Desktop.
simple-init-script.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# from http://ubuntuserverguide.com/2012/06/how-to-installing-nginx-with-php5-and-mysql-support-on-ubuntu-server-12-04-lts.html | |
PHP_SCRIPT=/usr/sbin/php-fastcgi | |
FASTCGI_USER=www-data | |
FASTCGI_GROUP=www-data | |
PID_DIR=/var/run/php-fastcgi | |
PID_FILE=/var/run/php-fastcgi/php-fastcgi.pid | |
RET_VAL=0 | |
case "$1" in | |
start) | |
if [[ ! -d $PID_DIR ]] | |
then | |
mkdir $PID_DIR | |
chown $FASTCGI_USER:$FASTCGI_GROUP $PID_DIR | |
chmod 0770 $PID_DIR | |
fi | |
if [[ -r $PID_FILE ]] | |
then | |
echo "php-fastcgi already running with PID `cat $PID_FILE`" | |
RET_VAL=1 | |
else | |
$PHP_SCRIPT | |
RET_VAL=$? | |
fi | |
;; | |
stop) | |
if [[ -r $PID_FILE ]] | |
then | |
kill `cat $PID_FILE` | |
rm $PID_FILE | |
RET_VAL=$? | |
else | |
echo "Could not find PID file $PID_FILE" | |
RET_VAL=1 | |
fi | |
;; | |
restart) | |
if [[ -r $PID_FILE ]] | |
then | |
kill `cat $PID_FILE` | |
rm $PID_FILE | |
RET_VAL=$? | |
else | |
echo "Could not find PID file $PID_FILE" | |
fi | |
$PHP_SCRIPT | |
RET_VAL=$? | |
;; | |
status) | |
if [[ -r $PID_FILE ]] | |
then | |
echo "php-fastcgi running with PID `cat $PID_FILE`" | |
RET_VAL=$? | |
else | |
echo "Could not find PID file $PID_FILE, php-fastcgi does not appear to be running" | |
fi | |
;; | |
*) | |
echo "Usage: php-fastcgi {start|stop|restart|status}" | |
RET_VAL=1 | |
;; | |
esac | |
exit $RET_VAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment