Well, I'm too lazy to doing some command just for change the configuration, here is the script. The logic is simple, change app port
from 80
into 8313
, and make the port 80
maintenance. And to revert it, change app port
from 8313
into 80
, and make the maintenance.conf
disable by change it into extension .confs
.
To use it, make sure the filename just look like below, and then chmod a+x *.sh
. Then ./maintenance.sh
to make it maintenance mode or ./demaintenance.sh
to revert.
#!/bin/bash
# @name : Maintenance script for CRM App
# Change the Application port from 80, into 8313
# and make port 80 go maintenance
# @author : [email protected]
# @date : 3-12-2014
cd /etc/nginx/conf.d/
mv vhost_crm.conf vhost_crm.confs
mv vhost_crm_maintenance.confs vhost_crm_maintenance.conf
echo "Application Port is at 8313"
mv vhost_maintenance.confs vhost_maintenance.conf
echo "Port 80 is now at maintenance"
service nginx reload
echo "service nginx reload"
#!/bin/bash
# @name : DeMaintenance script for CRM App
# Change the Application port from 8313, into 80
# and make maintenance script disable
# @author : [email protected]
# @date : 3-12-2014
cd /etc/nginx/conf.d/
mv vhost_crm.confs vhost_crm.conf
mv vhost_crm_maintenance.conf vhost_crm_maintenance.confs
echo "Application Port is at 80"
mv vhost_maintenance.conf vhost_maintenance.confs
echo "Port 80 is now disable"
service nginx reload
echo "service nginx reload"
server {
listen 80;
root /var/www/p2tk-crm/public;
index index.php;
server_tokens off;
access_log /etc/nginx/conf.d/logs/p2tk-crm_access_log;
error_log /etc/nginx/conf.d/logs/p2tk-crm_error_log error;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
server_tokens off;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
}
server {
listen 8313;
root /var/www/p2tk-crm/public;
index index.php;
server_tokens off;
access_log /etc/nginx/conf.d/logs/p2tk-crm_access_log;
error_log /etc/nginx/conf.d/logs/p2tk-crm_error_log error;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
server_tokens off;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
}
server {
listen 80;
root /var/www/maintenance;
index index.php;
server_tokens off;
access_log /etc/nginx/conf.d/logs/p2tk-crm_access_log;
error_log /etc/nginx/conf.d/logs/p2tk-crm_error_log error;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
server_tokens off;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
}