Hosting a django-rest api on hostinger

37 views Asked by At

I have a project which uses django as a backend, I wish to deploy it on hostinger, anyone has already done this before? I searched alot and didn't find much help, if someone already knows, please write me the steps to successfully deploy the django backend app to hostinger

I searched alot and didn't find someone who did this before

1

There are 1 answers

0
Manoj Kamble On

You can use Hostinger's VPS Plan.

After purchasing the VPS plan they will provide you the IP address of their VPS server then log in to the server using SSH.

After login to the VPS server, you can deploy your Django Application with Apache or any other web application.

For making these changes you will need a user with sudo permissions. Make a file in /etc/apache2/sites-available directory as domain.conf.

Below is an example of Apache file (domain.conf) configuration:

<VirtualHost *:80>
        DocumentRoot /var/www/
        ServerName domain.com
        ServerAlias www.domain.com
   

        ServerAdmin [email protected]
                ServerName domain.com
                DocumentRoot /var/www/html
                Alias /static /home/user_name/path_to_project_static_file
                        <Directory /home/user_name/path_to_project_static_file>
                                Require all granted
                        </Directory>


                Alias /media /home/user_name/path_to_project_media_file
                        <Directory /home/user_name/path_to_project_media_file>
                               Require all granted
                        </Directory>

                <Directory /home/user_name/project_path/project_name/wsgi.py>
                        <Files wsgi.py>
                                Require all granted
                        </Files>
                        </Directory>


                WSGIDaemonProcess process_group_name python-home=path_to_environment python-path=project_path
                WSGIProcessGroup process_group_name
                WSGIScriptAlias / /home/user_name/project_path/project_name/wsgi.py


            

                ErrorLog ${APACHE_LOG_DIR}/domain_error.log
                CustomLog ${APACHE_LOG_DIR}/domain_access.log combined
</VirtualHost>

Consider making appropriate changes.

After making these changes restart your Apache service by sudo service apache2 restart.