Difference between revisions of "Drupal"

From SME Server
Jump to navigationJump to search
m (Please do not use extensive spaces, one space indents are enough and cause text to be preformatted)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Installing Drupal 7 on SME Server 8 ==
 
 
{{Level|medium}}
 
{{Level|medium}}
  
This guide shows you how to correctly install Drupal ( http://www.drupal.org ) into your Primary ibay.
+
This guide shows you how to correctly install Drupal ( http://www.drupal.org ) into your Primary ibay on SME Server 8.
  
 
=== Setting up PHP to work correctly for Drupal ===
 
=== Setting up PHP to work correctly for Drupal ===
Line 17: Line 16:
 
=== Setting up the overrides for Apache ===
 
=== Setting up the overrides for Apache ===
  
    db accounts setprop Primary AllowOverride all
+
db accounts setprop Primary AllowOverride all
    db accounts setprop Primary FollowSymLinks enabled
+
db accounts setprop Primary FollowSymLinks enabled
    db accounts setprop Primary Indexes disabled
+
db accounts setprop Primary Indexes disabled
    signal-event ibay-modify Primary
+
signal-event ibay-modify Primary
  
 
=== Setting up ftp ===
 
=== Setting up ftp ===
Line 27: Line 26:
  
 
* Create a user from the user panel and reset their password
 
* Create a user from the user panel and reset their password
* Enable ftp from local networks
+
* Enable ftp from local networks (I only allow administration of websites from the local network as a matter of security principle!)
* Give the user you just created the correct access permissions
+
* Give the user you just created the correct access permissions using the fix_permissions.sh script from http://drupal.org/node/244924 (Note: the contents of this file is at the bottom of this page)
  
 
For example, say you created a user called '''fred''', then in order for '''fred''' to be able to ftp the required files via the Drupal interface, then you give them permission to do so like this:
 
For example, say you created a user called '''fred''', then in order for '''fred''' to be able to ftp the required files via the Drupal interface, then you give them permission to do so like this:
  
    cd /home/e-smith/files/ibays/Primary/html/
+
bash fix-permissions.sh /home/e-smith/files/ibays/Primary/html fred
    chown -R fred:www .
 
    find . -type d -exec chmod u=rwx,g=rx,o= {} \;
 
    find . -type f -exec chmod u=rw,g=r,o= {} \;
 
  
 
Where '''fred''' is the user account you will use in Drupal to ftp the files (for example installing a new theme) and www is the account that smesever runs the web server under.
 
Where '''fred''' is the user account you will use in Drupal to ftp the files (for example installing a new theme) and www is the account that smesever runs the web server under.
Line 41: Line 37:
 
Lastly you have to modify the /etc/proftpd.conf file and comment out the "DefaultRoot" line ( I used the nano editor for this ):
 
Lastly you have to modify the /etc/proftpd.conf file and comment out the "DefaultRoot" line ( I used the nano editor for this ):
  
    cp /etc/e-smith/templates/etc/proftpd.conf/05DefaultRoot /etc/e-smith/templates-custom/etc/proftpd.conf/
+
cp /etc/e-smith/templates/etc/proftpd.conf/05DefaultRoot /etc/e-smith/templates-custom/etc/proftpd.conf/
    nano /etc/e-smith/templates-custom/etc/proftpd.conf/05DefaultRoot
+
nano /etc/e-smith/templates-custom/etc/proftpd.conf/05DefaultRoot
  
 
Comment out the DefaultRoot like:
 
Comment out the DefaultRoot like:
  
    #DefaultRoot            /home/e-smith/files
+
#DefaultRoot            /home/e-smith/files
  
Now save the file by going pressing the '''control''' and '''o''' keys together, then exit nano by pressing the '''control''' and the '''x''' keys together.
+
Now save the file by pressing the '''control''' and '''o''' keys together, then exit nano by pressing the '''control''' and the '''x''' keys together.
  
 
Then you need to expand the template:
 
Then you need to expand the template:
  
    expand-template /etc/proftpd.conf
+
expand-template /etc/proftpd.conf
  
 
To confim this:
 
To confim this:
  
    config show ftp
+
config show ftp
  
 
Should return:
 
Should return:
  
    ftp=service
+
ftp=service
 
     LoginAccess=private
 
     LoginAccess=private
 
     TCPPort=21
 
     TCPPort=21
Line 73: Line 69:
 
This has been tested on 8Beta6 and the 8Beta7 release.
 
This has been tested on 8Beta6 and the 8Beta7 release.
  
 +
Note: You may need to delete the index.htm file in your Primary ibay so that Drupal's index.php file is picked up.
  
 
As a footnote, I would recommend only enabling ftp via the server-manager panel just when you need it so that it is not turned on all the time!
 
As a footnote, I would recommend only enabling ftp via the server-manager panel just when you need it so that it is not turned on all the time!
 +
 +
----
 +
 +
For your convenience, I have reproduced the contents of fix_permissions.sh:
 +
 +
#!/bin/bash
 +
 +
path=${1%/}
 +
user=${2}
 +
group="www"
 +
help="\nHelp: This script is used to fix permissions of a drupal installation\nyou need to provide the following arguments:\n\t 1) Path to your drupal installation\n\t 2)
 +
Username o$
 +
want to give files/directories ownership\nNote: \"www-data\" (apache default) is assumed as the group the server is belonging to, if this is different you need to modify it
 +
manually$
 +
script\n\nUsage: (sudo) bash ${0##*/} drupal_path user_name\n"
 +
 +
if [ -z "${path}" ] || [ ! -d "${path}/sites" ] || [ ! -f "${path}/modules/system/system.module" ]; then
 +
        echo "Please provide a valid drupal path"
 +
        echo -e $help
 +
        exit
 +
fi
 +
 +
if [ -z "${user}" ] || [ "`id -un ${user} 2> /dev/null`" != "${user}" ]; then
 +
        echo "Please provide a valid user"
 +
        echo -e $help
 +
        exit
 +
fi
 +
 +
cd $path;
 +
 +
echo -e "Changing ownership of all contents of \"${path}\" :\n user => \"${user}\" \t group => \"${group}\"\n"
 +
chown -R ${user}:${group} .
 +
echo "Changing permissions of all directories inside \"${path}\" to \"750\"..."
 +
find . -type d -exec chmod u=rwx,g=rx,o= {} \;
 +
echo -e "Changing permissions of all files inside \"${path}\" to \"640\"...\n"
 +
find . -type f -exec chmod u=rw,g=r,o= {} \;
 +
 +
cd $path/sites;
 +
 +
echo "Changing permissions of \"files\" directories in \"${path}/sites\" to \"770\"..."
 +
find . -type d -name files -exec chmod ug=rwx,o= '{}' \;
 +
echo "Changing permissions of all files inside all \"files\" directories in \"${path}/sites\" to \"660\"..."
 +
find . -name files -type d -exec find '{}' -type f \; | while read FILE; do chmod ug=rw,o= "$FILE"; done
 +
echo "Changing permissions of all directories inside all \"files\" directories in \"${path}/sites\" to \"770\"..."
 +
find . -name files -type d -exec find '{}' -type d \; | while read DIR; do chmod ug=rwx,o= "$DIR"; done
 +
 
----
 
----
 
[[Category: Howto]]
 
[[Category: Howto]]
 
[[Category: CMS]]
 
[[Category: CMS]]
 
[[Category: Webapps]]
 
[[Category: Webapps]]

Latest revision as of 07:07, 3 February 2012

PythonIcon.png Skill level: medium
The instructions on this page require a basic knowledge of linux.


This guide shows you how to correctly install Drupal ( http://www.drupal.org ) into your Primary ibay on SME Server 8.

Setting up PHP to work correctly for Drupal

db accounts setprop Primary PHPBaseDir /home/e-smith/files/ibays/Primary:/tmp
signal-event ibay-modify Primary
db configuration setprop php MemoryLimit 128M
db configuration setprop php PostMaxSize 112M
db configuration setprop php UploadMaxFilesize 96M
expand-template /etc/php.ini 
sv t httpd-e-smith

Setting up the overrides for Apache

db accounts setprop Primary AllowOverride all
db accounts setprop Primary FollowSymLinks enabled
db accounts setprop Primary Indexes disabled
signal-event ibay-modify Primary

Setting up ftp

In order to be able to ftp new themes and modules to your Drupal installation, you need to go to the server-manager panel in smeserver and:

  • Create a user from the user panel and reset their password
  • Enable ftp from local networks (I only allow administration of websites from the local network as a matter of security principle!)
  • Give the user you just created the correct access permissions using the fix_permissions.sh script from http://drupal.org/node/244924 (Note: the contents of this file is at the bottom of this page)

For example, say you created a user called fred, then in order for fred to be able to ftp the required files via the Drupal interface, then you give them permission to do so like this:

bash fix-permissions.sh /home/e-smith/files/ibays/Primary/html fred

Where fred is the user account you will use in Drupal to ftp the files (for example installing a new theme) and www is the account that smesever runs the web server under.

Lastly you have to modify the /etc/proftpd.conf file and comment out the "DefaultRoot" line ( I used the nano editor for this ):

cp /etc/e-smith/templates/etc/proftpd.conf/05DefaultRoot /etc/e-smith/templates-custom/etc/proftpd.conf/
nano /etc/e-smith/templates-custom/etc/proftpd.conf/05DefaultRoot

Comment out the DefaultRoot like:

#DefaultRoot            /home/e-smith/files

Now save the file by pressing the control and o keys together, then exit nano by pressing the control and the x keys together.

Then you need to expand the template:

expand-template /etc/proftpd.conf

To confim this:

config show ftp

Should return:

ftp=service
   LoginAccess=private
   TCPPort=21
   access=private
   status=enabled

Finally, you are ready to follow the install instructions for Drupal

Now SME Server is all set up ready for you to follow the Drupal installation guide at: http://drupal.org/documentation/install


This has been tested on 8Beta6 and the 8Beta7 release.

Note: You may need to delete the index.htm file in your Primary ibay so that Drupal's index.php file is picked up.

As a footnote, I would recommend only enabling ftp via the server-manager panel just when you need it so that it is not turned on all the time!


For your convenience, I have reproduced the contents of fix_permissions.sh:

#!/bin/bash

path=${1%/}
user=${2}
group="www"
help="\nHelp: This script is used to fix permissions of a drupal installation\nyou need to provide the following arguments:\n\t 1) Path to your drupal installation\n\t 2)
Username o$
want to give files/directories ownership\nNote: \"www-data\" (apache default) is assumed as the group the server is belonging to, if this is different you need to modify it
manually$
script\n\nUsage: (sudo) bash ${0##*/} drupal_path user_name\n"

if [ -z "${path}" ] || [ ! -d "${path}/sites" ] || [ ! -f "${path}/modules/system/system.module" ]; then
        echo "Please provide a valid drupal path"
        echo -e $help
        exit
fi

if [ -z "${user}" ] || [ "`id -un ${user} 2> /dev/null`" != "${user}" ]; then
        echo "Please provide a valid user"
        echo -e $help
        exit
fi

cd $path;

echo -e "Changing ownership of all contents of \"${path}\" :\n user => \"${user}\" \t group => \"${group}\"\n"
chown -R ${user}:${group} .
echo "Changing permissions of all directories inside \"${path}\" to \"750\"..."
find . -type d -exec chmod u=rwx,g=rx,o= {} \;
echo -e "Changing permissions of all files inside \"${path}\" to \"640\"...\n"
find . -type f -exec chmod u=rw,g=r,o= {} \;

cd $path/sites;

echo "Changing permissions of \"files\" directories in \"${path}/sites\" to \"770\"..."
find . -type d -name files -exec chmod ug=rwx,o= '{}' \;
echo "Changing permissions of all files inside all \"files\" directories in \"${path}/sites\" to \"660\"..."
find . -name files -type d -exec find '{}' -type f \; | while read FILE; do chmod ug=rw,o= "$FILE"; done
echo "Changing permissions of all directories inside all \"files\" directories in \"${path}/sites\" to \"770\"..."
find . -name files -type d -exec find '{}' -type d \; | while read DIR; do chmod ug=rwx,o= "$DIR"; done