Difference between revisions of "Drupal"
From Blue-IT.org Wiki
Line 283: | Line 283: | ||
[[Category:Drupal]] | [[Category:Drupal]] | ||
− | [[Category: | + | [[Category:Web Development]] |
Latest revision as of 20:21, 8 January 2012
{{#w4grb_rate:}}
Contents
Drupal 7 on Ubuntu Maverick / Debian Lenny
Structure configuration
Blocks
1. Alter the login block
Replace the default login block with a new menu-item called login which points to /user/login. This will also assure, that - if you are using the #Secure Pages module - you will get a https login.
It will only show up, if you are logged out.
Modules configuration
This section shows how to configure the individual modules.
IMCE
1. Thumnail size
To get thumbnails like in drupal default settings (these can be viewed under configuration->media->image styles) go to configuration->media->imce->profile of User-1 and alter the "Thumbnails" settings according to the following values:
Name | Dimensions | Präfix | Suffix |
---|---|---|---|
Small | 100x100 | _100x100 | |
Medium | 220x200 | _220x220 | |
Large | 480x480 | _480x480 |
2. Secure pages
To function properly with https please see #Secure Pages
Secure Pages
Go to admin->structure and alter the secure pages sites to
[...] admin admin/* imce imce/*
Postgresql Support
1. Prepare the php environment:
sudo apt-get install php5-pgsql
For lenny it might be necessary to use the php version from dotdeb.org. UPDATE: In squeeze this is not necessary an more, because it comes already with php 5.3.
2. Prepare PostgreSQL
See Postgres_SQL on Ubuntu as described.
3. Create user and database
Install a database and user as described in the INSTALL.pgsql.txt file of the Drupal Installation.
Be aware: Using a database schema is NOT advised, because it breaks the update functionality of drupal 7. Instead using a prefix is possible.
Be sure to use the following syntax:
sudo su su postgres -c "createuser --pwprompt --encrypted --no-createrole --no-createdb username" su postgres -c "createdb --encoding=UTF8 --owner=username databasename"
I created a script, with does the job quiet well. The --nocreateuser parameter is used, when you are accessing different databases with one (existing) account.
#!/bin/bash [ $UID -ne 0 ] && echo Have to be root. [ $UID -ne 0 ] && exit DATABASE="$1" DATABASEUSER="$2" CREATEUSER="$3" DBSCHEMA="$4" usage() { echo 'Have to add: DATABASENAME DATABASEUSER (--nocreateuser|--createuser) [SCHEMA]' echo 'DATABASENAME like: db_mysite_com' echo 'DATABASEUSER like: blue_it_org' echo 'Create a user or use an existing one:' echo ' --nocreateuser|--createuser' echo 'SCHEMA must be unique with an underscoe < _ > at the end:' echo ' www_mysite_com_ | subdomain_mysite_com_' exit } [ "$3" = "" ] && usage; db_schema_check() { if echo -n ${DBSCHEMA} | fgrep -q "." then echo "" echo "ERROR in SCHEMA-Name: < ${DBSCHEMA} >" echo "" echo " Using of character < . > (point) is not allowed in SCHEMA definition." echo " Use < _ > (underscore) instead" echo "" exit fi } create_user() { echo "Creating database user <${DATABASEUSER}>" if su postgres -c "createuser --pwprompt --encrypted --no-createrole --no-createdb ${DATABASEUSER}" then echo -n "" else echo "" echo "If the error was due to an existing user, try parameter --nocreateuser" exit fi } create_db() { echo "Creating database <${DATABASE}> owned by user <${DATABASEUSER}>" su postgres -c "createdb --encoding=UTF8 --owner=${DATABASEUSER} ${DATABASE}" || exit } create_schema() { echo "Creating database schema <${DBSCHEMA}>" su postgres -c "psql --dbname=${DATABASE} -c \"CREATE SCHEMA ${DBSCHEMA} AUTHORIZATION ${DATABASEUSER};\" "; } ####################################################### # MAIN ####################################################### [ "${DBSCHEMA}" = "" ] || db_schema_check; if [ "${CREATEUSER}" = "--createuser" ] then create_user; create_db; fi if [ "${CREATEUSER}" = "--nocreateuser" ] then create_db; fi if [ "${DBSCHEMA}" = "" ] then echo "NO database Schema will be created." else create_schema; fi
4. Edit the drupal configuration file as described in the INSTALL.txt like this Using prefix will result in tablenames with the assigned prefix. This is only necessary, if you are using the same database for more than one installation. If you use one database for one site, this is no problem.
[...] $databases['default']['default'] = array( 'driver' => 'pgsql', 'database' => 'db_name', 'username' => 'db_user_name', 'password' => 'db_pass', 'host' => 'localhost', 'prefix' => , ); $databases = array(); [...]
5. Edit an apache configuration file
<VirtualHost drupal7.localhost:80> NameVirtualHost drupal7.localhost DocumentRoot /path/to/drupal7/ <Directory "/path/to/drupal7/"> Options ExecCGI FollowSymLinks DirectoryIndex index.php AllowOverride None Order allow,deny Allow from all DefaultType application/x-httpd-php RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] </Directory> </VirtualHost>
6. Edit your /etc/hosts
sudo gedit /etc/hosts
[...] 127.0.0.1 localhost drupal7.localhost [...]
7. Start the installation within your webbrowser.
PHP
Uploadprogress and ACP
Thanks to joergfelser.at for this hint ...
If you are using Drupal 7 you will probably notice, that the system is not able to show an upload progress bar. You can fix this by installing the appropriate php modules and extensions:
apt-get install php5-dev php-apc mkdir -p /tmp/pear/cache # BUG #619307: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619307 pecl install uploadprogress vim /etc/php5/apache2/php.ini
Scroll to the End of the file and add
; Uploadprogress for Drupal 7 apc.rfc1867 = 1 extension=uploadprogress.so
Restart the webserver
service apache2 restart
If you like to keep your production system more secure, uninstall the following packages:
apt-get remove autoconf automake1.4 autotools-dev binutils cpp cpp-4.1 gcc gcc-4.1 libc6-dev libssl-dev libssp0 libtool linux-kernel-headers php5-dev shtool zlib1g-dev
Troubleshooting
Color module not working
File permissions has to be set to public !
Uploading files is not visible in the edit area
Check "content types" (german: Inhaltstypen) from the menu and activate the appropriate feature for the given content type (e.g. page, articel, blog, ...)
Contact form
* The contact form module has an entry in the "navigation" (!) menu which is NOT aktivated by default. Simply pput it e.g. into the secondary links.
PHP memory mimits
There are two ways to do this:
1. locally in your drupal installation
If error messages occur about memory limit when you try to install modules then edit sites/default/settings.php and add the following line:
ini_set('memory_limit', '24M');
This sets memory limit on a per site basis.
The other way is to edit serverwide (!) apache's /etc/php5/apache2/php.ini and customize the value there. Image processing needs - for drupal 6 - a minimal amount of 96M memory size!
memory_limit = 96M ; Maximum amount of memory a script may consume (16MB)
2. server wide in php.ini
You can also set the memory limit server wide in the php.ini file of your webserver.
You can find it in the /etc/php5/apache2 directory.
Not satisfied with Translation (.po files)
Edit the .po files for the translation and add them via the translation module.
You can also add the following module which filters active content:
Alter Strings
Go to Setting->Translation and click to the Search button.
Search for
@username's blog
and add your own translation.
Cron
On your sit enable cron
crontab -e -u www-data
and enter a line like (45 runs every hour)
# m h dom mon dow command 45 * * * * /usr/bin/lynx -source http://example.com/cron.php
or use wget to achieve the same:
0 * * * * wget -O - -q -t 1 http://www.example.com/cron.php