Step-by-Step Guide
Connect to Your EC2 Instance via SSH
Connect to your EC2 instance using SSH. Replace /path/to/your-key.pem with the path to your SSH key, and your-ec2-instance-public-dns with the public DNS of your EC2 instance.
ssh -i /path/to/your-key.pem ubuntu@your-ec2-instance-public-dns
Navigate to Your Laravel Project Directory
Change to the directory where your Laravel project is located.
cd /var/www/html/your-laravel-project
Set Correct Ownership
Ensure that the public directory is owned by the web server user (www-data for Apache on Ubuntu).
sudo chown -R www-data:www-data public
Set Correct Permissions
Adjust the permissions to allow the web server to read and execute files in the public directory.
sudo chmod -R 755 public
Example Commands to Execute
# Connect to your EC2 instance
ssh -i /path/to/your-key.pem ubuntu@your-ec2-instance-public-dns
# Navigate to your project directory
cd /var/www/html/your-laravel-project
# Set correct ownership to www-data
sudo chown -R www-data:www-data public
# Set permissions to 755
sudo chmod -R 755 public
Verify Permissions
To verify the permissions, you can use the ls -ld command:
ls -ld public
The output should look something like this:
drwxr-xr-x 10 www-data www-data 4096 Jun 7 10:00 public
This indicates that the public directory has the correct permissions and is owned by www-data.
0 More Answers