Trikks

The digital adventures of Eric Herlitz

Archive for October, 2009

SEF with Joomla on one.com

Posted by trikks on October 26, 2009

This guide is manly written to work with one.com hosted Joomla installations. However it’s most likely that it will work on almost any web hosting service.

Using SEF links (Search engine friendly) with Joomla is a really neat feature. The basic idea is to create human readable address links. So, instead of having your links looking like this

http://www.yoursite.com/index.php?option=com_content&view=article&id=4&Itemid=8

They could look like this

http://www.yoursite.com/products/ncb

Setting up the .htaccess

First, create a file called htaccess.txt, or use the one shipped with Joomla. Paste the following code into the file.

#The line below must(!) be commented out on one.com
#It may not be required if you use another web hosting service
#Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

Now, upload it to your web root (the same place where you keep your website) and rename the htaccess.txt to .htaccess

Setting up Joomla

Use the admin panel. Navigate to the Global Configuration » Site.

Make your SEO Settings look like this

Joomla SEO config

Joomla SEO config

Thats it!

Posted in Joomla | Tagged: , , , | 3 Comments »

Downgrading PHP 5.3.0 to 5.2.11 on Snow Leopard Server

Posted by trikks on October 7, 2009

Many thanks to Jeff Seibert for his excellent guide, however it needs some clarifications and extra info for newbies.

1. Check that you need this

Open a console and enter

$php --version

If the reply is similar to this

PHP 5.3.0 (cli) (built: Jul 19 2009 00:34:30)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

then you can proceed. Otherwise, don’t.

2. Install Xcode on your server

If not installed, install it from the “other installs” folder of your Snow Leopard DVD or via Apple’s site.

3. Install the “Snow Leopard” version of MacPorts from macports

Go to this webpage and get the Snow Leopard package.

Install it.

4. Open the terminal, or ssh

$sudo port -v selfupdate
$sudo port -f uninstall installed
$sudo port install php52 +mysql5 +sqlite
$sudo cp /opt/local/etc/php5/php.ini-dist /opt/local/etc/php5/php.ini

These commands may take some time, easily up to an hour if you have an older system.

5. Change some setting files

Edit /etc/apache2/httpd.conf and change

# Here is a suggested series of commands
# I use nano, you may use other text editors as well
$sudo nano /etc/apache2/httpd.conf

# Press control + w to search (with nano)
# In my file this is line 152, but this may vary
Search: LoadModule php5_module

# Change
libexec/apache2/libphp5.so
# To
/opt/local/apache2/modules/libphp5.so

Edit /opt/local/etc/php5/php.ini

$sudo nano /opt/local/etc/php5/php.ini

# If the file doesn't exist there is another one
$sudo cp /opt/local/etc/php5/php.ini-recommended /opt/local/etc/php5/php.ini

# Find and change
mysql.default_socket =
# To
mysql.default_socket = /var/mysql/mysql.sock

6. Restart the web service

With the Server Admin tool, the sharing pane in system preferences or

$sudo serveradmin stop web && sudo serveradmin stop mysql
$sudo serveradmin start web && sudo serveradmin start mysql

Or use the serviceRestart for a more complete reset of the server.

7. Check the results

$ php --version
PHP 5.2.11 (cli) (built: Oct  7 2009 03:34:39)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

Posted in Mac OS X | 95 Comments »

Restart all running services in OS X Server

Posted by trikks on October 2, 2009

In some Linux distributions it’s possible to restart all running services by typing

$/sbin/services.sh restart

This guide will help you to create an equivalent command in OS X Server. This should work on pretty much any OS X server version, but I have only tested it in Leopard Server and Snow Leopard Server.

First things first

Start by creating the script, I prefer nano but pretty much any text editor will do

$nano ~/Documents/serviceRestart

Paste this text into the script

# /bin/sh
echo "--- Script start ---"

# Create the array
services=( $(sudo serveradmin list) )

# Make the masterloop
for eachService in ${services[@]}; do

  # Check the status of the current service listed in the array
  tc=$(sudo serveradmin status $eachService | grep -io "RUNNING")

  # If the service is running, then restart it, we wont touch other services
  if [ "$tc" = "RUNNING" ]; then
    echo $i $eachService "(RUNNING)"
    sudo serveradmin stop $eachService && sudo serveradmin start $eachService
  fi

done
echo "--- Script end ---"
# /bin/sh
"--- Script start ---"

dd execute rights to the script

$sudo chmod +x ~/Documents/serviceRestart

And link the script into /usr/bin for easy execution

$sudo ln -s ~/Documents/serviceRestart /usr/bin/

Running the script

Open the terminal and enter

serviceRestart

The sudo command inside the script might ask for your password. This is normal.

Good luck!

Posted in Mac OS X | 6 Comments »

 
Follow

Get every new post delivered to your Inbox.