- Joomla 1.5
- Apache 2.2
- MySQL 5.1
- Ubuntu 8.04 Hardy Heron server edition
The instructions may apply for other versions too.
1. Prerequisitements
What you need to have in order to use this how to
- Basic UNIX file permissions knowledge
- Basic UNIX shell knowledge
- You have a Linux server (Ubuntu / Debian) for which you have root user access and you plan to use this server to host one or several Joomla! sites
- Apache and MySQL instaleld on your server
User setup
2. Set-up an UNIX user on a dedicated server for Joomla! hosting. The user can SSH in the box and write to his home folder, /tmp and /var/www site folder.
We create a user called “user” in this instructions. Replace it with the username you desire. We also use the example site name (www).yoursite.com.
sudo adduser user # Asks for the password and created /home/user
sudo mkdir /var/www/user sudo chmod -R user:user /var/www/user # Only user has writing access to this folder
3. Setup MySQL user account
Install MySQL as per Debian/Ubuntu instructions.
Login as MySQL admin user (may vary depending how your MySQL is configured). Note that first you will be asked for sudo password, then for MySQL administrative user password.
sudo mysql -u admin -p
CREATE DATABASE user DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON user.* TO 'user'@'localhost' identified by 'zxc123zxc';
4. Extract Joomla! installation files
Enter the folder which will contain web site PHP files.
sudo -i -u user # pose yourself as UNIX user who runs the site
cd /var/www/user
wget http://joomlacode.org/gf/download/frsrelease/12350/51111/Joomla_1.5.18-Stable-Full_Package.zip
unzip Joomla_1.5.18-Stable-Full_Package.zip
Exit posing yourself as user UNIX user.
exit
5. Set file permission
- Configuration files and upload directory must be writable by Apache user (www-data for Ubuntu/Debian, httpd for Fedora/Red Hat)
- Other .php files should be read-only
Note that during Joomla’s browser based installation Apache’s www-data must have write access to folder in order to create configuration.php file. We will later remove this access right.
We will set Joomla! files under UNIX group group www-data so that Apache can read them. Certain files are set to be writable. This must be done as root user.
sudo chown -R user:www-data /var/www/user # Make user group to www-data
sudo chmod g+wrx /var/www/user # Read only access to www-data user. Write access for installation, will be later removed.
Now ls -l command in /var/www/user should give you something like this for fil masks:
drwxr-xr-x 11 user www-data 4096 2010-05-28 10:22 plugins -rwxr--r-- 1 user www-data 304 2010-05-28 10:21 robots.txt drwxr-xr-x 6 user www-data 4096 2010-05-28 10:22 templates
6. Creating Apache configuration
sudo nano /etc/apache2/sites-enabled/yoursite.conf
ServerName yoursite.com ServerAlias www.yoursite.com ServerAdmin info@yourcompany.com LogFormat combined TransferLog /var/log/apache2/yoursite.log # Make sure this virtual host if capable of executing PHP5 Options +ExecCGI AddType application/x-httpd-php .php .php5 # Point to www folder where Joomla! is extracted DocumentRoot /var/www/yoursite # Do not give illusion of safety # as PHP safe_mode really is a crap # and only causes problems php_admin_flag safe_mode off # # This entry will redirect traffic www.yoursite.com -> yoursite.com # Assume mod_rewrite is installed and enabled on Apache # 301 is HTTP Permanent Redirect code RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC] RewriteRule (.*) http://yoursite.com$1 [L,R=301] </VirtualHost>
7. Faking the DNS entry
sudo gedit /etc/hosts
# Force this hostname to go to your server public IP address from your local computer
123.123.123 yoursite.com www.yoursite.com
8. Start Joomla! browser based installation
http://yoursite.com
- Fill in MySQL database values as created before.
- If you plan to use SSH for file transfer do not enable FTP layer (unsecure).
- Use a random password as Joomla! administrator user and store it somewhere in safe.
- When Joomla! browser based installation goes to the point it asks you to remove the installation directory follow the instructions below.
Secure the configuration
sudo chmod -R g-w /var/www/user # Remote write permission sudo rm -rf /var/www/user/installation # Remove installation directory # Add write permission to folders which contain writable files sudo chmod -R g+x /var/www/user/logs sudo chmod -R g+x /var/www/user/images sudo chmod -R g+x /var/www/user/tmp sudo chmod -R g+x /var/www/user/images
9. Setting up htaccess files
Joomla! comes with a sample htaccess file which has some security measurements by having RewriteRules to prevent malformed URL access.
To install this file do the following
sudo -i cd /var/www/user cp htaccess.txt .htaccess chmod user:www-data .htaccess # Set file permission to be readable by Apache and writable by the UNIX user
Then we create a .htaccess file which we will place in all folders with Joomla! write access to prevent execution of PHP files in these folders. First we create htaccess.limited file which we use as a template.
sudo -i cd /var/www/user nano htaccess.limited # Open text editor
Use the following htaccess.limited content
# secure directory by disabling script execution AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi Options -ExecCGI -Indexes
And put the master template htaccess.limited to proper places
cp htaccess.limited media/.htaccess chown -R user:www-data media/.htaccess cp htaccess.limited tmp/.htaccess chown -R user:www-data tmp/.htaccess cp htaccess.limited logs/.htaccess chown -R user:www-data logs/.htaccess cp htaccess.limited images/.htaccess chown -R user:www-data images/.htaccess
10. Start using the site
11. Setting outgoing email
11. Test outgoing email
12. Maintaining file permission
- UNIX user: user (your site username)
- UNIX group: www-data
sudo usermod -a -G www-data user # Add user to www-data group so that it can set group permissions
sudo -i -u user # Login as your UNIX user chgrp -R www-data templates libraries # Fix group ownership chmod -R g+rx libraries templates # Set read access for the group
Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+