Wednesday, 26 March 2014

How-to: Install Joomla on Debian 7 LaMp


Joomla is the well-established Content Management System (CMS) used to run a vast number of websites around the world.

I don't intend to be highly original here: you will find a version of these instructions on wiki.debian.org.

Make sure that you have installed zip and unzip for extracting the downloaded Joomla (sorry, 'Joomla!') package; I've found the default Squeeze archive manager hangs when I try to use it on the Joomla zip files.


You can check this by using a very geeky dpkg command:
$ dpkg -l  | awk '/^ii zip/ {print $1" "$2}'
ii unzip


Personally I just go ahead and issue

apt-get install zip unzip

and the system tells me if they're already installed, and installs them if not.

Note that the dollar sign '$' shell prompt is indicating you're a regular user. For software installs under Linux, you generally need to work under a hash '#' shell prompt, which indicates that you're the super user 'root', invoked by issuing an su or sudo command.


We're not installing from source but a pre-prepared package. You will want to check http://www.joomla.org/download.html for an updated package. At the time I wrote this it was http://joomlacode.org/gf/download/frsrelease/19007/134333/Joomla_3.2.1-Stable-Full_Package.zip

You need to extract and upload the files and folders to your web server. If you're working on a remote server, that usually means using FTP.

If you want Joomla to be the main installation accessible through your main domain (i.e. www.mydomain.com), you need to upload the extracted files to your www root or public_html folder. To access Joomla on a subfolder of your domain (i.e. www.mydomain.com/joomla) you create that sub-folder and FTP the files into it (i.e. public_html/joomla/).

For version 3.2.1, you may do the following from command line, assuming your current working directory is your home folder /home/user:

$ wget http://joomlacode.org/gf/download/frsrelease/19007/134333/Joomla_3.2.1-Stable-Full_Package.zip
$ cd /var/www
$ su
# mkdir -m 0755 joomla
# cd joomla
# unzip /home/user/Downloads/Joomla_3.2.1-Stable-Full_Package.zip

So, invoke a root terminal using  su without any options, because we want to issue root commands more than only one time; it will prompt for the super user's password and then change the shell environment, repectively $UID and $EUID, to give you a hash mark (#) shell prompt.

wget fetches the package; we then create a folder and assign write permissions, change path into that folder and unzip the Joomla package.

To set ownerships and permissions to allow writing in the entire joomla folder, enter:

chown -R www-data:www-data /var/www/joomla

To be more selective and keep most of the Joomla files locked down, instead run:
chown -R root:root /var/www/joomla
cd /var/www/joomla
PLACES='
administrator/backups X
administrator/components
administrator/modules
administrator/templates
cache
components
images
images/banners
images/stories X
language
mambots X
mambots/content X
mambots/editors X
mambots/editors-xtd X
mambots/search X
media
modules
templates
'
for i in $PLACES; do chown -R www-data:www-data $i; done

Then set file and directory permissions:

find /var/www/joomla -type f -exec chmod 0644 {} \;
find /var/www/joomla -type d -exec chmod 0755 {} \;


Pre-install Tasks
The Joomla files are in place, but we need a bit more prep before we configure it.


Configure MySQL

It is time to create a database for Joomla (sorry, 'Joomla!'):

mysqladmin -u root -p create joomla

Where joomla is the name for this Joomla!' instance's database.

Next create a MySQL user different from root for Joomla!'s database. Invoke the MySQL client with:

mysql -u root -p

The prompt changes to 'mysql>' to indicate you're in a mysql session. Use your  Joomla! database name, yourusername and yourpassword with the ones you're going to use.

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, \
LOCK TABLES ON joomla.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';

Activate the settings and quit : [ there will be a mysql> prompt:

FLUSH PRIVILEGES;
\q


After disconnecting from the database server, you should remove the login information of your just new created MySQL user by editing MySQL's history file.

nano ~/.mysql_history

You can use your choice editor - vi, gedit - in place of nano. I happen to run a GUI on my virtual servers because I'm lazy that way.

Configure PHP5
In the Joomla pre- install check, when the install is complete and you set up Joomla in the browser, Output Buffering is On and it's recommended that it should be Off .

Edit /etc/php5/apache2/php.ini  and comment out this line:
output_buffering = 4096

by putting a ';' in front to get:

;output_buffering = 4096

You will likely get warnings on the install screen regarding suhosin. To make the suggested changes, edit  /etc/php5/conf.d/suhosin.ini.

Set the values:

suhosin.post.max_array_index_length = 256
suhosin.post.max_totalname_length = 8192
suhosin.post.max_vars = 2048
suhosin.request.max_array_index_length = 256
suhosin.request.max_totalname_length = 8192
suhosin.request.max_vars = 2048

Configure Joomla!
At last! Open a web-browser at the page http://localhost/joomla, replacing localhost with your server IP address or domain name (i.e. http://mydomain.com) if you are installing on a remote server.

You will be guided in the steps of setting up Joomla! through several screens of the Joomla Web Installer. On the first step of the installation process, you need to add the necessary information about your site and your administrative username, so have your MySQL user, password and database name available to insert as directed.

The web installer needs to know (lifted from the wiki):
  • Site Name: Enter the name of your site. Most templates will use this for the first heading of your index.
  • Description: Add a brief description of your website. It depends on your template if and where this text would be displayed.
  • Admin Email: Enter a valid email address. It will be used for password recovery and system messages.
  • Admin Username: Your administrative username. Please select a unique username, rather than "admin" or "administrator" since those are often subject to hacker attacks.
  • Admin Password: Add a password as strong as possible.
  • Site Offline: Select whether your site should be taken offline after you complete the installation. For the purpose of this tutorial we will leave this option set to NO (site will be live after installation).

The next screen, requires the information to connect to your MySQL database.
  • Database Type: By default this value is set to MySQLi. I leave it that way, MySQLi is an optimised version of the regular MySQL database.
  • Host Name: Once again, leave the default localhost value.
  • Username: Enter the username for your MySQL database.
  • Password: Fill in the password for the database username.
  • Database Name: Enter the name of the MySQL database you want to use.
  • Table Prefix: Joomla will add this prefix to all of its database tables. This is useful if you want to host multiple Joomla sites on a single database. You should leave the default value.
  • Old Database Process: If you have any existing databases, choose what to do with the existing tables that are required by the installer. The options are to remove or backup any existing data that's about to be replaced. I usually accept the option set to Backup since it is the safest choice and none of my databases are very big.

On the last page of the installation process, you can specify if you want any sample data installed on your server. I find it useful to choose the Default Sample data option as you can use it as a default testbed and a sample on which to build our actual site. All the sample data can be deleted at any time.

The second part of the page shows all the pre-installation checks. If your server setup meets the Joomla requirements you will see a green check after each line.

Lastly, hit the Install button to start the actual Joomla installation. In a few minutes you will be redirected to the last screen of the Joomla Web Installer.

On the last screen of the installer you are required to remove the installation folder button for security reasons; Joomla enforces this bit of best practice and won't let you use your site unless you remove this folder completely; an intruder  could potentially overwrite your site by running the installer again

It is possible at this point to get:

Error
Installation folder could not be deleted. Please manually delete the folder.

Deleting the installation folder manually

You will not be able to browse to your site or admin page until you delete that installation folder.

To delete the installation folder manually, use an FTP client and right click on the folder named "installation" and press Delete; or  from a root terminal:

# rm -rf /var/www/joomla/installation/
# exit
$


You might also see:

Notice
Your configuration file or directory is not writable or there was a problem creating the configuration file. 

This means Joomla could not create the configuration.php file and you will have to upload the following code by hand to your site root folder:

<?php
class JConfig {
    public $offline = '0';
    public $offline_message = 'This site is down for maintenance.<br /> Please check back again soon.';
    public $display_offline_message = '1';
    public $offline_image = '';
    public $sitename = 'Fostering and Adoption';
    public $editor = 'tinymce';
    public $captcha = '0';
    public $list_limit = '20';
    public $access = '1';
    public $debug = '0';
    public $debug_lang = '0';
    public $dbtype = 'mysql';
    public $host = 'localhost';
    public $user = 'robin';
    public $password = 'J0llyG00d';
    public $db = 'joomla';
    public $dbprefix = 'fanda_';
    public $live_site = '';
    public $secret = 'pHIZSq2pGjsFGBn2';
    public $gzip = '0';
    public $error_reporting = 'default';
    public $helpurl = 'http://help.joomla.org/proxy/index.php?option=com_help&keyref=Help{major}{minor}:{keyref}';
    public $ftp_host = '127.0.0.1';
    public $ftp_port = '21';
    public $ftp_user = '';
    public $ftp_pass = '';
    public $ftp_root = '';
    public $ftp_enable = '0';
    public $offset = 'UTC';
    public $mailonline = '1';
    public $mailer = 'mail';
    public $mailfrom = 'robin.catling@fanda.org.uk';
    public $fromname = 'Fostering and Adoption';
    public $sendmail = '/usr/sbin/sendmail';
    public $smtpauth = '0';
    public $smtpuser = '';
    public $smtppass = '';
    public $smtphost = 'localhost';
    public $smtpsecure = 'none';
    public $smtpport = '25';
    public $caching = '0';
    public $cache_handler = 'file';
    public $cachetime = '15';
    public $MetaDesc = 'RiP Fostering and Adoption site';
    public $MetaKeys = '';
    public $MetaTitle = '1';
    public $MetaAuthor = '1';
    public $MetaVersion = '0';
    public $robots = '';
    public $sef = '1';
    public $sef_rewrite = '0';
    public $sef_suffix = '0';
    public $unicodeslugs = '0';
    public $feed_limit = '10';
    public $log_path = '/var/www/joomla/logs';
    public $tmp_path = '/var/www/joomla/tmp';
    public $lifetime = '15';
    public $session_handler = 'database';
}

Done! You should have a fully functional Joomla website and be able to start building your website content. RC


1 comment:

At least try to be nice, it won't kill you...