Difference between revisions of "Drupal"

From ArchWiki
Jump to: navigation, search
m (More Resources: Use internal link)
(don't italicize quotes)
 
(53 intermediate revisions by 11 users not shown)
Line 1: Line 1:
 +
[[Category:Web server]]
 
[[it:Drupal]]
 
[[it:Drupal]]
 +
[[ja:Drupal]]
 
[[sr:Drupal]]
 
[[sr:Drupal]]
 
[[zh-CN:Drupal]]
 
[[zh-CN:Drupal]]
[[Category:Web Server]]
+
{{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]]
  
''"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]
+
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.
  
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.
+
== Installation ==
  
==Installation==
+
[[Install]] the {{Pkg|drupal}} package.
  
===Installing Drupal===
+
== Configuration ==
  
====from Arch repositories====
+
=== PHP ===
#Install the {{Pkg|drupal}} package from [[community]] using [[pacman]].
+
#Edit {{ic|/etc/php/php.ini}}:
+
#*If PHP version is less than 5.2.0, Find the line with "{{Ic|<nowiki>;extension=json.so</nowiki>}}" and uncomment it by removing the ";" from the beginning of the line if necessary. If no such line is found, add it to the {{Ic|<nowiki>[PHP]</nowiki>}} section of the file.
+
#*For Drupal 7, 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 "{{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}}:
+
#*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"}}.
+
#**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]].
+
#Comment out the '{{Ic|deny from all}}' line of the {{ic|/usr/share/webapps/drupal/.htaccess}} file to enable httpd access.
+
#[[Daemons#Restarting|Restart]] Apache (httpd).
+
  
====manual install====
+
Edit {{ic|/etc/php/php.ini}}:
  
#Download the latest package from http://drupal.org and extract it.
+
* To enable support for image manipulation uncomment the line {{ic|<nowiki>extension=gd.so</nowiki>}}
#Move the folders to apache's htdocs folder.
+
#Open a web browser, and navigate to "localhost"
+
#Follow the on-screen instructions.
+
  
===Installing GD===
+
For database support enable a PDO extension for your database
You may need the GD library for your Drupal installation.
+
* To enable support for [[SQLite]] uncomment the line {{ic|<nowiki>extension=pdo_sqlite.so</nowiki>}}
#Install the {{Pkg|php-gd}} package using [[pacman]].
+
* To enable support for [[MySQL]] uncomment the line {{ic|<nowiki>extension=pdo_mysql.so</nowiki>}}
#Edit {{ic|/etc/php/php.ini}}. Find the line with {{Ic|<nowiki>;extension=gd.so</nowiki>}} and uncomment it by removing the ";". If no such line is found, add it to the {{Ic|<nowiki>[PHP]</nowiki>}} section of the file.
+
* To enable support for [[PostgreSQL]] uncomment the line {{ic|<nowiki>extension=pdo_pgsql.so</nowiki>}}
#[[Daemons#Restarting|Restart]] Apache (httpd).
+
  
===Installing Postfix===
+
=== Apache ===
In order to send e-mails with Drupal, you will need to install [[postfix]].  Drupal uses e-mails for account verification, password recovery, etc.
+
#Install Postfix<pre># pacman -S postfix </pre>
+
#Configure Postfix as needed <pre># nano /etc/postfix/main.cf </pre> All that you should have to do is change the hostnames under "Internet Host and Domain Names" <pre> myhostname = hostname1 </pre><br>And then start the Postfix service:<pre># rc.d start postfix</pre>
+
#Send a test e-mail to yourself <pre> mail myusername@localhost </pre> (Enter a subject, some words in the body, then press 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
+
#Open the file {{ic|/etc/php/php.ini}} with your editor of choice, e.g. <pre># nano /etc/php/php.ini</pre> 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<pre>rc.d restart httpd</pre>
+
  
==Tips and Tricks==
+
Copy the example Apache configuration file:
 +
# cp /etc/webapps/drupal/apache.example.conf /etc/httpd/conf/extra/drupal.conf
  
===Scheduling with Cron===
+
And include it at the bottom of {{ic|/etc/httpd/conf/httpd.conf}}:
Drupal recommends running cron jobs hourly.  Cron can be executed from the browser by visiting '''<code>localhost/cron</code>'''  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.
+
Include conf/extra/drupal.conf
  
===Xampp Compatibility===
+
In {{ic|/etc/httpd/conf/httpd.conf}}, also uncomment the {{ic|LoadModule rewrite_module modules/mod_rewrite.so}} line.
  
The 5.x and 6.x series of Drupal do not support PHP 5.3, and as a result are incompatible with the latest release of [[Xampp]].  Currently, the last Drupal-compatible version of Xampp is 1.7.1.
+
=== Drupal ===
  
Note: Xampp's PHP memory limit currently defaults to 8MB.  Also, Xampp ignores php.ini files in the Drupal directory.  To fix this:
+
Edit {{ic|/usr/share/webapps/drupal/.htaccess}} and replace {{ic|Require all denied}} by {{ic|Require all granted}}.
#edit Xampp's php.ini file using your favorite editor.<pre>nano /opt/lampp/etc/php.ini</pre>
+
#Search for the "memory_limit" line, and replace it with an appropriate value. (Most Drupal installations are happy with 32M, but sites with a lot of modules may need 100M or more.)
+
#Restart Xampp.<pre>/opt/lampp/lampp restart</pre>
+
  
===Upload progress Not enabled===
+
Finally, [[Daemons#Restarting|restart]]{{Broken section link}} Apache ({{ic|httpd.service}}). You can now access the Drupal installation at http://localhost/drupal .
  
Upon successful installation you may see the following message in the Status Report:
+
== Commandline tools ==
{{Box BLUE||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.}}
+
<br>
+
First, install the <code>php-pear</code> package:
+
<pre># pacman -S php-pear</pre>
+
Next, use the <code>pecl</code> command to automatically download, compile and install the library:
+
<pre># pecl install uploadprogress</pre>
+
Finally, add to {{ic|/etc/php/php.ini}}
+
<pre>extension=uploadprogress.so</pre>
+
Restart apache.
+
  
==Troubleshooting==
+
=== Drush ===
  
===Browser shows the actual PHP code when visiting localhost===
+
[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.
 +
It can be installed with the {{AUR|drush}} package.
  
You do not have php-apache installed.
+
=== Drupalconsole ===
<pre># pacman -S php-apache</pre>
+
  
Then, enable the PHP module in {{ic|/etc/httpd/conf/httpd.conf}} by adding the following lines in the appropriate sections:
+
[https://drupalconsole.com/ Drupalconsole] is a CLI tool to generate boilerplate code, interact and debug Drupal 8.
<pre>LoadModule php5_module modules/libphp5.so
+
It can be installed with the {{AUR|drupalconsole}} package.
Include conf/extra/php5_module.conf</pre>
+
  
If, when starting httpd, you get the following error:
+
=== PHP-Codesniffer-Drupal ===
<pre>httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName</pre>
+
You should edit {{ic|httpd.conf}}
+
<pre># nano /etc/httpd/conf/httpd.conf</pre>
+
In that file find the line that looks similar to
+
<pre>#ServerName www.example.com:80</pre>
+
Uncomment it (remove # from the front) and adjust the address as needed. Restart httpd by
+
<pre># /etc/rc.d/httpd restart</pre>
+
or
+
<pre># rc.d restart httpd</pre> and you are ready to go!
+
  
===Drupal's setup page is not the initial page when accessing localhost===
+
[https://www.drupal.org/project/coder PHP-Codesniffer-Drupal] checks your Drupal code against coding standards and other best practices.
 +
It can be installed with the {{AUR|php-codesniffer-drupal}} package.
  
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|httpd.conf}} by
+
== Tips and tricks ==
<pre># nano /etc/httpd/conf/httpd.conf</pre>
+
and look for a line starting with {{Ic|DocumentRoot}} and change the path with that folder's path (for me it looks like DocumentRoot "/srv/http/drupal") and also find another line starting with <pre><Directory</pre> and set the same path there as well. Restart httpd by <pre># rc.d restart httpd</pre> and you will be done.
+
  
===Drupal's setup page does not start and shows HTTP ERROR 500===
+
=== 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 [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.
 +
 
 +
=== 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 {{ic|/etc/cron.hourly}} and making it executable.
 +
 
 +
=== Upload progress not enabled ===
 +
 
 +
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.}}
 +
 
 +
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.so
 +
Restart Apache.
  
This may be because Drupal needs the {{Ic|json.so}} extension to be activated in your {{ic|/etc/php/php.ini}}.
+
== See also ==
just uncomment the line
+
{{Ic|<nowiki>;extension=json.so</nowiki>}}
+
from {{ic|/etc/php/php.ini}} by deleting the initial ';' and restart httpd service by typing
+
<code>rc.d restart httpd</code>.
+
(See [http://drupal.org/node/1018824 this link] for info.)
+
  
==More Resources==
+
* [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 17:50, 12 September 2016

"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.so

For database support enable a PDO extension for your database

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

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[broken link: invalid section] 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.so

Restart Apache.

See also