Search code examples
nginxopenresty

call openresty's nginx.conf file while running service start/stop/restart nginx command


I am using nginx as web server to my Django project.
I am using command

sudo service nginx start/stop/restart 
to manage nginx server. Now i am using Openresty framework to implement Lua code into nginx server to handle Cache system.
Openrestry provides it's own nginx.conf file. Requirement : Now i want then when i run
sudo service nginx start/stop/restart 
system should call nginx.conf file from Openresty folder(/usr/local/openresty/nginx/conf/nginx.conf in place of /etc/nginx/nginx.confM file.
How can i achieve this ???


Solution

  • You should go to

    cd /etc/init.d 
    vim nginx.conf
    #Edit PATH , DAEMON variable
    PATH=/usr/local/openresty/nginx/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/local/openresty/nginx/sbin/nginx
     

    Now when you will run sudo service nginx start/stop/restart it will call nginx.conf file from openresty folder. While /usr/local/openresty is the path where Openresty is installed by default