Section: Configuring an application
^ Creating an application | Creating an administration interface » |
− Table of content
You have the files of your application installed on your hard drive. Now you have to configure the application in order to access it from the web.
Note that following instructions are not specific to jelix. You can have more details by reading the documentation of apache, php, mysql, or by reading other tutorials on the web, about server configurations etc..
In this section, myapp is the name of the application. Replace this name by the name of your application.
Directories permissions ¶
You have to set write permission to the apache user at least on the myapp/var/log/
directory and on each sub-directories of the temp/
directory.
Example, on a debian/ubuntu server:
sudo chown www-data:www-data temp/myapp* myapp/var/log
sudo chmod g+w temp/myapp* myapp/var/log
For some applications, perhaps you may have to set this permissions on other folders in myapp/var/
. Read the installation manual of the application.
Configure the database access ¶
Server configuration ¶
Here is what you have to configure at server level.
Note: each time you change the configuration of your web server (like document root, php version etc,), you must delete all files in the temp directory of your applications (like temp/myapp
here), so Jelix will take care about modifications in the new configuration.
If you can change the document root ¶
If you can specify the document root of the site by modifying the configuration files of the web server or through an administration interface provided by your web hosting, indicate the mysite/myapp/www
directory as the root of the site.
For example, with apache, you will indicate in the httpd.conf
file, something like:
<VirtualHost *>
ServerName www.monsite.com
DocumentRoot /var/monsite/myapp/www/
</VirtualHost>
You must also indicate an alias towards the lib/jelix-www
directory, by naming it to "jelix" :
<VirtualHost *>
ServerName www.mysite.com
DocumentRoot /var/mysite/myapp/www/
Alias /jelix/ "/var/mysite/lib/jelix-www/"
</VirtualHost>
<Directory "/var/mysite/lib/jelix-www/">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Note : you can choose an other name for the alias of jelix-www
. If you do this, you have to change the jelixWWWPath option in the configuration file of the application.
In the file mysite/myapp/var/config/defaultconfig.ini.php
, you can adjust the basePath option, by specifying the path to the index.php
file (here : /).
basePath="/"
This setting is optional since Jelix try to discover the base path. But on complex configuration (for example, you have many entry points in different sub directories), it could not work correctly, so you have to setup this option.
Thus, by typing http:www.mysite.com you reach your site, and http:www.mysite.com/jelix/, the contents of jelix-www
, which contains a number of useful Javascript scripts, XUL resources etc.
If you can't change the document root ¶
In this case, it is better to move the content of the directory mysite/myapp/www
to the root of your site, mysite/
. After that, you have for example :
mysite/ myapp/ lib/ temp/ index.php jsonrpc.php xmlrpc.php
Here in our example, index.php
, jsonrpc.php
and xmlrpc.php
are some entry points of our application. You have to modify this three PHP files to change the relative paths they contain. Same for the testapp/application.init.php
file. For example, after modifications, the file index.php should look like this :
require_once ('myapp/application.init.php');
require_once (JELIX_LIB_CORE_PATH.'request/jClassicRequest.class.php');
$config_file = 'index/config.ini.php';
$jelix = new jCoordinator($config_file);
$jelix->process(new jClassicRequest());
You need also to modify the myapp/project.xml
file in order to update the path of each directory, so commands of jelix-scripts will work fine:
<project xmlns="http://jelix.org/ns/project/1.0">
<!-- ... -->
<directories>
<config>./var/config/</config>
<log>./var/log/</log>
<var>./var/</var>
<www>../</www>
<temp>../temp/myapp/</temp>
</directories>
<entrypoints>
<!-- ... -->
</entrypoints>
</project>
It is finally necessary to move the lib/jelix-www
directory to the root and to rename it in jelix/
. You will obtain:
mysite/ myapp/ jelix/ lib/ temp/ index.php jsonrpc.php xmlrpc.php
Note: you can choose another name for the jelix-www
directory. If you do this, you have to change the jelixWWWPath option in the configuration file of the application (myapp/var/config/defaultconfig.ini.php
)
Finally, in the file myapp/application.ini.php
, you must change JELIX_APP_WWW_PATH
to:
define ('JELIX_APP_WWW_PATH', realpath(JELIX_APP_PATH.'../').'/');
And in the file myapp/var/config/defaultconfig.ini.php
, you can change the basePath option, by specifying the path to index.php
(here : /) :
basePath="/"
You can then enter the address of your site (http:www.mysite.com for example, or http:localhost/)
Specify an extension other than .php ¶
On some servers, PHP4 and PHP5 are both proposed at the same time. In general, .php are PHP4 files and .php5 are PHP5 files. You then have to make modifications for your Jelix application to be able to use PHP5. Two ways with Apache, depending of the possibilities you have.
With .htaccess ¶
In the www directory of your application, add .htaccess
file with :
AddHandler php5-script .php
And that's all. If this doesn't work, se the following point.
With some Hosting Provider, we can also setting an environnement variable in the .htaccess
, for example:
SetEnv PHP_VER 5
If it doesn't work, read the instructions of your provider to configure PHP5, or try the following solution.
By renaming the extension ¶
You have to rename the index.php
file in index.php5
(idem for the other php files in www : jsonrpc.php
, xmlrpc.php
etc..). But you don't have to rename the php files from the other directories !
In the config file var/config/defaultconfig.ini.php
, put the extension in the urlengine
section :
entrypointExtension = .php5
Configuration for "cools" urls ¶
In order to use significants URLS with the urls automatic system of jelix, you have to activate in Apache (in its configuration file or in the .htaccess
):
Options +Multiviews
With Apache 2, you have also to do this :
AcceptPathInfo on
To verify if it is ok, create a test.php
on your site, which executes phpinfo()
. Then try this url : mysite.com/test/foo/bar
. the phpinfo should be displayed, and in the $_SERVER[’PATH_INFO’] variable (at the bottom of the page), you should see "/foo/bar".