404 not found after deploying laravel 5.3 into AWS EC2 server - amazon-web-services

I deployed (actually cloned from git my site, previously developed on local server) into AWS EC2 instance. I did the necessary things like composer updating, .env file etc. But still it is showing 404 error when I try to visit my site --
{my-public-ip}/{my-site}/public/
what am I missing here?

I ran sudo a2enmod rewrite and for some unknown reason, it worked. Strange! No idea what or how this happened

Related

Server Error (500) Django App on AWS server

Good day,
i have currently my django project running on an aws server. I have used Nginx and configured it all. The application is running, but when i try to login via the login page i have created or try to login via the admin panel it gives me a Server Error (500). I have my DEBUG=False and added my server dns to ALLOWED_HOSTS. As for the Database. I have got my SQL Database running on an Azure server and used environment variables (that i have permanently set in my ubuntu terminal) to get my password and username.
I have also tried to set DEBUG to False and trying to figure out the issue when running python manage.py runserver so i could experiment with it on my localhost, but no luck. I cant access 127.0.0.1 eventhough i have added it to my Allowed hosts.
How could i see what the error is? Thank you in advance
Ok, so fixed it!
After each change, you simply run the command sudo supervisorctl reload in your powershell after you ssh'ed into your aws ec2 server.
As for seeing what the error is, simply set DEBUG=True

Not able to deploy Django app on AWS Lightsail using Apache server based on provided tutorial

I followed the tutorial (https://aws.amazon.com/getting-started/hands-on/deploy-python-application/) on deploying Django website in AWS Lightsail. When I use the
python3 manage.py runserver 0.0.0.0:8000
to deploy the website then it works perfectly and I can access the website at http://AWS.INSTANCE.PUBLIC.IP.ADDRESS:8000
However, if I follow the Host the application using Apache part of the same tutorial, I am getting the following error when I try to access http://AWS.INSTANCE.PUBLIC.IP.ADDRESS:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator at you#example.com to inform
them of the time this error occurred, and the actions you performed
just before this error.
More information about this error may be available in the server error
log.
How to successfully deploy the Django website/app using Apache on AWS Lightsail instance?
I was able to run Django on lightsail by following the tutorial.
Make sure all paths in bitnami.conf file is correctly configured. Also, you need to retain the below part.
# Let Apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto https HTTPS=on
This is the part where the tutorial asks to delete but don't delete this part. Below this part, should start.
If you were able to put up the correct paths, you should be able to run Django application on LightSail.
However, there is a bigger problem later on when you try to get HTTPS on lightsail instance;;;

Django API works locally but not when deployed on Elastic Beanstalk

I'm working with Django Rest Framework and Django Rest Framework JWT, but I'm running into an issue in regards to local behavior vs external behavior.
When I make a POST request to get a JWT token, everything works as desired both locally and on my EC2 instance. However, once I have the token, when I make a request to my server that requires authentication, only my local server returns the expected response. On my deployed server, I get the following error:
{"detail":"Authentication credentials were not provided."}
What I've tried so far:
Editing http.conf by sshing into my server and enabling WSGIPathAuthorization. (saw a similar post here and tried the solution)
What could be causing this behavior? My local machine and my deployed code are identical, leading me to believe that this has something to do with server-side configuration.
All help is appreciated. Thanks!
You mentioned ElasticBeanstalk.
You can add this to your container commands which will be executed during deployment.
01_wsgipass:
command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'
Simply restarting Apache after enabling WSGPPathAuthorization fixed my error. For those of you who encounter something similar, here's what I did:
SSH into the server
Navigate to where your http.conf file is stored (in Apache, this is usually
etc/httpd/http.conf)
Edit http.conf, adding WSGIPathAuthorization On.
Restart Apache by running sudo service httpd restart.
This problem usually occurs when you do configure wsgi with apache on EC2 instance.
Bascially its the problem in apache configuration,
it has nothing to do with AWS EC2.
As apache bydefault do not process Authorization headers, so in order to make that happen we need to configure its files.
For ubuntu
cd /etc/apache2/apache2.conf
paste the following line
WSGIPassAuthorization On

Unable to setup Django in production on EC2 instance running Ubuntu 14.04

I have set up an EC2 instance with Ubuntu and able to login via ssh.
Now I have installed Apache, MySQL (worked fine) and Django also tried to configure it to run with apache. I have tried doing so with mod-wsgi but it still shows a apache default page instead of django (Congratulation ! It works) page. Can someone please provide me instructions for how to setup all this after login into EC2 via SSH.
Here is a tutorial provided by Django.
You need to make sure the apache config file is in /etc/apache2/sites-enabled/ or wherever your apache configuration files rest.
Another silly problem and this might be your issue is whenever I start a new instance of EC2 there is always a config called "000-default" already in the apache sites-enabled. This needs to be DELETED or DISABLED for apache to read from your config instead.
Hopefully this helps!
For a example check the Step 2 of this link. yum + git + pip + python requirements

Deploying django project on AWS elastic beanstalk

I am following the tutorial for deploying a django project on AWS elastic beanstalk here:
http://docs.amazonwebservices.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html
My app works when I test locally but when I deploy, I'm getting a 404 error. Looking at the event logs, I see this message:
Error running user's commands : An error occurred running '. /opt/python/ondeck/env && PYTHONPATH=/opt/python/ondeck/app: django-admin.py syncdb --noinput' (rc: 127) /bin/sh: django-admin.py: command not found
That leads me to believe that the tutorial is missing a part about installing django files on the server or at least configuring my project to recognize django-admin.py. I have django installed on my local machine so it works there.
I know python support is brand new for elastic beanstalk but has anyone deployed django to it?
I believe you don't need to put container_commands in .config because there is no database or table at this moment.
Did you made the step?: Freeze the requirements.txt file.
(djangodev)# pip freeze > requirements.txt
Note
Make sure your requirements.txt file contains the following:
Django==1.4.1
MySQL-python==1.2.3
I had the same problem because I skipped it. Once I did it, add, commit and push. It works!
I followed the same tutorial recently and had a similar result.
At step 6, upon seeing the default django 'congrats' page render locally, I deployed to EB as instructed and got a 404 instead of the default 'congrats' page.
I decided to use the code up to that point as a foundation for following the 'getting started with django tutorial' which led me to a successful rendering of a 'home' view. This is a much more useful place to be anyway. I do agree that there is something wrong with the AWS tutorial and posted to the AWS forums here.
If you can, you should try to access the log file; it might give you a better idea of what's going on. Here's a link that might help:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.loggingS3.title.html