Difference between revisions of "Drupal"

From ArchWiki
Jump to: navigation, search
(Arch repositories: drupal needs mod_rewrite)
m (Configuration: Missed PHP block at top, combined both PHP config sections - I'm new here!!)
 
(44 intermediate revisions by 10 users not shown)
Line 1: Line 1:
[[Category:Web server]]
+
[[Category:Content management systems]]
 
[[it:Drupal]]
 
[[it:Drupal]]
 
[[ja:Drupal]]
 
[[ja:Drupal]]
 
[[sr:Drupal]]
 
[[sr:Drupal]]
[[zh-CN:Drupal]]
+
[[zh-hans: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."'' - [http://en.wikipedia.org/wiki/Drupal Wikipedia]
+
{{Related articles start}}
 +
{{Related|LAMP}}
 +
{{Related|LAPP}}
 +
{{Related|LASP}}
 +
{{Related|MySQL}}
 +
{{Related|PostgreSQL}}
 +
{{Related|SQLite}}
 +
{{Related|Sendmail}}
 +
{{Related|PostFix}}
 +
{{Related|Exim}}
 +
{{Related articles end}}
 +
"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:Drupal|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.
+
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]] (Linux, Apache, MySQL, PHP), LAPP (Linux, Apache, PostgreSQL, PHP) or LASP (Linux, Apache, SQLite, PHP) server already setup.
  
 
== Installation ==
 
== Installation ==
  
=== Arch repositories ===
+
[[Install]] the {{Pkg|drupal}} package.
 +
 
 +
== Configuration ==
  
[[Install]] the {{Pkg|drupal}} package.
+
=== PHP ===
  
 
Edit {{ic|/etc/php/php.ini}}:
 
Edit {{ic|/etc/php/php.ini}}:
*Uncomment the {{ic|<nowiki>extension=gd.so</nowiki>}} line. Also install {{pkg|php-gd}} ({{bug|47548}}).
 
*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}}:
+
* To enable support for image manipulation uncomment the line {{ic|<nowiki>extension=gd</nowiki>}}
*Uncomment the {{ic|LoadModule rewrite_module modules/mod_rewrite.so}} line.
+
 
*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.
+
For database support enable a PDO extension for your database
*If you are using Apache Virtual Hosts, see [[Apache#Virtual hosts]].
+
* To enable support for [[SQLite]] uncomment the line {{ic|<nowiki>extension=pdo_sqlite</nowiki>}}
 +
* To enable support for [[MySQL]] uncomment the line {{ic|<nowiki>extension=pdo_mysql</nowiki>}}
 +
* To enable support for [[PostgreSQL]] uncomment the line {{ic|<nowiki>extension=pdo_pgsql</nowiki>}}
 +
 
 +
Apache will fail to start with an error finding php_admin_value, below fixes this:
 +
 
 +
[[Install]] the {{Pkg|php-apache}} package.
 +
 
 +
In {{ic|/etc/httpd/conf/httpd.conf}}, comment the line:
 +
#LoadModule mpm_event_module modules/mod_mpm_event.so
 +
and uncomment the line:
 +
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
  
Finally comment out the {{ic|Require all denied}} line in the {{ic|/usr/share/webapps/drupal/.htaccess}} file to enable access from any machine. Then [[Daemons#Restarting|restart]] Apache ({{ic|httpd.service}}).
+
Place this at the end of the {{ic|LoadModule}} list:
 +
LoadModule php7_module modules/libphp7.so
 +
AddHandler php7-script .php
 +
Place this at the end of the {{ic|Include}} list:
 +
Include conf/extra/php7_module.conf
  
=== Manual install ===
+
Restart {{ic|httpd.service}} using [[systemd#Using units|systemd]].
  
Download the latest package from http://drupal.org and extract it. Move the folders to Apache's htdocs folder. Open a web browser, and navigate to [localhost localhost]. Follow the on-screen instructions.
+
Apache will fail to start with an error finding open_basedir, below fixes this:
  
=== Installing Postfix ===
+
In {{ic|/etc/php/php.ini}}, uncomment and suffix {{ic|open_basedir}} to look like this:
  
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 {{Pkg|postfix}}.
+
open_basedir = /etc/webapps
# Edit Postfix configuration file {{ic|/etc/postfix/main.cf}} as needed. All that you should have to do is change the hostnames under "Internet Host and Domain Names" {{ic|myhostname &#61; hostname1}}
 
# Start the Postfix service: {{ic|# systemctl start postfix}}.
 
# Send a test e-mail to yourself: {{ic|mail myusername@localhost}}. Enter a subject, some words in the body, then press {{ic|Ctrl+d}} to exit and send the letter. Wait 10 seconds, and then type {{ic|mail}} to check your mail. If you've gotten it, excellent.
 
# Make sure port 25 is fowarded if you have a router so that mails can be sent to the Internet at large
 
# Edit the file {{ic|/etc/php/php.ini}}. Find the line that starts with, {{ic|<nowiki>;sendmail_path=""</nowiki>}} and change it to {{ic|<nowiki>sendmail_path="/usr/sbin/sendmail -t -i"</nowiki>}}
 
# Restart the Apache web server.
 
  
== Tips and tricks ==
+
=== Apache ===
 +
 
 +
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 {{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.
 +
 
 +
=== Drupal ===
  
=== Scheduling with Cron ===
+
Edit {{ic|/usr/share/webapps/drupal/.htaccess}} and replace {{ic|Require all denied}} by {{ic|Require all granted}}.
  
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 {{ic|/etc/cron.hourly}} and making it executable.
+
Finally, [[restart]] Apache ({{ic|httpd.service}}). You can now access the Drupal installation at http://localhost/drupal .
  
=== Upload progress not enabled ===
+
== Commandline tools ==
  
Upon successful installation you may see the following message in the Status Report:
+
=== Drush ===
{{bc|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 {{Pkg|php-pear}} package.
+
[http://www.drush.org/ Drush] is a command line shell and Unix scripting interface for Drupal. Drush core ships with lots of useful commands for interacting with code like modules/themes/profiles. Similarly, it runs update.php, executes sql queries and DB migrations, and misc utilities like run cron or clear cache. Drush can be extended by 3rd party commandfiles.
Next, use the '''pecl''' command to automatically download, compile and install the library:
+
It can be installed with the {{AUR|drush}} package.
# pecl install uploadprogress
 
Finally, add to {{ic|/etc/php/php.ini}}
 
extension=uploadprogress.so
 
Restart Apache.
 
  
== Troubleshooting ==
+
=== Drupalconsole ===
  
=== Browser shows the actual PHP code when visiting localhost ===
+
[https://drupalconsole.com/ Drupalconsole] is a CLI tool to generate boilerplate code, interact and debug Drupal 8.
 +
It can be installed with the {{AUR|drupalconsole}} package.
  
You do not have {{Pkg|php-apache}} installed.
+
=== PHP-Codesniffer-Drupal ===
  
Then, enable the PHP module in {{ic|/etc/httpd/conf/httpd.conf}} by adding the following lines in the appropriate sections:
+
[https://www.drupal.org/project/coder PHP-Codesniffer-Drupal] checks your Drupal code against coding standards and other best practices.
LoadModule php5_module modules/libphp5.so
+
It can be installed with the {{AUR|php-codesniffer-drupal}} package.
Include conf/extra/php5_module.conf
 
  
If, when starting httpd, you get the following error:
+
== Tips and tricks ==
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
 
You should edit {{ic|/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 ===
+
=== Sending Mail ===
  
In this situation, you should navigate in your {{ic|/srv}} directory and look for the {{ic|drupal}} folder (most probably it will be in the {{ic|http}} directory). Then edit {{ic|/etc/httpd/conf/httpd.conf}}.
+
Drupal needs a Sendmail-compatible MTA like [[Sendmail]], [[Postfix]] or [[Exim]] if you plan to send mail from your local setup.
and look for a line starting with {{ic|DocumentRoot}} and change the path with that folder's path (for example {{ic|DocumentRoot "/srv/http/drupal"}}) and also find another line starting with {{ic|<Directory}} and set the same path there as well. Restart httpd.
+
Alternatively there are multiple solutions to send mail via external mail servers through SMTP or other means like [https://drupal.org/project/smtp SMTP] or [https://drupal.org/project/phpmailer PHPMailer]. Use the [https://www.drupal.org/search/site/mail search page] to find more possibilities.
  
=== Setup page does not start and shows HTTP ERROR 500 ===
+
=== Scheduling with Cron ===
  
This may be because Drupal needs the {{ic|json.so}} extension to be activated in your {{ic|/etc/php/php.ini}}.
+
Drupal recommends running cron jobs hourly. Cron can be executed from the browser by visiting http://localhost/drupal/cron. It is also possible to run cron via script by copying the appropriate file from the "scripts" folder into {{ic|/etc/cron.hourly}} and making it executable.
Just uncomment in {{ic|/etc/php/php.ini}} the line:
 
;extension=json.so
 
Restart httpd service.
 
  
See [http://drupal.org/node/1018824 this link] for info.
+
=== Upload progress not enabled ===
  
This can be caused because Drupal doesn't have access to its .htacccess, to enable this make sure that the directive AllowOverride All is set in your {{ic|/etc/httpd/conf/httpd.conf}} or for your respective user directory.
+
Upon successful installation you may see the following message in the Status Report:
 +
{{bc|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.}}
  
See [https://httpd.apache.org/docs/current/mod/core.html#allowoverride this link] for info.
+
First, install the {{AUR|php-pear}} package.
 +
Next, use the '''pecl''' command to automatically download, compile and install the library:
 +
# pecl install uploadprogress
 +
Finally, add to {{ic|/etc/php/php.ini}}
 +
extension=uploadprogress
 +
Restart Apache.
  
 
== See also ==
 
== See also ==
Line 98: Line 119:
 
* [http://drupal.org/handbook Official Drupal documentation]
 
* [http://drupal.org/handbook Official Drupal documentation]
 
* [http://drupal.org/node/307956 Simple guide to install Drupal on Xampp]
 
* [http://drupal.org/node/307956 Simple guide to install Drupal on Xampp]
* [[LAMP|LAMP (How to setup an Apache server)]]
 

Latest revision as of 11:18, 12 June 2018

"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 (Linux, Apache, MySQL, PHP), LAPP (Linux, Apache, PostgreSQL, PHP) or LASP (Linux, Apache, SQLite, PHP) server already setup.

Installation

Install the drupal package.

Configuration

PHP

Edit /etc/php/php.ini:

  • To enable support for image manipulation uncomment the line extension=gd

For database support enable a PDO extension for your database

  • To enable support for SQLite uncomment the line extension=pdo_sqlite
  • To enable support for MySQL uncomment the line extension=pdo_mysql
  • To enable support for PostgreSQL uncomment the line extension=pdo_pgsql

Apache will fail to start with an error finding php_admin_value, below fixes this:

Install the php-apache package.

In /etc/httpd/conf/httpd.conf, comment the line:

#LoadModule mpm_event_module modules/mod_mpm_event.so

and uncomment the line:

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Place this at the end of the LoadModule list:

LoadModule php7_module modules/libphp7.so
AddHandler php7-script .php

Place this at the end of the Include list:

Include conf/extra/php7_module.conf

Restart httpd.service using systemd.

Apache will fail to start with an error finding open_basedir, below fixes this:

In /etc/php/php.ini, uncomment and suffix open_basedir to look like this:

open_basedir = /etc/webapps

Apache

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.

Drupal

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

Finally, restart Apache (httpd.service). You can now access the Drupal installation at http://localhost/drupal .

Commandline tools

Drush

Drush is a command line shell and Unix scripting interface for Drupal. Drush core ships with lots of useful commands for interacting with code like modules/themes/profiles. Similarly, it runs update.php, executes sql queries and DB migrations, and misc utilities like run cron or clear cache. Drush can be extended by 3rd party commandfiles. It can be installed with the drushAUR package.

Drupalconsole

Drupalconsole is a CLI tool to generate boilerplate code, interact and debug Drupal 8. It can be installed with the drupalconsoleAUR package.

PHP-Codesniffer-Drupal

PHP-Codesniffer-Drupal checks your Drupal code against coding standards and other best practices. It can be installed with the php-codesniffer-drupalAUR package.

Tips and tricks

Sending Mail

Drupal needs a Sendmail-compatible MTA like Sendmail, Postfix or Exim if you plan to send mail from your local setup. Alternatively there are multiple solutions to send mail via external mail servers through SMTP or other means like SMTP or PHPMailer. Use the search page to find more possibilities.

Scheduling with Cron

Drupal recommends running cron jobs hourly. Cron can be executed from the browser by visiting http://localhost/drupal/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-pearAUR package. Next, use the pecl command to automatically download, compile and install the library:

# pecl install uploadprogress

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

extension=uploadprogress

Restart Apache.

See also