How to install, configure, and adjust permissions of drupal and apache in ubuntu

Source: Internet
Author: User
Tags apache php php language mkdir php mysql postgresql drupal mysql database

Drupal introduction:Drupal is an open-source content management Framework (CMF) written in PHP. It consists of a content management system (CMS) and a PHP development Framework. It has won the world's best CMS Award for many years and is the most famous WEB application based on the PHP language. Drupal is a robust content management system on lamp (linux + apache + mysql + php). The default database is mysql, but drupal also supports PostgreSQL databases, the latest ubuntu release contains drupal6 and drupal7 in the repository. This is only two drupal versions supported by ubuntu. Please note when selecting the drupal version!

LAMP system installation

To install lamp using other methods, visit Apache PHP MySQL (link is external)

Install lamp in a simple way

The simplest way is to use the terminal command line to install the entire lamp package.

The code is as follows: Copy code
Sudo tasksel install lamp-server

If your system does not support the tasksel command, install:

The code is as follows: Copy code
Sudo apt-get install tasksel

I (optional) recommend that you enable rewrite of apache2, which is helpful for page redirection of many modules of drupal and apache servers.

Edit the file "/etc/apache2/sites-available/default" and change "AllowOverride (link is external) none" to "AllowOverride (link is external) All ", then execute:

The code is as follows: Copy code
Sudo gedit/etc/apache2/sites-available/default

Sudo a2enmod rewrite

Sudo service apache2 restart

Drupal installation

Note: The following two installation methods are incompatible. The ubuntu package (in the repository) and the manual installation directory are different. Select an installation method and do not try to use them at the same time, two switchover modes are not supported.


Install the drupal package from the ubuntu repository

You can choose to install drupal6 or drupal 7 in the ubuntu repository. As usual, the version in the repository is not the latest, but it can be easily updated.

The code is as follows: Copy code

Sudo apt-get install drupal6


The code is as follows: Copy code
Sudo apt-get install drupal7

Allow dbconfig-common to configure your database (default database: MySQL)

Then, register the drupal module with apache:

The code is as follows: Copy code
Sudo cp/etc/drupal/6/apache2.conf/etc/apache2/mod-enabled/drupal. conf


The code is as follows: Copy code
Sudo cp/etc/drupal/7/apache2.conf/etc/apache2/mod-enabled/drupal. conf

Finally, restart the apache server:

The code is as follows: Copy code

Sudo service apache2 restart

Install drupal manually

The following steps take drupal 7.25 in the drupal7 series as an example. It is the latest version when writing this article (this step also applies to drupal6)

The code is as follows: Copy code

Wget (link is external)

Tar-xvzf drupal-7.25.tar.gz

Sudo mkdir/var/www/drupal

Sudo mv drupal-7.25/* drupal-7.25/. htaccess drupal-7.25/. gitignore/var/www/drupal

Create a new sub-folder under the default website installation directory of drupal to store custom logos, user names, and other media files for your new website.

The code is as follows: Copy code

Sudo mkdir/var/www/drupal/sites/default/files

Sudo chown www-data: www-data/var/www/drupal/sites/default/files

You also need to create a startup configuration file for the default site.

The code is as follows: Copy code

Sudo cp/var/www/drupal/sites/default. settings. php/var/www/drupal/sites/default/settings. php

Sudo chown www-data: www-data/var/www/drupal/sites/default/settings. php

Manually configure the mysql database for Drupal

You need to create a database for drupal to import the database table of drupal. You can create the database through phpmyadmin or the command line.

The code is as follows: Copy code
Mysqladmin-u root-p create drupal

Create a database named drupal for drupal. Of course, you can customize the database name

The code is as follows: Copy code

Mysql-u root-p

Mysql> grant select, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, create temporary tables, lock tables on drupal. * TO 'drupaluser' @ 'localhost' identified by 'drupalpass ';

You certainly don't want drupal to use the root account to connect to the database. The above Command creates a database user with certain permissions different from mysql root: drupaluser, drupalpass, you can use another user name and password to replace drupaluser and drupalpass. If the command successfully activates the new permissions:

The code is as follows: Copy code

Mysql> flush privileges;

Exit mysql command:

The code is as follows: Copy code

Mysql> q

Configure the PostgreSQL database for drupal

Edit the/var/www/drupal/sites/default/settings. php file and specify the username, password, and database used by drupal.

The code is as follows: Copy code
Sudo gedit/var/www/drupal/sites/default/settings. php

* Database URL format:

$ Db_url = 'pgsql: // username: password @ localhost (link sends e-mail)/databasename ';

Where username = drupaluser password = drupaluserpass databasename = drupaldb

Restart Apache

Restart Apache2.

The code is as follows: Copy code
Sudo service apache2 restart

Use a browser to complete the final installation of drupal

Finally, enter http: // localhost/drupal/install in the browser. php (link is external) (or it may be http: // localhost/drupal6/install. php (link is external) or http: // localhost/drupal7/install. php (link is external) if the installation uses the official repository), create an account, log in, follow the installation instructions to connect to the database, and then configure your site, the first account will automatically become the primary management account with all permissions

Special Problems With Drupal 7 installation

When you install drupal 7 locally, you may encounter special questions about "module", "topic", and "email authentication".

Install new modules

When installing a new module, you may encounter the following errors:

The code is as follows: Copy code
"WARNING: You are not using an encrypted connection, so your password will be sent in plain text. Learn more ."

"To continue, provide your server connection details"

This warning prompt is a bit misleading. The error is caused by the Directory write permission on the server.

Write permission

If you are not worried about security issues, the fastest solution is to change the write permission.

When apache users are www-data (apache default, ngnix is also the default ):

The code is as follows: Copy code
Sudo chown www-data: www-data-R/var/www/drupal/sites

Command line

The safe solution is to solve the problem through ssh command line, which is slow but safer.

For example, install Wysiwyg

The code is as follows: Copy code

Wget (link is external)

Tar-xvzf wysiwyg-7.x-2.1.tar.gz

Sudo mkdir-p/var/www/drupal/sites/all/modules/wysiwyg

Sudo mv wysiwyg/*/var/www/drupal/sites/all/modules/wysiwyg

Wysiwvg requires the client's editor. CKEditor runs the following

The code is as follows: Copy code

Wget (link is external)

Tar-xvzf ckeditor_3.6.1.tar.gz

Sudo mkdir-p/var/www/drupal/sites/all/libraries/ckeditor

Sudo mv ckeditor/*/var/www/drupal/sites/all/libraries/ckeditor

Adjust the php memory limit

You should increase the default php memory limit value (the memory value is used to support running scripts). The default 8 M is not enough, and 96 M or 160 M is used, if you want to use the GUI (although the basic 32 m is enough)

In a newer version of drupal6, you can edit the settiings. Php file to add the following values.

The code is as follows: Copy code
Ini_set ('memory _ limit ', '96m ');


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.