403 Permission Denied After Modifying Permissions in Magento 1.8

magento-1.8

Hoping someone can help me. I run version 1.8.1 of Magento Community on a VPS running Debian 7.4, PHP 5.4.4 and MySQL 5.3.35. I have used this page as my reference to know what permissions I should be setting. http://www.magentocommerce.com/knowledge-base/entry/install-privs-after

I created 2 scripts on my VPS, one to set permissions to allow extensions and other changes and one to set them to the recommended as per the above link. The scripts are below. The one to secure my installation works great. The issue is the unsecure one is not working right. It was working last week, but for some reason, something has changed and it no longer does.

When I run the unsecure script, I get 403 Permission Denied errors on ALL pages which I don't understand. Can anyone help me with where I am going wrong? The above link said 600/700 for the permissions which I tried originally, and then swapped to 677/777. I also added chown -R www-data . just in case, but that didn't do anything either.

SECURE

#!/bin/bash

clear

echo "Setting File Permissions."

find . -type f -exec chmod 400 {} \;

echo "Setting Directory Permissions."

find . -type d -exec chmod 500 {} \;

echo "Setting /var File Permissions."

find var/ -type f -exec chmod 600 {} \;

echo "Setting /media File Permissions."

find media/ -type f -exec chmod 600 {} \;

echo "Setting /var Directory Permissions."

find var/ -type d -exec chmod 700 {} \;

echo "Setting /media Directory Permissions."

find media/ -type d -exec chmod 700 {} \;

echo "CHOWNing files and folders to www-data"

chown -R www-data .

echo "Operation Complete."

UNSECURE

#!/bin/bash

clear

echo "Setting File Permissions."

find . -type f -exec chmod 777 {} \;

echo "Setting Directory Permissions."

find . -type d -exec chmod 677 {} \;

echo "Operation Complete."

Best Answer

The directory permission being 677 seems to be the problem here. I would go with 755:

#!/bin/bash

clear

echo "Setting File Permissions."

find . -type f -exec chmod 777 {} \;

echo "Setting Directory Permissions."

find . -type d -exec chmod 755 {} \;

echo "Operation Complete."