Chapter: Server configuration
« Creating an application | ^ Getting started | Using jelix scripts » |
− Table of content
In this chapter we'll see how to configure your web server.
If you install your application on a machine that you cannot configure, you propably want to modify the directories hierarchy so you won't have to configure the document root on the server. See then the chapter about directory changes.
About PHP configuration ¶
The minimal version of PHP is 5.6. PHP 7 or 8 is highly recommended.
Please refer to the PHP documentation to know how to install it.
About temporary files of Jelix ¶
Each time you modifiy the server configuration (like document root, php version etc...) or you
update your application, you must delete all temporary files generated by Jelix (stored into
myapp/temp/
for example), so Jelix can take care about the new environment parameters to
generate config files and other temporary files.
Example :
sudo rm -rf myapp/temp/*
Server configuration ¶
The main thing to configure into the web server is to indicate the root directory of your
web site that contain files accessible from a browser. In the case of a Jelix application, this
is the www/
directory. You can indicate it by modifying configuration files of the web server,
or by using the web interface provided by some hosting vendor.
The content of lib/jelix-www/
should also be accessible from the web, through the path
jelix/
. Since Jelix 1.7, by default, its content is copied into the www/ directory
of the application. If this is not the case, you should set an alias in the server
configuration, or a symbolic link in the www/
directory.
Jelix needs to receive a "pathinfo" in the url: this is a path after a script file. The web server should then be configured to support pathinfo.
With Apache, this is the @Multiview,
AcceptPathInfo or
MultiviewsMatch@@ option,
depending of the version of Apache.
With Nginx, you have to use the fastcgi_split_path_info
, fastcgi_param PATH_INFO
and fastcgi_param PATH_TRANSLATED
parameters.
In next section, we expect you have installed your application myapp/
into /srv/mysite/
.
Configuration with Apache ¶
In a mysite.com.conf
file, you set the configuration like this:
<VirtualHost *>
ServerName www.mysite.com
# ----- Root of the web site
DocumentRoot /srv/mysite/myapp/www/
<Directory "/srv/mysite/myapp/www/">
AllowOverride None
Order allow,deny
Allow from all
# For the PathInfo
Options +Multiviews
AcceptPathInfo on
# comment this line if you use Apache 2.2 or lower
Require all granted
</Directory>
# set a jelix alias, if there is no directory myapp/www/jelix
# ----- "jelix" alias to jelix-wwww if jelix is installed with Composer
Alias /jelix/ "/srv/mysite/myapp/vendor/jelix/jelix/lib/jelix-www/"
<Directory "/srv/mysite/myapp/vendor/jelix/jelix/lib/jelix-www/">
AllowOverride None
Order allow,deny
Allow from all
# comment this line if you use Apache 2.2 or lower
Require all granted
</Directory>
# ------ "jelix" alias to jelix-wwww if jelix is NOT installed with Composer
#Alias /jelix/ "/srv/mysite/lib/jelix-www/"
#<Directory "/srv/mysite/lib/jelix-www/">
# AllowOverride None
# Order allow,deny
# Allow from all
# Require all granted # comment this line if you use Apache 2.2 or lower
#</Directory>
</VirtualHost>
About the pathinfo, for Apache 2.4 and higher, in a file in conf.d/
or conf-enabled/
,
you have to add this configuration:
RemoveType .php
<Files "*.php">
MultiviewsMatch Any
</Files>
Configuration with Nginx ¶
With Nginx, most of time you are using PHP-FPM, and so parameters specific to fastcgi. You'll
define also the root directory and an alias for the jelix/
URL.
Example:
server {
listen 80;
server_name www.mysite.com;
index index.html index.php;
root /srv/mysite/myapp/www;
location / {
root /srv/mysite/myapp/www;
try_files $uri $uri/ =404;
}
# remove it if there is a myapp/www/jelix directory
location /jelix/ {
alias /srv/mysite/myapp/vendor/jelix/jelix/lib/jelix-www/;
#ou pour une installation Sans composer:
#alias /srv/mysite/lib/jelix-www/;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
# because of bug http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param PATH_INFO $path_info;
fastcgi_param PATH_TRANSLATED $document_root$path_info;
include fastcgi.conf;
}
}
Verifying the configuration ¶
With your browser, try to access to your application with http://www.mysite.com
but also
try to access to a file from jelix-www/
, for example
http://www.mysite.com/jelix/design/jelix.css
.
To verify that pathinfo is supported, 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".
Settings into the Jelix configuration ¶
Changing the name of the alias to jelix-www ¶
You can choose an other name for the alias of jelix-www
. If you do this, you have to
change the jelixWWWPath option into the section urlengine
of the configuration file
var/config/localconfig.ini.php
or app/system/mainconfig.ini.php
.
Specifying the basePath ¶
In the file myapp/var/config/mainconfig.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 it may not work correctly, so you have to setup this option. It appears in this cases:
- you have several entry points in different sub-directories
- there is an alias to
myapp/www
.
Example with an alias /superapp/
to myapp/www
:
basePath="/superapp/"
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 myapp/temp/ myapp/var/log
sudo chmod g+w myapp/temp 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.