Deployment script to apache, permissions problem - django

I'm developing a Django application that is being deployed to an apache server.
I'm using two servers right now. In one server I have the Development and Staging instances for which I use a bash shell script to deploy, and in the other server the Production instance in which I use a mina-deploy script.
The problem comes after deploying since the permissions on the /var/www/... folder are not correct after the deployment, this wont allow apache to serve the website.
I was wondering if there is anyway I can deploy this code without making any change to permissions. For both I'm not using a root user but an user with SUDO permissions.

Related

What is the best option to deploy Next.js and Strapi projects to AWS?

Please understand that I am using a translator because I can't speak English.
I want to use Strapi to configure API Server, receive APIs using Nextjs, and create a website that expresses news articles.
News articles are registered daily using the Strapi management panel, and Nextjs should reflect them in real time.
Next.js will also include the ability for users to register, modify, and delete posts. (Board)
Also, in the Expo React Native App, data must be received from Strapi to the API and displayed.
Cloud services must use AWS.
In addition, after development in the local development environment, it must be reviewed by the customer at the test server and updated to the production environment after that.
Therefore, I think we need at least two management servers.
S3 and RDS should also be used.
It's not a very large site.
There are not many users yet.
If I need a docker, I will use it.
Frontend(Next.js)
Amplify
Docker -> App Runner
Docker -> Fargate
EC2
Backend(Strapi)
Amplify
Docker -> App Runner
Docker -> Fargate
EC2
Help me Please!

Can Amazon Chime be deployed and run on a third-party VPS? And how?

In the examples of Amazon Chime, for instance here https://github.com/aws-samples/amazon-chime-sdk-classroom-demo, they imply that it should be deployed and run on a AWS server via Cloud9. However, I want to deploy and run it on some other VPS such as a digitalocean or linode server.
The main question: can that be done at all, it is supported?
If yes, how? General pointers. Which example should I use and where is it described at all?
Eventually what I want is this:
Say, I have a teaching website that I run on digital ocean or linode. Not on AWS. I want to be able to use Amazon Chime in a way that my users will go to my website and connect to a video class from my website as well
The Chime service would need run on AWS, but you can have a link to the Chime service endpoint from any website hosted anywhere else.
To use the Amazon Chime web application, your students would sign in to https://app.chime.aws/ from your web browser. You would have that link on your website.
See https://docs.aws.amazon.com/chime/latest/ug/chime-web-app.html
Note about the demo. The demo shows how to use the Amazon Chime SDK to build an online classroom in Electron and React. If you are are using that deployment method you can host the React app anywhere under a private domain on any host. That app will run any where, while connecting back to the AWS service endpoint.
Resources would be deployed in AWS. No way around it.
Deployment script can be run from your own laptop, Cloud9 and/or any other Linux server. You just need to be able to run git clone and script/deploy.js.
You'll also need to make that environment is configured with appropriate AWS credentials. Cloud9 would have these credentials out of the box. For any other environment (your laptop/Digital Ocean VM etc.) would need to get AWS Account Ket/Secret pair and use aws config to enable them.

How to autodeploy Django in EC2 and React in S3

I have an app created in Django and React, but there are few problems that I am facing :-
As I will have a large database(postgres) exclusily for a single user, I am creating different AWS EC2 instance for every user.
Whenever there is a new user then I have to go and manually install postgres, setup nginx and other important things and this is just for Django in EC2. Then I setup ReactJS frontend in Amazon S3.
How can i automate this so that when a paid user signs up, everything happens automatically.
The following should happen automatically:
- Automatically create a new EC2 instance, and deploy backend (This including installing several libraries, Postgres, Redis, async task queue (We use Huey which is like Celery), making migrations and other trivial stuff)
- Automatically make an S3 bucket and deploy frontend for the user. We will have to setup domains .etc for this.
Would like to know your inputs on how to approach this problem.

Launching an EC-2 Instance for S3 Bucket

I'm new to web dev and created a site using an S3 bucket that works and is live online. However, I realized that since I'm trying to run a PHP script I found online for a contact form, the site is not truly static so the form will not work. The form is called like this in the html code:
<form name="htmlform" method="post" action="html_form_send.php">
Currently when I try to run this, I get a 405 method not allowed error. Is there a way I can get this code to run? I've done some research online that mentions I have to create an EC2 instance, but I'm overwhelmed by which AMI to choose and don't know how to get the instance connected to the bucket. Can anyone help, or at least does anyone have a resource I could look at to figure this out? Thanks!
The easiest way to deploy your PHP app in AWS is using Elastic Beanstalk.
Elastic Beanstalk for PHP makes it easy to deploy, manage, and scale
your PHP web applications using Amazon Web Services. Elastic Beanstalk
for PHP is available to anyone developing or hosting a web application
using PHP.
Elastic Beanstalk provides configuration options that you can use to
customize the software that runs on the EC2 instances in your Elastic
Beanstalk environment. You can configure environment variables needed
by your application, enable log rotation to Amazon S3, and set common
PHP initialization settings.
Reference: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP_eb.html

Can I deploy automatically to AWS ElasticBeanstalk? SSH or so?

I have a simple PHP application, which doesn't use any database, or anything else. I have a script, which asks me for version name and than creates ZIP with the site and upload via the web interface.
Can I upload to ElasticBeanstalk via let's say SSH?
Yes, with the Elastic Beanstalk Configuration Files.