mirror of
https://github.com/jkaninda/nginx-php-fpm.git
synced 2025-12-06 13:39:42 +01:00
Add custom supervisor config
This commit is contained in:
25
README.md
25
README.md
@@ -34,9 +34,9 @@
|
|||||||
```yml
|
```yml
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
php-fpm:
|
app:
|
||||||
image: jkaninda/nginx-php-fpm:latest
|
image: jkaninda/nginx-php-fpm:latest
|
||||||
container_name: php-fpm
|
container_name: my-app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
#Project root
|
#Project root
|
||||||
@@ -48,9 +48,9 @@ services:
|
|||||||
|
|
||||||
```
|
```
|
||||||
## Laravel `artisan` command usage:
|
## Laravel `artisan` command usage:
|
||||||
### Open php-fpm
|
### CLI
|
||||||
```sh
|
```sh
|
||||||
docker-compose exec php-fpm /bin/bash
|
docker-compose exec app bash
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -65,9 +65,9 @@ php atisan migrate
|
|||||||
```yml
|
```yml
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
php-fpm:
|
app:
|
||||||
image: jkaninda/nginx-php-fpm
|
image: jkaninda/nginx-php-fpm
|
||||||
container_name: php-fpm
|
container_name: my-app
|
||||||
working_dir: /var/www/html #Optional, If you want to use a custom directory
|
working_dir: /var/www/html #Optional, If you want to use a custom directory
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
@@ -76,15 +76,13 @@ services:
|
|||||||
#Project root
|
#Project root
|
||||||
- ./:/var/www/html
|
- ./:/var/www/html
|
||||||
- ~/.ssh:/root/.ssh # If you use private CVS
|
- ~/.ssh:/root/.ssh # If you use private CVS
|
||||||
- ./supervisord:/etc/supervisor/conf.d/ # Supervisor directory, if you want to add more supervisor process config file
|
- #./php.ini:/usr/local/etc/php/conf.d/php.ini # Optional, your custom php init file
|
||||||
- ./php.ini:/usr/local/etc/php/conf.d/php.ini # Optional, your custom php init file
|
|
||||||
- storage-data:/var/www/html/storage/app #Optional, your custom storage data
|
- storage-data:/var/www/html/storage/app #Optional, your custom storage data
|
||||||
environment:
|
environment:
|
||||||
- APP_ENV=development # Optional, or production
|
- APP_ENV=development # Optional, or production
|
||||||
- WORKDIR=/var/www/html #Optional, If you want to use a custom directory
|
|
||||||
- LARAVEL_PROCS_NUMBER=3 # Optional, Laravel queue:work process number
|
- LARAVEL_PROCS_NUMBER=3 # Optional, Laravel queue:work process number
|
||||||
- CLIENT_MAX_BODY_SIZE=20M
|
- CLIENT_MAX_BODY_SIZE=20M # Optional
|
||||||
- DOMAIN=example.com
|
- DOMAIN=example.com # Optional
|
||||||
volumes:
|
volumes:
|
||||||
storage-data:
|
storage-data:
|
||||||
```
|
```
|
||||||
@@ -97,10 +95,13 @@ volumes:
|
|||||||
## Nginx custom config:
|
## Nginx custom config:
|
||||||
### Enable custom nginx config files
|
### Enable custom nginx config files
|
||||||
> /var/www/html/conf/nginx/nginx.conf
|
> /var/www/html/conf/nginx/nginx.conf
|
||||||
<br>
|
|
||||||
|
|
||||||
> /var/www/html/conf/nginx/nginx-site.conf
|
> /var/www/html/conf/nginx/nginx-site.conf
|
||||||
|
|
||||||
|
## Supervisord
|
||||||
|
### Add more supervisor process in
|
||||||
|
> /var/www/html/conf/worker/supervisor.conf
|
||||||
|
|
||||||
|
|
||||||
> P.S. please give a star if you like it :wink:
|
> P.S. please give a star if you like it :wink:
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Red='\033[0;31m' # Red
|
|||||||
Green='\033[0;32m' # Green
|
Green='\033[0;32m' # Green
|
||||||
echo ""
|
echo ""
|
||||||
echo "***********************************************************"
|
echo "***********************************************************"
|
||||||
echo " Starting LARAVEL NGINX PHP-FPM Docker Container "
|
echo " Starting NGINX PHP-FPM Docker Container "
|
||||||
echo "***********************************************************"
|
echo "***********************************************************"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
@@ -12,9 +12,6 @@ set -e
|
|||||||
TASK=/etc/supervisor/conf.d/php-fpm.conf
|
TASK=/etc/supervisor/conf.d/php-fpm.conf
|
||||||
touch $TASK
|
touch $TASK
|
||||||
cat > "$TASK" <<EOF
|
cat > "$TASK" <<EOF
|
||||||
[supervisord]
|
|
||||||
nodaemon=true
|
|
||||||
user=root
|
|
||||||
[program:php-fpm]
|
[program:php-fpm]
|
||||||
command=/usr/local/sbin/php-fpm
|
command=/usr/local/sbin/php-fpm
|
||||||
numprocs=1
|
numprocs=1
|
||||||
@@ -81,14 +78,15 @@ fi
|
|||||||
|
|
||||||
if [ -f /var/www/html/conf/nginx/nginx-site.conf ]; then
|
if [ -f /var/www/html/conf/nginx/nginx-site.conf ]; then
|
||||||
echo "Custom nginx site config found"
|
echo "Custom nginx site config found"
|
||||||
rm /etc/nginx/sites-enabled/default
|
rm /etc/nginx/sites-available/default
|
||||||
cp /var/www/html/conf/nginx/nginx-site.conf /etc/nginx/sites-enabled/default
|
cp /var/www/html/conf/nginx/nginx-site.conf /etc/nginx/sites-available/default
|
||||||
|
echo "${Green} Start nginx with custom server config..."
|
||||||
else
|
else
|
||||||
echo "${Red} nginx-site.conf not found"
|
echo "${Red} nginx-site.conf not found"
|
||||||
echo "${Green} If you want to use custom configs, create config file in /var/www/html/conf/nginx/nginx-site.conf"
|
echo "${Green} If you want to use custom configs, create config file in /var/www/html/conf/nginx/nginx-site.conf"
|
||||||
echo "${Green} Start nginx with default config..."
|
echo "${Green} Start nginx with default config..."
|
||||||
rm -f /etc/nginx/sites-enabled/default
|
rm -f /etc/nginx/sites-available/default
|
||||||
TASK=/etc/nginx/sites-enabled/default
|
TASK=/etc/nginx/sites-available/default
|
||||||
touch $TASK
|
touch $TASK
|
||||||
cat > "$TASK" <<EOF
|
cat > "$TASK" <<EOF
|
||||||
server {
|
server {
|
||||||
@@ -123,6 +121,12 @@ if [ -f /var/www/html/conf/nginx/nginx-site.conf ]; then
|
|||||||
try_files \$uri \$uri/ /index.php?\$query_string;
|
try_files \$uri \$uri/ /index.php?\$query_string;
|
||||||
gzip_static on;
|
gzip_static on;
|
||||||
}
|
}
|
||||||
|
location ~ \.css {
|
||||||
|
add_header Content-Type text/css;
|
||||||
|
}
|
||||||
|
location ~ \.js {
|
||||||
|
add_header Content-Type application/x-javascript;
|
||||||
|
}
|
||||||
# deny access to Apache .htaccess on Nginx with PHP,
|
# deny access to Apache .htaccess on Nginx with PHP,
|
||||||
# if Apache and Nginx document roots concur
|
# if Apache and Nginx document roots concur
|
||||||
location ~ /\.ht {deny all;}
|
location ~ /\.ht {deny all;}
|
||||||
@@ -132,23 +136,28 @@ if [ -f /var/www/html/conf/nginx/nginx-site.conf ]; then
|
|||||||
location ~ /\.bzr/ {deny all;}
|
location ~ /\.bzr/ {deny all;}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
## Check if the supervisor config file exists
|
||||||
|
if [ -f /var/www/html/conf/worker/supervisor.conf ]; then
|
||||||
|
echo "Custom supervisor config found"
|
||||||
|
cp /var/www/html/conf/worker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
|
||||||
|
else
|
||||||
|
echo "${Red} Supervisor.conf not found"
|
||||||
|
echo "${Green} If you want to add more supervisor configs, create config file in /var/www/html/conf/worker/supervisor.conf"
|
||||||
|
echo "${Green} Start supervisor with default config..."
|
||||||
|
fi
|
||||||
|
## Add nginx process to supervisor
|
||||||
TASK=/etc/supervisor/conf.d/nginx.conf
|
TASK=/etc/supervisor/conf.d/nginx.conf
|
||||||
touch $TASK
|
touch $TASK
|
||||||
cat > "$TASK" <<EOF
|
cat > "$TASK" <<EOF
|
||||||
[supervisord]
|
[program:nginx]
|
||||||
nodaemon=true
|
|
||||||
user=root
|
|
||||||
[program:ginx]
|
|
||||||
command=/usr/sbin/nginx -g "daemon off;"
|
command=/usr/sbin/nginx -g "daemon off;"
|
||||||
numprocs=1
|
numprocs=1
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stderr_logfile=/var/log/ngnix.err.log
|
stderr_logfile=/var/log/ngnix.err.log
|
||||||
stdout_logfile=/var/log/ngnix.out.log
|
stdout_logfile=/var/log/ngnix.out.log
|
||||||
|
user=root
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user