As the main language for web program development, php is widely used. As a statistical software, R has good operability in the implementation of mathematical algorithms. Recently, due to work needs, I have to perform complex mathematical calculations on some web application data. However, although PHP itself can write some mathematical algorithms, it is still difficult to meet the demand. The efficiency of dozens of lines of code is not comparable to a function in R.
Use .user.ini file to modify open_basedir to enhance PHP system security
.user.ini is an lnmp file, which contains the folder path address of the website. The purpose is to prevent cross-directory access and cross-directory reading of files. In a certain sense, it ensures potential security issues that may be caused by unknown PHP code. .
The configuration is placed in the root directory .user.ini
open_basedir=/project path/:/tmp/:/proc/
example:
PHP program to automatically backup files to Tencent COS
Download the official SDK: https://github.com/tencentyun/cos-php-sdk-v5/releases
Upload procedure:
Add HTTP authentication code to PHP page
// Digest HTTP Authentication // To enable, add user: "name" => "password". //$users = array(); $users = array(""=>""); // If auth is enabled: if (!empty($users)) { if (empty($_SERVER['PHP_AUTH_DIGEST'])) { header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Digest realm="' . $realm . '",qop="auth",nonce="' . uniqid() . '",opaque="' . md5($realm) .
Problem with relative references in cron regularly executing php program in shell environment
Under the Linux system, using cron to execute PHP programs regularly is a convenient way to deal with it. I recently tested a PHP script and the browser called and debugged everything normally. So I configured the shell timing, but the next day I found that nothing was saved in the database... ...Looking at the error log, it was said that there was an error in a certain line of PHP. I checked this line of code and found that it was a relative reference. This script had also been executed regularly before. The executed program and the referenced file were in the same folder.