Loading...
 

InstallTikiUnderSafeMode

By Markku Niskanen)

Installing Tiki without Linux root rights

Background


The problem with many PHP applications is that one needs very strong rights to be able to install, configure and finally run them. They may work fine when you install them into your own Linux box but if you install them to a web hotel you may face problems like:

  • You have no access to the Apache httpd.conf file
  • You cannot access PHP files outside your own directory which may be, for instance /home/customers/acmecorp/
  • Some necessary libraries are installed to root owned, unaccessible directories, for instace /usr/lib/php/
  • With safe_mode enabled you cannot create directories from within your PHP application.
  • You or your customer will only have access to one MySQL database, for istance acme_db, you cannot create more


Assumptions for the rest of the discussion The rest of the document makes some assumptions about the installation directories and the rest of the environment. Please make sure you understand where to install the libraries in your environment before even trying to do that.

  • The main assumption is that you have SSH or Telnet access to your ISP. Without one you cannot do much.
  • The actual company home directory for our example installation is /home/customers/acmecorp
  • The actual public_html directory will thus be /home/customers/acmecorp/public_html
  • The ISP has turned PHP safe_mode on to improve security
  • The files from mode directory own are owned by user/group acme/acme
  • You have access to MySQL database acme_db with username/password acme/acme1234
  • The DNS name of the MySQL server is mysql.myhost.com (not "localhost").
  • The PEAR modules are unavailable (you will need PEAR and PEAR::DB)

Checking if something is actually wrong


Copy the following lines and save the test application to your public_html directory naming it "peartest.php":

<?
require_once("DB.php");
require_once "PEAR.php";

echo ("<h3>Swoobadoo</h3>");

?>

insert peartest.php

Now test whether you can run the application, pointing your browser to it. If you see the message
Swoobadoo

then you will probably not have any problems with PEAR. You can jump directly to the Tiki installation section.

However, if you get warnings about "Safe mode restrictions", you will need to install a local copy of PEAR. Also, if you get a message telling that DB.php cannot be found, you will need to install a local copy of PEAR.

Installing the PEAR stuff locally

Only do this step for 1.7.x Tiki's.

1.8 onwards uses ADODB instead of PEAR continue down to "The Tiki installation"

I have found two types of Apache installations: With the good one the restrictions are friendly and you can change the PHP include path using .htaccess files. With the bad one you must hand-code a few paths but it will work, anyhow.

First some basic stuff you need to do whatever installation method you must use. For the sake of simplicity we will install PEAR to directory php under our public_html directory, the actual path will be /home/customers/acmecorp/public_html/php

You will need to find the PEAR sources, download them decide where you want to install it.

If you find out that the files have by chance been installed by the web hotel owner you can copy the directory from the root owned directory, if you are allowed to do so. If not, you can fetch a zipped copy from the PEAR website and unzip the package to your public_html directory.

After unzipping the files make sure that you have the correct ownwership for the files. Just to make sure this is the case go to the public_html directory and give two commands:
chown acme php --recursive
chgrp acme php --recursive

The above may not be necessary, however but does no harm, either.

The easy case


The easiest way to get access to the PEAR classes is use the .htaccess file in your application directory.

Add the following line to the .htaccess file (if the file does not exist, create it):
php_value include_path .:/home/customers/acmecorp/public_html/php

That's all. Now you can re-run the peartest.php page and if it works now you are done with the PEAR installation and can continue with Tiki.

The handmade way


If the .htaccess method did not work you must make a couple of small changes to the PEAR files. There are several ways to do this, here is one of them. Let's start with DB.php. Find the following line in the code:
require_once "PEAR.php";
and replace it with these two lines:
$peardir="/hode> $peardir="/home/customers/acmecorp/public_html/php/ ";
require_once $peardir."PEAR.php";

Then find all lines that are trying to include the MySQL module:
include_once "DB/${type}.php"
and replace them with
include_once $peardir."DB/${type}.php";

Also, add the following line to the beginning of the functions that are affected (at least functions &connect and &factory);
global $peardir;

Now you will need to make one more modification. Replace the require_once stuff in file "DB/mysql.php" as follows:
$peardir="/home/customers/acmecorp/public_html/php/";
require_once $peardir."DB/common.php";

Testing the PEAR installation


Point your browser once more to "peartest.php" and load it. If you see no errors but can see the "Swoobadoo" then your installation is succesful.

The Tiki installation


If you have made things work so far the rest will be a lot easier. So you need to do the following (from the command prompt):

Unzip the Tiki stuff to your public_html directory. You should find the directory structure there starting from tiki/.

Remember that our problem was the lack of root access to our MySQL and we only have one database available and we cannot create another. Therefore we must tell Tiki to use that very database and run a bit more complicated (or accurate) creation script.

Go to your tiki/db directory and edit the tiki-db.php file as follows:
// if you used the handmade way (.htaccess did not work) then
// uncomment the following line and comment the line after it

//require_once('/home/customers/acmecorp/public_html/php/DB.php');
require_once('DB.php');

// Often MySQL is being run in another server, check your situation!
$host_tiki ='mysql.myhost.com';
$user_tiki = 'acme';
$pass_tiki = 'acme1234';
$dbs_tiki = 'acme_db';

Now you can run the sql creation script in the same directory. I prefer to do this in the MySQL command prompt:
mysql -p -h mysql.myhost.com -d acme_db --user acme

Enter your password and when you are in the MySQL command prompt enter
source tiki.sql

You should now see some 75 messages about the creation of tables but no error messages. After the script has finished enter
show tables

If you see the following table listing you have succeeded in creating the tables and you can quit the command prompt:
+-------------+
| Tables |
+-------------+
| tiki_actionlog |
| tiki_articles |
| tiki_banners |
| tiki_blog_activity |
etc.

Configuring Smarty safe_mode friendly


You will need to edit the Smarty/Smarty.class.php file as well. As we are running our stuff in safe_mode we cannot create subdirectories and you will need to find the subdirectory creation flag in the file and change it to false:
var $use_sub_dirs = false; // use sub dirs for cache and compiled files?
// sub directories are more efficient, but
// you can set this to false if your PHP environment etc...

After this you should be able to open Tiki using your regular browser. The rest of the stuff can be found in the Tiki manual and will not be covered here.

Open Basedir tweaks


If you have some restrictions in the php config open_basedir (see phpinfo from your admin page), you probably have to tweak tiki, if the include_path is set to a directory outside the open_basedir paths, or if the session.save_path is set to outside the open_basedir paths.

Add these lines to tiki-install.php, tiki-setup.php, topic_image.php, tiki-download_file.php and show_image.php just after the first line:

ini_set('include_path','.');

and if this does not fix your problems, try to add this line too:

ini_set('session.save_path','/some/dir/where/u/can/write/');

redflo

If you still have the same problem with the tweaks suggested above you should try to modify the lib/init/initlib.php
like this page says. Thanks to xavi on #tikiwiki for this hack.


magowiz


-

Installing 1.8.2 under safe mode


I just tried to install a 1.8.2 on a server4free.de host (it's not free, even if the name would mention it). On this host there is a confixx that sets safe_mode and a open_basedir restriction for every virtual host. This is waht i did:

setup_smarty.php:
Lines 22 look like:

function Smarty_TikiWiki($tikidomain = "") {
$this->use_sub_dirs = false;
$this->template_dir = "templates/";
$this->compile_dir = "templates_c/$tikidomain";


tiki-setup.php:
Lines 47 look like

//if (!is_dir($save_path)) {
// $errors .= "The directory '$save_path' does not exist or PHP is not allowed to access it (check open_basedir entry in php.ini).\n";
//} else
// if (!is_writeable($save_path)) {
// $errors .= "The directory '$save_path' is not writeable.\n";
// }

tiki-setup_base.php:
Line 27 looks like:

// ini_set('url_rewriter.tags', '');


This worked for me. If it doesn't work for you, meet tiki-experts at irc #tikiwiki at freenode.net.
redflo


-

Installing 1.8.3 or newer under safe mode


Since i included all changes from the previous section - with some additional checks - tiki should now install without problems in safe mode. If the tiki-installer comes up with a blank page, make sure, that all php scripts have the same owner. This can happen if you install tiki as root with the setup.sh script.

Have fun!

redflo


Page last modified on Sunday 18 May 2008 17:27:34 GMT-0000

Upcoming Events

1)  21 Mar 2024 18:00 GMT-0000
Tiki Roundtable Meeting
2)  25 Mar 2024 17:00 GMT-0000
29th anniversary WikiBirthday (With Ward Cunningham)
3)  18 Apr 2024 18:00 GMT-0000
Tiki Roundtable Meeting
4)  16 May 2024 18:00 GMT-0000
Tiki Roundtable Meeting
5)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
8)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9) 
Tiki birthday
10)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting