Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
php:macos-installation [2021-10-28] dcaiphp:macos-installation [2021-10-31] (current) dcai
Line 1: Line 1:
 +===== PHP 7.4 macOS installation =====
 +
 +
 +==== install packages ====
 <code> <code>
-# fish shell +brew install php@7.4 nginx postgresql@12 
-brew install php@7.4 nginx +pecl install zip libsodium
-pecl install zip libsodium+
 # remove duplicated extension added in /usr/local/etc/php/7.4/php.ini # remove duplicated extension added in /usr/local/etc/php/7.4/php.ini
 +brew link php@7.4
 +brew link postgresql@12
 </code> </code>
  
-== update nginx config == 
  
-''/opt/homebrew/etc/nginx/nginx.conf''+==== setup postgres ==== 
 +<code> 
 +# 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 
 +</code>
  
 +==== update php fpm config ====
 +
 +''/opt/homebrew/etc/php/7.4/php-fpm.d/www.conf''
 <code> <code>
 +[www]
 +user = _www
 +group = _www
 +listen = 127.0.0.1:9991
 +pm = ondemand
 +pm.max_children = 5
  
-#user  nobody; +php_admin_flag[log_errors] = on 
-worker_processes  1;+php_admin_flag[display_errors] = on
  
-error_log  /tmp/nginx-error.log;+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 
 +</code>
  
-#pid        logs/nginx.pid;+==== update nginx config ====
  
 +''/opt/homebrew/etc/nginx/nginx.conf''
 +
 +<code>
  
 +worker_processes  1;
 +error_log  /tmp/nginx-error.log;
 events { events {
     worker_connections  1024;     worker_connections  1024;
 } }
- 
  
 http { http {
     include       mime.types;     include       mime.types;
     default_type  application/octet-stream;     default_type  application/octet-stream;
- 
-    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ' 
-    #                  '$status $body_bytes_sent "$http_referer" ' 
-    #                  '"$http_user_agent" "$http_x_forwarded_for"'; 
- 
-    #access_log  logs/access.log  main; 
- 
     sendfile        on;     sendfile        on;
-    #tcp_nopush     on; 
- 
-    #keepalive_timeout  0; 
     keepalive_timeout  65;     keepalive_timeout  65;
- 
-    #gzip  on; 
- 
     server {     server {
         listen       8080;         listen       8080;
         server_name  localhost;         server_name  localhost;
- 
-        #access_log  logs/host.access.log  main; 
  
         location / {         location / {
             root   /Users/dcai/moodles/www;             root   /Users/dcai/moodles/www;
             index  index.php index.html index.htm;             index  index.php index.html index.htm;
-        } 
- 
-        #error_page  404              /404.html; 
- 
-        # redirect server error pages to the static page /50x.html 
-        # 
-        error_page   500 502 503 504  /50x.html; 
-        location = /50x.html { 
-            root   html; 
         }         }
  
Line 72: Line 79:
             fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;             fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
         }         }
- 
-        # deny access to .htaccess files, if Apache's document root 
-        # concurs with nginx's one 
-        # 
-        #location ~ /\.ht { 
-        #    deny  all; 
-        #} 
     }     }
- 
- 
-    # another virtual host using mix of IP-, name-, and port-based configuration 
-    # 
-    #server { 
-    #    listen       8000; 
-    #    listen       somename:8080; 
-    #    server_name  somename  alias  another.alias; 
- 
-    #    location / { 
-    #        root   html; 
-    #        index  index.html index.htm; 
-    #    } 
-    #} 
- 
- 
-    # HTTPS server 
-    # 
-    #server { 
-    #    listen       443 ssl; 
-    #    server_name  localhost; 
- 
-    #    ssl_certificate      cert.pem; 
-    #    ssl_certificate_key  cert.key; 
- 
-    #    ssl_session_cache    shared:SSL:1m; 
-    #    ssl_session_timeout  5m; 
- 
-    #    ssl_ciphers  HIGH:!aNULL:!MD5; 
-    #    ssl_prefer_server_ciphers  on; 
- 
-    #    location / { 
-    #        root   html; 
-    #        index  index.html index.htm; 
-    #    } 
-    #} 
     include servers/*;     include servers/*;
 } }
 +
 </code> </code>
php/macos-installation.1635410752.txt.gz · Last modified: by dcai