John Davidson

amazon ec2 - Hosting PHP application on Centos 7 (AWS EC2)

0 comments
Message:


I am trying to setup an existing PHP application. Moved form an external host onto AWS, it's on an EC2 instance with Centos 7.


The folder structure provided by the current host looks like this:


I can FTP and SSH into the EC2 instance. But where should I put this folder and what setup is required to point the website to the folder?


EC2 from FTP:



My Answer:
To host your PHP application on an AWS EC2 instance with CentOS 7, you can follow these steps:

1. Connect to your EC2 instance via SSH and navigate to the web server root directory. In CentOS 7, the default web server root directory is `/var/www/html/`.

2. Upload your PHP application folder to the web server root directory using FTP or SCP.

3. Once the folder is uploaded, you may need to adjust the file permissions to ensure that the web server (usually Apache) can access and serve the files. You can do this by running the following command in the terminal:


sudo chown -R apache:apache /var/www/html/your_application_folder


Replace `/var/www/html/your_application_folder` with the actual path to your PHP application folder.

4. Next, you will need to configure the virtual host settings for your PHP application. Create a new virtual host configuration file in the `/etc/httpd/conf.d/` directory. You can use the following command to create a new configuration file:


sudo nano /etc/httpd/conf.d/your_application.conf


Add the following configuration to the file, replacing `your_application_folder` with the actual path to your PHP application folder:



ServerName your_domain.com
DocumentRoot /var/www/html/your_application_folder

AllowOverride All
Require all granted




Save the file and exit the text editor.

5. Restart the Apache web server to apply the changes:


sudo systemctl restart httpd


6. Finally, update the DNS settings for your domain to point to the public IP address of your EC2 instance. Once the DNS changes have propagated, you should be able to access your PHP application by visiting your domain in a web browser.

That's it! Your PHP application should now be successfully hosted on your AWS EC2 instance with CentOS 7.

Rate this post

3 of 5 based on 9465 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us