Langsung ke konten utama

How to run PHP in nginx and fix the errors

first you gonna need to backup the conf file in order when you did something wrong, who knows tho?

and then edit them;
dunno wheres the config file located?
just run nginx -t and it will show you wheres the conf file and its content.
now just edit it with the following:

put root YOUR_INDEX_ROOT; at the top and inside of http { params
the purpose is to set it as global root directory.
and within location ~ \.php$ { edit with the following params:
try_files $uri =404; # try to find the file, if fail throw 404 error
            #root           /data/data/com.termux/files/home/sdcard/www; # this is the root dir of php files
            fastcgi_pass   unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock; # pass every php file to this server
            fastcgi_index  index.php; # the index file name
            #fastcgi_split_path_info ^(.+\.php)(/.+)$; # ?
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; # param for fastcgi to find the script
            include        /data/data/com.termux/files/home/sdcard/www/nginx/fastcgi_params;
        }

okay then save it and if everything's fine you can run php-fpm by just type php-fpm and hit enter in terminal.

note:
you can also set the fastcgi_pass value to a server addr.
but it seems that php-fpm always use socket file in the first place rather than a server addr.

Komentar

Postingan populer dari blog ini

how to install postgresql and use it with php on termux

first of all you need to install it: apt install postgresql then specify data dir for it by typing: initd -D YOUR_DATA_DIR example YOUR_DATA_DIR is /data/data/com.termux/files/home/mydb note that you don't need to make the dir first, you just need the dir name then initdb will create it automatically :) in this example like this: initdb -D /data/data/com.termux/files/home/mydb The files belonging to this database system will be owned by user "u0_a171". This user must also own the server process. The database cluster will be initialized with locale "C.UTF-8". The default text search configuration will be set to "english". Data page checksums are disabled. creating directory test ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... sysv selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default time zone ... Asia/Jakarta creating configuration files

How to fix Apache httpd error: [:crit] [pid xxxx] (2)No such file or directory: AH00141: Could not initialize random number generator

How to fix Apache httpd error: [:crit] [pid xxxx] (2)No such file or directory: AH00141: Could not initialize random number generator. This error might be offen happen when using chroot  and no urandom in /dev folder of your chroot dir. Simply just mount the /dev folder to your chroot dir: mount -o bind /dev $chroot_dir/dev/ Then test it: httpd -v Server version: Apache/2.4.34 (Unix) Server built: Jul 19 2018 03:32:51