1

I apologized as I'm not well versed specifically with drupal. But anyway, I was migrating an existing installation on a Windows Server to a Linux Server (debian).

I went ahead and moved all the files, setup the database, updated settings.php in /sites/default

I also chown'd with correct user, and set /sites/default/files to 777 permissions with all other directories set to 755 and files set to 644.

I have errors with some images, css, and js. I checked the files, and they exist. When attempting to access via GET request (http protocol) I get 500 Internal Server error.

Looking at PHP's error logs I see these alerts (no errors):

/sites/default/files/.htaccess: Option FollowSymLinks not allowed here

When I edit said .htaccess files to:

#Options None
#Options +FollowSymLinks

The images load, but the CSS and JS does not (it exists but tries pulling from incorrect directory). I am also worried about security in this folder.

ie:

Actual Request: GET site.com/css/css_49249400b301b59bd86200648ba96215.css

Correct Request: GET site.com/sites/default/files/css/css_49249400b301b59bd86200648ba96215.css

Anything I could be doing wrong?

Help is appreciated!

UPDATE: Rewrites are enabled and working.

  • What is your configuration at admin/config/media/file-system? – cilefen Nov 12 '15 at 19:08
0

Did you have "Clean URLs" enabled on the Windows install? You may need mod_rewrite enabled in Apache (a2enmod rewrite)

I'm not sure how your server is configured (os/php version/etc), but I had a similar issue that required me to change the following in .htaccess

# RewriteBase /
to 
RewriteBase /

Another thing to check would be that overrides are allowed at all. Apache needs to be set to something like "AllowOverride All"

More info regarding AllowOverride:

How can I enable clean URLs?

How to enable Clean URLs?

Regarding permissions, there is a bunch of information available including a script that can help repair permissions (obviously use extreme caution when running and verify before you do.)

Source for the script below.

#!/bin/bash

# Help menu
print_help() {
cat <<-HELP
This script is used to fix permissions of a Drupal installation
you need to provide the following arguments:

  1) Path to your Drupal installation.
  2) Username of the user that you want to give files/directories ownership.
  3) HTTPD group name (defaults to www-data for Apache).

Usage: (sudo) bash ${0##*/} --drupal_path=PATH --drupal_user=USER --httpd_group=GROUP
Example: (sudo) bash ${0##*/} --drupal_path=/usr/local/apache2/htdocs --drupal_user=john --httpd_group=www-data
HELP
exit 0
}

if [ $(id -u) != 0 ]; then
  printf "**************************************\n"
  printf "* Error: You must run this with sudo or root*\n"
  printf "**************************************\n"
  print_help
  exit 1
fi

drupal_path=${1%/}
drupal_user=${2}
httpd_group="${3:-www-data}"

# Parse Command Line Arguments
while [ "$#" -gt 0 ]; do
  case "$1" in
    --drupal_path=*)
        drupal_path="${1#*=}"
        ;;
    --drupal_user=*)
        drupal_user="${1#*=}"
        ;;
    --httpd_group=*)
        httpd_group="${1#*=}"
        ;;
    --help) print_help;;
    *)
      printf "***********************************************************\n"
      printf "* Error: Invalid argument, run --help for valid arguments. *\n"
      printf "***********************************************************\n"
      exit 1
  esac
  shift
done

if [ -z "${drupal_path}" ] || [ ! -d "${drupal_path}/sites" ] || [ ! -f "${drupal_path}/core/modules/system/system.module" ] && [ ! -f "${drupal_path}/modules/system/system.module" ]; then
  printf "*********************************************\n"
  printf "* Error: Please provide a valid Drupal path. *\n"
  printf "*********************************************\n"
  print_help
  exit 1
fi

if [ -z "${drupal_user}" ] || [[ $(id -un "${drupal_user}" 2> /dev/null) != "${drupal_user}" ]]; then
  printf "*************************************\n"
  printf "* Error: Please provide a valid user. *\n"
  printf "*************************************\n"
  print_help
  exit 1
fi

cd $drupal_path
printf "Changing ownership of all contents of "${drupal_path}":\n user => "${drupal_user}" \t group => "${httpd_group}"\n"
chown -R ${drupal_user}:${httpd_group} .

printf "Changing permissions of all directories inside "${drupal_path}" to "rwxr-x---"...\n"
find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;

printf "Changing permissions of all files inside "${drupal_path}" to "rw-r-----"...\n"
find . -type f -exec chmod u=rw,g=r,o= '{}' \;

printf "Changing permissions of "files" directories in "${drupal_path}/sites" to "rwxrwx---"...\n"
cd sites
find . -type d -name files -exec chmod ug=rwx,o= '{}' \;

printf "Changing permissions of all files inside all "files" directories in "${drupal_path}/sites" to "rw-rw----"...\n"
printf "Changing permissions of all directories inside all "files" directories in "${drupal_path}/sites" to "rwxrwx---"...\n"
for x in ./*/files; do
  find ${x} -type d -exec chmod ug=rwx,o= '{}' \;
  find ${x} -type f -exec chmod ug=rw,o= '{}' \;
done
echo "Done setting proper permissions on files and directories"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.