Thanks Graham. I will start reading up the doc resources and then get back 
should there be more questions. Thanks for the always helpful comments and help 
in pointing us the right direction. 

> Den 29. jul. 2021 kl. 07.51 skrev Graham Dumpleton 
> <[email protected]>:
> 
> In general make sure you read this.
> 
> https://modwsgi.readthedocs.io/en/master/user-guides/reloading-source-code.html
>  
> <https://modwsgi.readthedocs.io/en/master/user-guides/reloading-source-code.html>
> 
> Note that mod_wsgi-express uses daemon mode by default.
> 
> The issue in your case is that you are using Django management command which 
> means you are relying on the Django project to start mod_wsgi-express.
> 
> The alternative would be to not use the Django management command which does 
> mean though needing to pass extra options to mod_wsgi-express to set up 
> static files etc. See:
> 
> http://blog.dscpl.com.au/2015/04/using-modwsgi-express-with-django.html 
> <http://blog.dscpl.com.au/2015/04/using-modwsgi-express-with-django.html>
> 
> If you did that though and had the WSGI script file separate to the Django 
> code so it isn't modified when updating Django, you could leave the server 
> running, update Django code, then touch or update the WSGI script file and 
> mod_wsgi-express daemon process would automatically shutdown and restart 
> without you needing to stop the whole Apache server.
> 
> Whether this is a good idea really depends on the complexity of the 
> application, plus if needing to do database migrations you probably need to 
> stop the whole server anyway to be safe.
> 
>> On 29 Jul 2021, at 3:43 pm, Jian Wu <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> Thanks Graham. It makes much more sense now. I have disabled the apache2 so 
>> it is the modwsgi instance that runs now. I have just tested and confirmed 
>> that I can still stop the apache server using the below command
>> 
>> sudo /etc/wsgi-port-80/apachectl stop
>> 
>> Also, in your experience what is the best practice when I need to update my 
>> Django code? I am now doing the followings right now
>> 
>> 1) Apply the above command to stop the apache server
>> 
>> 2) Do my Django updates
>> 
>> 3) Running the below script again to start up the server
>> 
>>>>>> #!/bin/sh
>>>>>> 
>>>>>> #Configuration on how to start the server
>>>>>> python manage.py runmodwsgi \
>>>>>> --server-root /etc/wsgi-port-80 \
>>>>>> --user www-data --group www-data \
>>>>>> --port 80 --setup-only \
>>>>>> --https-only \
>>>>>> --https-port 443 \
>>>>>> --ssl-certificate-file "/etc/letsencrypt/live/www.dimsum.dk/cert.pem 
>>>>>> <http://www.dimsum.dk/cert.pem>" \
>>>>>> --ssl-certificate-key-file 
>>>>>> "/etc/letsencrypt/live/www.dimsum.dk/privkey.pem 
>>>>>> <http://www.dimsum.dk/privkey.pem>" \
>>>>>> --server-name 'www.dimsum.dk <http://www.dimsum.dk/>'
>>>>>> 
>>>>>> #Starting the server
>>>>>> sudo /etc/wsgi-port-80/apachectl stop
>>>>>> sudo /etc/wsgi-port-80/apachectl start
>> 
>> The reason why I ask is because earlier before I disabled the Apache2 server 
>> I always need to reboot my entire server before I can see the changes I have 
>> made in the website which is annoying. 
>> 
>>> Den 29. jul. 2021 kl. 07.29 skrev Graham Dumpleton 
>>> <[email protected] <mailto:[email protected]>>:
>>> 
>>> So it is still running and would conflict with the mod_express instance.
>>> 
>>> There can only be one Apache instance listening on 80/443.
>>> 
>>> If you are not using the system Apache instance now, you would need to stop 
>>> then disable it.
>>> 
>>> systemctl stop apache2
>>> systemctl disable apache2
>>> 
>>> Only then could you start up the mod_wsgi-express instance on 80/443.
>>> 
>>> If you had looked at the error log in the directory /etc/wsgi-port-80 you 
>>> should have seen an error about it complaining 80/443 was in use when you 
>>> had attempted to start of mod_wsgi-express instance.
>>> 
>>>> On 29 Jul 2021, at 3:25 pm, Jian Wu <[email protected] 
>>>> <mailto:[email protected]>> wrote:
>>>> 
>>>> I am using Ubuntu version 20.04 and I get the followings
>>>> 
>>>> systemctl status apache2
>>>> ● apache2.service - The Apache HTTP Server
>>>>      Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor 
>>>> preset: enabled)
>>>>      Active: active (running) since Wed 2021-07-28 21:35:35 UTC; 7h ago
>>>>        Docs: https://httpd.apache.org/docs/2.4/ 
>>>> <https://httpd.apache.org/docs/2.4/>
>>>>     Process: 1961 ExecReload=/usr/sbin/apachectl graceful (code=exited, 
>>>> status=0/SUCCESS)
>>>>    Main PID: 751 (apache2)
>>>>       Tasks: 73 (limit: 2279)
>>>>      Memory: 100.1M
>>>>      CGroup: /system.slice/apache2.service
>>>>              ├─ 751 /usr/sbin/apache2 -k start
>>>>              ├─1976 /usr/sbin/apache2 -k start
>>>>              ├─1977 /usr/sbin/apache2 -k start
>>>>              └─1978 /usr/sbin/apache2 -k start
>>>> 
>>>> Warning: some journal files were not opened due to insufficient 
>>>> permissions.
>>>> 
>>>> 
>>>>> Den 29. jul. 2021 kl. 07.22 skrev Graham Dumpleton 
>>>>> <[email protected] <mailto:[email protected]>>:
>>>>> 
>>>>> Depending on platform, what do you get for:
>>>>> 
>>>>> # systemctl status apache2          #Debian/Ubuntu 
>>>>> # systemctl status httpd    #RHEL/CentOS/Fedora 
>>>>> 
>>>>>> On 29 Jul 2021, at 3:18 pm, Jian Wu <[email protected] 
>>>>>> <mailto:[email protected]>> wrote:
>>>>>> 
>>>>>> Thanks Graham. This is also my thought. I am using the script below to 
>>>>>> start my modwsgi
>>>>>> 
>>>>>> #!/bin/sh
>>>>>> 
>>>>>> #Configuration on how to start the server
>>>>>> python manage.py runmodwsgi \
>>>>>> --server-root /etc/wsgi-port-80 \
>>>>>> --user www-data --group www-data \
>>>>>> --port 80 --setup-only \
>>>>>> --https-only \
>>>>>> --https-port 443 \
>>>>>> --ssl-certificate-file "/etc/letsencrypt/live/www.dimsum.dk/cert.pem 
>>>>>> <http://www.dimsum.dk/cert.pem>" \
>>>>>> --ssl-certificate-key-file 
>>>>>> "/etc/letsencrypt/live/www.dimsum.dk/privkey.pem 
>>>>>> <http://www.dimsum.dk/privkey.pem>" \
>>>>>> --server-name 'www.dimsum.dk <http://www.dimsum.dk/>'
>>>>>> 
>>>>>> #Starting the server
>>>>>> sudo /etc/wsgi-port-80/apachectl stop
>>>>>> sudo /etc/wsgi-port-80/apachectl start
>>>>>> 
>>>>>> 
>>>>>>> Den 29. jul. 2021 kl. 00.38 skrev Graham Dumpleton 
>>>>>>> <[email protected] <mailto:[email protected]>>:
>>>>>>> 
>>>>>>> Your system Apache is probably still running and was never disabled.
>>>>>>> 
>>>>>>> What was the mod_wsgi-express setup-server command you can to generate 
>>>>>>> the /etc/wsgi-port-80/ config directory to begin with?
>>>>>>> 
>>>>>>>> On 29 Jul 2021, at 6:42 am, Jian Wu <[email protected] 
>>>>>>>> <mailto:[email protected]>> wrote:
>>>>>>>> 
>>>>>>>> Dear all,
>>>>>>>> 
>>>>>>>> I am a bit confused if my website is actually running on modwsgi. 
>>>>>>>> 
>>>>>>>> When I type in the following commands below in my server, I should 
>>>>>>>> expect that my server will stop serving my website. But after running 
>>>>>>>> the below command I can still access my website.
>>>>>>>> 
>>>>>>>> sudo /etc/wsgi-port-80/apachectl stop
>>>>>>>> /etc/wsgi-port-80/apachectl: line 63: warning: setlocale: LC_ALL: 
>>>>>>>> cannot change locale (en_US.UTF-8)
>>>>>>>> httpd (no pid file) not running
>>>>>>>> 
>>>>>>>> My understanding is when I installed modwsgi, it actually installed an 
>>>>>>>> Apache2 isolated environment in my server. I then assumed that when I 
>>>>>>>> stopped apache, I should not longer be able to access my website. 
>>>>>>>> 
>>>>>>>> Is there a way for me to check if my website is actually being served 
>>>>>>>> by the Apache2 server with modwsgi and not another Apache2 server that 
>>>>>>>> is not associated with modwsgi?
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Thanks!
>>>>>>>> 
>>>>>>>> 
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "modwsgi" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>>>>> an email to [email protected] 
>>>>>>>> <mailto:[email protected]>.
>>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/modwsgi/62C31893-47BD-4304-A397-5E5B80FF414C%40gmail.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/modwsgi/62C31893-47BD-4304-A397-5E5B80FF414C%40gmail.com?utm_medium=email&utm_source=footer>.
>>>>>>> 
>>>>>>> 
>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "modwsgi" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>>>> an email to [email protected] 
>>>>>>> <mailto:[email protected]>.
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/modwsgi/8D94077E-4989-473A-8AFE-445A74DEF1CD%40gmail.com
>>>>>>>  
>>>>>>> <https://groups.google.com/d/msgid/modwsgi/8D94077E-4989-473A-8AFE-445A74DEF1CD%40gmail.com?utm_medium=email&utm_source=footer>.
>>>>>> 
>>>>>> 
>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "modwsgi" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>>> an email to [email protected] 
>>>>>> <mailto:[email protected]>.
>>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/modwsgi/C224AD97-E987-4365-88FF-01419BAD3F3C%40gmail.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/modwsgi/C224AD97-E987-4365-88FF-01419BAD3F3C%40gmail.com?utm_medium=email&utm_source=footer>.
>>>>> 
>>>>> 
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google Groups 
>>>>> "modwsgi" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>>> email to [email protected] 
>>>>> <mailto:[email protected]>.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/modwsgi/B9471E6C-626B-4915-B8A8-FE0CA903B9D1%40gmail.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/modwsgi/B9471E6C-626B-4915-B8A8-FE0CA903B9D1%40gmail.com?utm_medium=email&utm_source=footer>.
>>>> 
>>>> 
>>>> -- 
>>>> You received this message because you are subscribed to the Google Groups 
>>>> "modwsgi" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>> email to [email protected] 
>>>> <mailto:[email protected]>.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/modwsgi/C7C39B3F-B6A4-472C-ABD0-7732D8DA24E3%40gmail.com
>>>>  
>>>> <https://groups.google.com/d/msgid/modwsgi/C7C39B3F-B6A4-472C-ABD0-7732D8DA24E3%40gmail.com?utm_medium=email&utm_source=footer>.
>>> 
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "modwsgi" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to [email protected] 
>>> <mailto:[email protected]>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/modwsgi/803E9055-C114-4785-8880-0533F1BF3599%40gmail.com
>>>  
>>> <https://groups.google.com/d/msgid/modwsgi/803E9055-C114-4785-8880-0533F1BF3599%40gmail.com?utm_medium=email&utm_source=footer>.
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "modwsgi" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <mailto:[email protected]>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/modwsgi/FE21B0BA-9C27-4BAB-AFA0-E5D592377E5A%40gmail.com
>>  
>> <https://groups.google.com/d/msgid/modwsgi/FE21B0BA-9C27-4BAB-AFA0-E5D592377E5A%40gmail.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/modwsgi/3060EA7D-4E13-4B42-9AF9-19FDA60C8B95%40gmail.com
>  
> <https://groups.google.com/d/msgid/modwsgi/3060EA7D-4E13-4B42-9AF9-19FDA60C8B95%40gmail.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/modwsgi/9CFF76D2-342C-4290-A2A2-6846EC598B63%40gmail.com.

Reply via email to