Difference between revisions of "Drupal"

From ArchWiki
Jump to: navigation, search
(Installation: use the apache configuration file included with the package)
Line 14: Line 14:
*Uncomment the {{ic|<nowiki>extension=gd.so</nowiki>}} line.
*Uncomment the {{ic|<nowiki>extension=gd.so</nowiki>}} line.
*Enable a PDO extension for your database. For MySQL, the line {{ic|<nowiki>extension=pdo_mysql.so</nowiki>}} should be uncommented.
*Enable a PDO extension for your database. For MySQL, the line {{ic|<nowiki>extension=pdo_mysql.so</nowiki>}} should be uncommented.
*Find the line beginning with {{ic|<nowiki>open_basedir =</nowiki>}}. Add the Drupal install directories, {{ic|/usr/share/webapps/drupal/}} and {{ic|/var/lib/drupal/}}. {{ic|/srv/http/}} can be removed if you do not intend to use it.
Edit {{ic|/etc/httpd/conf/httpd.conf}}:
Copy the example Apache configuration file:
*Uncomment the {{ic|LoadModule rewrite_module modules/mod_rewrite.so}} line.
# cp /etc/webapps/drupal/apache.example.conf /etc/httpd/conf/extra/drupal.conf
*If your webserver is dedicated to Drupal, find the line {{ic|DocumentRoot "/srv/http"}} and change it to the Drupal install directory, i.e. {{ic|DocumentRoot "/usr/share/webapps/drupal"}}, then find the section that starts with {{ic|&lt;Directory "/srv/http"&gt;}} and change {{ic|/srv/http}} to the Drupal install directory, {{ic|/usr/share/webapps/drupal}}. In the same section, make sure it includes a line {{ic|AllowOverride All}} to enable the clean URL's.
*If you are using Apache Virtual Hosts, see [[Apache#Virtual hosts]].
And include it at the bottom of {{ic|/etc/httpd/conf/httpd.conf}}:
Include conf/extra/drupal.conf
In {{ic|/etc/httpd/conf/httpd.conf}}, also uncomment the {{ic|LoadModule rewrite_module modules/mod_rewrite.so}} line.
Edit {{ic|/usr/share/webapps/drupal/.htaccess}} and replace {{ic|Require all denied}} by {{ic|Require all granted}}.
Edit {{ic|/usr/share/webapps/drupal/.htaccess}} and replace {{ic|Require all denied}} by {{ic|Require all granted}}.

Revision as of 22:35, 28 December 2015

zh-CN:Drupal "Drupal is a free and open source content management system (CMS) and Content Management framework (CMF) written in PHP and distributed under the GNU General Public License." - Wikipedia

This article describes how to setup Drupal and configure Apache, MySQL or PostgreSQL, PHP, and Postfix to work with it. It is assumed that you have some sort of LAMP (Apache, MySQL, PHP) or LAPP (Apache, PostgreSQL, PHP) server already setup.


Install the drupal package.

Edit /etc/php/php.ini:

  • Uncomment the extension=gd.so line.
  • Enable a PDO extension for your database. For MySQL, the line extension=pdo_mysql.so should be uncommented.

Copy the example Apache configuration file:

# cp /etc/webapps/drupal/apache.example.conf /etc/httpd/conf/extra/drupal.conf

And include it at the bottom of /etc/httpd/conf/httpd.conf:

Include conf/extra/drupal.conf

In /etc/httpd/conf/httpd.conf, also uncomment the LoadModule rewrite_module modules/mod_rewrite.so line.

Edit /usr/share/webapps/drupal/.htaccess and replace Require all denied by Require all granted.

Finally, restart Apache (httpd.service).

Installing Postfix

In order to send e-mails with Drupal, you will need to install Postfix. Drupal uses e-mails for account verification, password recovery, etc. First install postfix.

  1. Edit Postfix configuration file /etc/postfix/main.cf as needed. All that you should have to do is change the hostnames under "Internet Host and Domain Names" myhostname = hostname1
  2. Start the Postfix service: # systemctl start postfix.
  3. Send a test e-mail to yourself: mail myusername@localhost. Enter a subject, some words in the body, then press Ctrl+d to exit and send the letter. Wait 10 seconds, and then type mail to check your mail. If you've gotten it, excellent.
  4. Make sure port 25 is fowarded if you have a router so that mails can be sent to the Internet at large
  5. Edit the file /etc/php/php.ini. Find the line that starts with, ;sendmail_path="" and change it to sendmail_path="/usr/sbin/sendmail -t -i"
  6. Restart the Apache web server.

Tips and tricks

Scheduling with Cron

Drupal recommends running cron jobs hourly. Cron can be executed from the browser by visiting http://localhost/cron. It is also possible to run cron via script by copying the appropriate file from the "scripts" folder into /etc/cron.hourly and making it executable.

Upload progress not enabled

Upon successful installation you may see the following message in the Status Report:

Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the PECL uploadprogress library (preferred) or to install APC.

First, install the php-pear package. Next, use the pecl command to automatically download, compile and install the library:

# pecl install uploadprogress

Finally, add to /etc/php/php.ini


Restart Apache.


Browser shows the actual PHP code when visiting localhost

You do not have php-apache installed.

Then, enable the PHP module in /etc/httpd/conf/httpd.conf by adding the following lines in the appropriate sections:

LoadModule php5_module modules/libphp5.so
Include conf/extra/php5_module.conf

If, when starting httpd, you get the following error:

httpd: Could not reliably determine the server's fully qualified domain name, using for ServerName

You should edit /etc/httpd/conf/httpd.conf. In that file find the line that looks similar to

#ServerName www.example.com:80

Uncomment it (remove # from the front) and adjust the address as needed. Restart httpd:

# systemctl restart httpd

Setup page is not the initial page when accessing localhost

In this situation, you should navigate in your /srv directory and look for the drupal folder (most probably it will be in the http directory). Then edit /etc/httpd/conf/httpd.conf. and look for a line starting with DocumentRoot and change the path with that folder's path (for example DocumentRoot "/srv/http/drupal") and also find another line starting with <Directory and set the same path there as well. Restart httpd.

See also