Table of Contents

PHP 7.4 macOS installation

install packages

brew install php@7.4 nginx postgresql@12
# pecl install zip libsodium
# remove duplicated extension added in /usr/local/etc/php/7.4/php.ini
brew link php@7.4
brew link postgresql@12

setup postgres

# init db
initdb -D /Users/dcai/.local/var/postgres12
# start db
postgres -D ~/.local/var/postgres12/
echo "ALTER USER postgres WITH PASSWORD 'postgres';" | psql -U postgres

update php fpm config

/opt/homebrew/etc/php/7.4/php-fpm.d/www.conf

[www]
user = _www
group = _www
listen = 127.0.0.1:9991
pm = ondemand
pm.max_children = 5

php_admin_flag[log_errors] = on
php_admin_flag[display_errors] = on

php_admin_value[memory_limit] = 1G
php_admin_value[upload_max_filesize] = 100M
php_admin_value[post_max_size] = 100M
php_admin_value[max_input_vars] = 5000
php_admin_value[max_file_uploads] = 20
php_admin_value[date.timezone] = Australia/Sydney
php_admin_value[error_log] = /tmp/phperror.log

update nginx config

/opt/homebrew/etc/nginx/nginx.conf

worker_processes  1;
error_log  /tmp/nginx-error.log;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       8080;
        server_name  localhost;

        location / {
            root   /Users/dcai/moodles/www;
            index  index.php index.html index.htm;
        }

        location ~ [^/]\.php(/|$) {
            root   /Users/dcai/moodles/www;
            fastcgi_split_path_info  ^(.+\.php)(/.+)$;
            fastcgi_index            index.php;
            fastcgi_pass             127.0.0.1:9991;
            include                  fastcgi_params;
            fastcgi_param   PATH_INFO       $fastcgi_path_info;
            fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    }
    include servers/*;
}