From Newroco tech docs
Jump to: navigation, search


  • Install the packages: apache2 php5 php5-gd
  • Install mysql-server and php5-mysql, take note of the root password
  • Download the latest Joomla archive and extract all the code in /var/www/
  • chown -R root:www-data /var/www
  • chmod -R g+w /var/www
  • sudo -i && mysql
  • vim .my.cnf and paste the code below putting in the real root password. This will enable you to login as mysql root without the password
password=<the root password>
password=<the root password>
  • sudo vim /etc/php5/apache2/php.ini - edit the maximum file size to 5MB
  • Create database and db role
create database <db name>
grant all privileges on <db name>.* to '<role name>'@'localhost' identified by '<role password>';
  • Go to the web interface and follow the online instructions using the database name, role name and role password defined in the previous step.
  • If this is a migration to a much newer version now is the perfect time to use SP Transfer plugin to take all the articles, menus, etc from the old website.
  • Check everything worked correctly before making any changes to the menus or articles otherwise the transfer will have to be done once more, but to a fresh install of Joomla!
  • Follow the mysql DB backup procedure here.
  • Enable .htaccess from Joomla Admin
  • Enable mod_rewrite in Apache:
 sudo a2enmod RewriteEngine
 sudo /etc/init.d/apache2 restart
  • Copy the template, discover it and install it from the Admin interface

File Permissions

Set the permissions for your Joomla folders to 755
Set the permissions for your Joomla files to 644
Set the permissions for your configuration.php file to 444
Never use 777(full access) permissions!

If root is owner and www-data as group, 664 is in order for files.

chown -R root:www-data /var/www
chmod -R 664 /var/www
chmod 444 /var/www/configuration.php

Access MYSQL

sudo -i && mysql

Recommended packages

  • Adaptive Images - it will feed to the browser an image better suited for smaller screens automatically.

Recommended plugins

  • OA Contacts - built for OA to display all staff added to the back end as contacts
  • OA Projects - built for OA to display all projects from a specified category in a nice list
  • Simple Transition Gallery - displays in a nice transition images and captions with animations
  • Simple Image Gallery (by JoomlaWorks) - a nice way to display all the photos from a folder
  • Ultimate Feed Display - displays a feed in a module, it can be from the same website
  • Social Backlinks plugin - makes publishing articles to Facebok, twitter and linkedin easy
  • JCE Editor - a much better WYSIWYG editor than TinyMCE
  • GoSquared Plugin - for tracking on GoSquared
  • Kunena - for forums
  • Joes Word Cloud + Lucian's multi colour hack - shows a random list of words from articles of a certain category ina nice tag cloud
  • Simple Email Form - for sending e-mails from a form on the website.
  • jHackGuard - a Joomla 2.5/3.0 security plugin developed by SiteGround. With this plugin your Joomla is protected against the most popular hacking attacks - SQL Injections, Remote URL/File Inclusions, Remote Code Executions and XSS Based Attacks!

Basic and frequent Joomla procedures

  • Login to the back end by going to http://<public website url>/administrator
  • Manage users (add, change name, password) from Users->"User manager" when connected to the back end.
  • When fearing hackers all Joomla files can be locked from writing and unlocked only when installing new plugins. When everything is locked, the media manager can not upload new photos, so to temporarily unlocking it you'd have to give write permissions to the media folder which usually is <website doc root>/images . Provided that www-data is the group of all the files in /var/www do this while connected with ssh
sudo chmod -R g+w /var/www/images

and when done with the media manager

sudo chmod -R g-w /var/www/images

On the current website the procedure should be this (paths accurate)

sudo chmod -R g+w /var/www/

and when done with the media manager

sudo chmod -R g-w /var/www/
  • Never ever upgrade Joomla on production VMs, a lot of people complain about unsuspected basic functions missing after minor upgrades!!!

Prepare for update

We need to make a backup of all files, a backup of the database, then make sure your account has write access to files and allow www-data to write to all files.

sudo rm /var/lib/db_backups/joomla*.tar.gz
sudo tar -zcpf /var/lib/db_backups/joomla<currdate>.tar.gz /var/www/html
sudo -i && mysql
sudo /opt/bin/ --nosleep
sudo chown -R <your user name>:www-data /var/www/html/*
sudo chmod -R g+w /var/www/html/*

Now you can go to Control Panel, and update first Joomla, then all plugins that require updates.

Restore saved version

This assumes your CWD is the web server's folder

sudo rm -R *
sudo tar -zxpf /var/lib/db_backups/joomla<currdate>.tar.gz 
sudo mv var/www/html/* ./
sudo rm -R var
sudo gunzip /var/lib/db_backups/<database name>.gz 
sudo -i && mysql
create database <database name>2; --or another version number if it's been through a restore before
grant all privileges on <database name>2.* to '<user name>'@'localhost' identified by '<password>'; --you can obtain these details from configuration.php
mysql <database name>2 < /var/lib/db_backups/<database name>.sql
--update joomla configuration.php with the new database name
--check that all pages work correctly, no errors, no warnings, etc
--if everything checks out
drop database <database name>;

After update or restore

sudo chmod -R g-w /var/www/html/administrator/
sudo chmod -R g+w /var/www/html/administrator/cache/
sudo chmod -R g-w /var/www/html/bin
sudo chmod -R g-w /var/www/html/cli
sudo chmod -R g-w /var/www/html/components/
sudo chmod -R g-w /var/www/html/includes/
sudo chmod -R g-w /var/www/html/language/
sudo chmod -R g-w /var/www/html/layouts/
sudo chmod -R g-w /var/www/html/libraries/
sudo chmod -R g-w /var/www/html/modules
sudo chmod -R g-w /var/www/html/plugins
sudo chmod -R g-w /var/www/html/templates/
sudo chmod -R g+w /var/www/html/cache
sudo chmod g-w /var/www/html/index.php
sudo chmod g-w /var/www/html/configuration.php
sudo chmod g-w /var/www/html/.htaccess

Find images not used by Joomla


# jfindfiles -- Find used and unused content files in your Joomla website
# This scripts supports Joomla versions 2.5 - 3.x
# Copyright 2014 Rene Kreijveld -
# This program is free software; you may redistribute it and/or modify it.

# Setup Vvariables

echo "Creating database dump..."

# Dump the database to a .sql file
if mysqldump --skip-opt --add-drop-table --add-locks --create-options --disable-keys --lock-tables --quick --set-charset ${database} > ${database}.sql
        echo "Database dump ${database}.sql created."
        echo "Error creating database dump."
        exit 1

echo "The following files were mentioned in your Joomla database:" > ${usedfile}
echo "The following files were NOT mentioned in your Joomla database:" > ${notusedfile}
echo "Checking for used and unused files..."

# Move into the images/stories directory
cd ${start}
# Find all files and check if they are mentioned in the database dump
for file in `find . -type f -print | cut -c 3- | sed 's/ /#}/g'`
	file2=`echo $file | sed 's/#}/ /g'`
	file3=`echo $file | sed 's/#}/%20/g'`
	result1=`grep -c "$file2" ${dbdump}`
	result2=`grep -c "$file3" ${dbdump}`
	if [[ $result1 = 0 ]]; then
		if [[ $result2 = 0 ]]; then
			echo $file2 >> ${notusedfile}
			echo $file2 >> ${usedfile}
		echo $file2 >> ${usedfile}

# Move back to the root of the website
cd ${curdir}

# Cleanup database dump
rm ${dbdump}

# Report findings
echo "Files checking done."
echo "Check the following text-files for results:"
echo "${usedfile}"
echo "${notusedfile}"