1

I am trying to host my Django website using CyberPanel on OpenLiteSpeed. I have completed website development. The website is running properly when I run in debug mode (using runserver command). I am trying to deploy the website.

I am using CyberPanel as I wish to deploy my own SMTP server.

I have used the following article to install cyber-panel on my digital ocean server : https://cyberpanel.net/docs/installing-cyberpanel/

I have used the following article to install and configure Django based website on Openlitespeed server https://cyberpanel.net/blog/2019/01/10/how-to-setup-django-application-on-cyberpanel-openlitespeed/

When I try to open website unionelectronics.in I get 503 Service Unavailable (The server is temporarily busy, try again later!) error.

I have updated A record in DNS Management on godaddy to point to my cloud service provider (digital ocean).

Error Log :

2021-10-05 14:53:37.241089 [INFO] [817] [config:server:vhosts:vhost:Example] config context /docs/.
2021-10-05 14:53:37.241103 [INFO] [817] [config:server:vhosts:vhost:Example] config context /protected/.
2021-10-05 14:53:37.242757 [INFO] [817] [PlainConf] [virtualHostConfig:] start parsing file /usr/local/lsws/conf/vhosts/unionelectronics.in/vhost.conf
2021-10-05 14:53:37.243519 [INFO] [817] [PlainConf] [virtualHostConfig:] Finished parsing file /usr/local/lsws/conf/vhosts/unionelectronics.in/vhost.conf
2021-10-05 14:53:37.243533 [INFO] [817] [PlainConf] [virtualHostConfig:] context [/] add param [envtype 1]
2021-10-05 14:53:37.251116 [NOTICE] [817] [SSL_CTX: 0x124eb20] OCSP Stapling can't be enabled: [OCSP] /etc/letsencrypt/live/unionelectronics.in/fullchain.pem: X509_STORE_CTX_get1_issuer failed!.
2021-10-05 14:53:37.251224 [INFO] [817] [config:server:vhosts:vhost:unionelectronics.in] config context /.
2021-10-05 14:53:37.257606 [INFO] [817] [PlainConf] [virtualHostTemplate:] start parsing file /usr/local/lsws/conf/templates/ccl.conf
2021-10-05 14:53:37.261988 [INFO] [817] [PlainConf] [virtualHostTemplate:] Finished parsing file /usr/local/lsws/conf/templates/ccl.conf
2021-10-05 14:53:37.262027 [INFO] [817] [PlainConf] [context:/] rewrite [] add rules [rewritefile .htaccess]
2021-10-05 14:53:37.262326 [INFO] [817] [PlainConf] [virtualHostTemplate:] start parsing file /usr/local/lsws/conf/templates/rails.conf
2021-10-05 14:53:37.274452 [INFO] [817] [PlainConf] [virtualHostTemplate:] Finished parsing file /usr/local/lsws/conf/templates/rails.conf
2021-10-05 14:53:37.274503 [INFO] [817] [PlainConf] [context:/] rewrite [] add rules [rewritefile .htaccess]
2021-10-05 14:53:37.274660 [NOTICE] [817] [ZConfManager] No VHosts added, do not send!
2021-10-05 14:53:37.275041 [NOTICE] [817] Instance is ready for service. m_fdCmd 29, m_fdAdmin 6.
2021-10-05 14:53:37.278573 [NOTICE] [817] [AutoRestarter] new child process with pid=848 is forked!
2021-10-05 14:53:37.279309 [NOTICE] [848] [*:80] Worker #1 activates SO_REUSEPORT #1 socket, fd: 22
2021-10-05 14:53:37.279352 [NOTICE] [848] [*:443] Worker #1 activates SO_REUSEPORT #1 socket, fd: 23
2021-10-05 14:53:37.279366 [NOTICE] [848] [UDP *:443] Worker #1 activates SO_REUSEPORT #1 socket, fd: 24
2021-10-05 14:53:37.279406 [INFO] [848] [UDP:0.0.0.0:443] initPacketsIn: allocated 100 packets
2021-10-05 14:53:37.279418 [INFO] [848] [UDP:0.0.0.0:7080] initPacketsIn: allocated 100 packets
2021-10-05 14:53:37.279605 [NOTICE] [848] AIO is not supported on this machine!
2021-10-05 14:53:37.279650 [NOTICE] [848] Successfully change current user to nobody
2021-10-05 14:53:37.279659 [NOTICE] [848] Core dump is enabled.
2021-10-05 14:53:37.279705 [INFO] [848] [union7914.655340]: locked pid file [/tmp/lshttpd/union7914.sock.pid].
2021-10-05 14:53:37.279729 [INFO] [848] [union7914.655340] remove unix socket for detached process: /tmp/lshttpd/union7914.sock
2021-10-05 14:53:37.279781 [NOTICE] [848] [LocalWorker::workerExec] VHost:unionelectronics.in suExec check uid 65534 gid 65534 setuidmode 0.
2021-10-05 14:53:37.279787 [NOTICE] [848] [LocalWorker::workerExec] Config[union7914.655340]: suExec uid 1002 gid 1002 cmd /usr/local/lsws/lsphp80/bin/lsphp, final uid 1002 gid 1002, flags: 0.
2021-10-05 14:53:37.299448 [NOTICE] [848] [union7914.655340] add child process pid: 850
2021-10-05 14:53:37.299497 [INFO] [848] [union7914.655340]: unlocked pid file [/tmp/lshttpd/union7914.sock.pid].
2021-10-05 14:53:37.299538 [INFO] [848] [wsgi:unionelectronics.in:/]: locked pid file [/tmp/lshttpd/unionelectronics.in:_.sock.pid].
2021-10-05 14:53:37.299541 [INFO] [848] [wsgi:unionelectronics.in:/] remove unix socket for detached process: /tmp/lshttpd/unionelectronics.in:_.sock
2021-10-05 14:53:37.306283 [NOTICE] [848] [LocalWorker::workerExec] VHost:unionelectronics.in suExec check uid 65534 gid 65534 setuidmode 0.
2021-10-05 14:53:37.306306 [NOTICE] [848] [LocalWorker::workerExec] Config[wsgi:unionelectronics.in:/]: suExec uid 65534 gid 65534 cmd /usr/local/lsws/fcgi-bin/lswsgi -m /home/company_website/companywebsiteproject/companywebsiteproject/wsgi.py, final uid 65534 gid 65534, flags: 0.
2021-10-05 14:53:37.314205 [NOTICE] [848] [wsgi:unionelectronics.in:/] add child process pid: 854
2021-10-05 14:53:37.314305 [INFO] [848] [wsgi:unionelectronics.in:/]: unlocked pid file [/tmp/lshttpd/unionelectronics.in:_.sock.pid].
2021-10-05 14:53:37.314358 [INFO] [848] [lsphp]: locked pid file [/tmp/lshttpd/lsphp.sock.pid].
2021-10-05 14:53:37.314362 [INFO] [848] [lsphp] remove unix socket for detached process: /tmp/lshttpd/lsphp.sock
2021-10-05 14:53:37.314425 [NOTICE] [848] [LocalWorker::workerExec] Config[lsphp]: suExec uid 65534 gid 65534 cmd /usr/local/lsws/lsphp73/bin/lsphp, final uid 65534 gid 65534, flags: 0.
2021-10-05 14:53:37.325014 [NOTICE] [848] [lsphp] add child process pid: 855
2021-10-05 14:53:37.325069 [INFO] [848] [lsphp]: unlocked pid file [/tmp/lshttpd/lsphp.sock.pid].
2021-10-05 14:53:37.325113 [NOTICE] [848] Setup swapping space...
2021-10-05 14:53:37.325224 [NOTICE] [848] LiteSpeed/1.7.14 Open
    module versions:
    modgzip 1.1
    cache 1.62
    modinspector 1.1
    uploadprogress 1.1
    mod_security 1.4
 starts successfully!

Update (08-10-2021) :

I deleted the my old droplet, created a new droplet and reinstalled the entire system.

I have added vHost Conf entry that I added. I have created a virtual environment company_website and have created companywebsiteproject Project inside the virtual enviroment.

docRoot                   $VH_ROOT/public_html
vhDomain                  $VH_NAME
vhAliases                 www.$VH_NAME
adminEmails               kpecengineers@gmail.com
enableGzip                1
enableIpGeo               1

index  {
  useServer               0
  indexFiles              index.php, index.html
}

errorlog $VH_ROOT/logs/$VH_NAME.error_log {
  useServer               0
  logLevel                ERROR
  rollingSize             10M
}

accesslog $VH_ROOT/logs/$VH_NAME.access_log {
  useServer               0
  logFormat               "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i""
  logHeaders              5
  rollingSize             10M
  keepDays                10  
  compressArchive         1
}

scripthandler  {
  add                     lsapi:union9108 php
}

extprocessor union9108 {
  type                    lsapi
  address                 UDS://tmp/lshttpd/union9108.sock
  maxConns                10
  env                     LSAPI_CHILDREN=10
  initTimeout             600
  retryTimeout            0
  persistConn             1
  pcKeepAliveTimeout      1
  respBuffer              0
  autoStart               1
  path                    /usr/local/lsws/lsphp80/bin/lsphp
  extUser                 union9108
  extGroup                union9108
  memSoftLimit            2047M
  memHardLimit            2047M
  procSoftLimit           400
  procHardLimit           500
}

phpIniOverride  {

}

rewrite  {
  enable                  1
  autoLoadHtaccess        1
}

context / {
  type                    App Server
  location                /home/unionelectronics.in/public_html/KPECproject/
  binPath                 /usr/local/lsws/fcgi-bin/lswsgi
  appType                 WSGI
  startupFile             KPECproject/wsgi.py
  env                     PYTHONPATH=/home/unionelectronics.in/public_html/bin/python3:/home/unionelectronics.in/public_html/KPECproject
  env                     LS_PYTHONBIN=/home/unionelectronics.in/public_html/bin/python3
}

When I go to http://Server_IP I get 404 error instead of earlier 503 error. When I go to http://unionelectronics.in/ I get 404 error instead of earlier 503 error.

Earlier I was getting error in error log now I am not getting any error.

I believe the issue is because of

index  {
  useServer               0
  indexFiles              index.php, index.html
}

How should I reroute to my home page?

If I remove index.html I get 404 error. If I keep index.html I am getting teh default cyberpanel data.

Dark Sorrow
  • 1,681
  • 14
  • 37
  • May I know if the default Django application works? If not, then it means there's something on the server that you need to fix. – Eric Oct 06 '21 at 00:23
  • @Eric, when I run my application using the run server command I can access my website over the internet however when I am using the above configuration i.e. cyberpanel with openlitespeed server the I am getting 503 error. When running on cyberpanel I cannot access any part of my django application even the Admin section. – Dark Sorrow Oct 06 '21 at 02:41
  • yes, I saw that. To test default Django is just to verify if your environment setup is correct. maybe this can help, please check https://openlitespeed.org/kb/python-wsgi-applications/#Set_up_Context-2 e.g. "Environment = PYTHONPATH=/var/www/html/lib/python3.8:/var/www/html/demo" please substitute the listed python version (python 3.8) with your current one, also the document root path. – Eric Oct 06 '21 at 03:08
  • @Eric From Website (management) -> Configurations -> vHost Conf I have added context I had added. I have updated my original post with this new information. – Dark Sorrow Oct 06 '21 at 07:43
  • Not PYTHONHOME=/home/company_website/ but PYTHONPATH=xxxxxxxxxxx:xxxxxx. Please check the env value again. And restart the lswsgi by "killall lswsgi" – Eric Oct 07 '21 at 07:22
  • @Eric I deleted the current instance and created new instance. Now instead of 503 error I am getting 404 error. I believe this is because of the index record in my conf file. How do I resolve this? I have attached my vHost Conf file – Dark Sorrow Oct 08 '21 at 06:55
  • Hi, I just set up a default Django site and it works correctly on CyberPanel, I mean both the default page and the admin page load as expected. I think it would be faster if you could join https://litespeedtech.com/slack/ and @eric me there so I can help you directly. – Eric Oct 08 '21 at 08:02

0 Answers0