Instructions for use on PHP on FI
First, go to our directory
/home/xlogin/public_html create a file
.htaccess (must have "r" access for others). Let's note that .php files are scripts and run as scripts:
DirectoryIndex index.php AddHandler cgi-script .php AddType application/x-httpd-php .php
In order for the PHP script to run, it must have "x" access for the owner (PHP scripts are triggered under your identity).
If you have a Web site management right on Aise, which is located elsewhere than below
/home/xlogin/public_html/ , these PHP scripts need to allow "x" access for users
apachefi , otherwise they will not work. Adding this right is ideally possible with the command
setfacl -m u:apachefi:x soubor.php
Furthermore, its first line must be a string
#!/packages/run/php/bin/php . It is not necessary to insert this string into files that do not run directly, but for example they are only inserted with
The default encoding is set for historical reasons on
ISO8859-2 . New applications should be used
UTF-8 , both for program code and for possible HTML files.
In PHP, set the encoding by adding this command to the beginning of the program:
Set HTML encoding in a file
For more information, see Encoding of Czech in documents .
Example PHP script
#!/packages/run/php/bin/php <?php ini_set('default_charset', 'UTF-8'); ?> <html> <?php echo strftime("%H:%M:%S\n"); ?> </html>
If you want to use FastCGI, edit v
DirectoryIndex index.php AddHandler fastcgi-script .php AddType application/x-httpd-php .php
FastCGI scripts are not re-launched at each request, but serve them more. This may cause an accelerated response of the application, but on the other hand not all applications are ready for this mode of use.
How to deal with problems
A useful resource for more detailed error information is the Apache logs. They can be found on the Aisa server located in
/var/log/httpd/ , specifically
error.log , eventually
When debugging errors, it is also preferable to use CGI instead of FastCGI. The error logs are then clearer, and running the script over the web is more responsive.
The PHP script should also be directly executable on the command line. Correct Output Example:
aisa:/home/xlogin/public_html>$ ./index.php X-Powered-By: PHP/5.6.30 Content-type: text/html; charset=UTF-8 <html> 10:04:01 </html>
Examples of possible errors in case of unsuccessful startup
-bash: ./index.php: Permission denied
The PHP script apparently does not allow "x" access for the owner.
-bash: ./index.php: /packages/run/php/bin/php^M: bad interpreter: No such file or directory
The PHP script has DOS line breaks. Unix line breaks can be converted to a utility
Premature end of script headers(in
Check the header
Content-typeyou are listing correctly and followed by a blank line.
Security of error logs
Since error logs are accessible to all users for reading, logging of some PHP errors can pose a security risk. These are, for example, messages containing access data.
In this case, you can consider logging errors into your own file. This can be accomplished by creating your own PHP configuration file
user.ini , which you place in the directory
public_html . This file should have at least the "r" access right for the owner and should contain a line
error_log = /home/xlogin/php.log
Consequently, the error messages should be logged in the file. Of course, it is advisable to secure this file before accessing other users. Therefore, we recommend that you create this file manually with the appropriate permissions, otherwise you will be created with read permissions when writing the first error. At a minimum, the "w" right for the owner and the file path should be accessible to you - Logging takes place again under your identity. Alternatively, if the directory in which you want to save this file is accessible only to you (right "x" for the owner), you can create the file automatically.