{"id":14955009,"url":"https://github.com/digitoimistodude/macos-lemp-setup","last_synced_at":"2025-10-28T17:12:32.007Z","repository":{"id":41092025,"uuid":"97226384","full_name":"digitoimistodude/macos-lemp-setup","owner":"digitoimistodude","description":"Installation script for enabling macOS baked-in LEMP stack","archived":false,"fork":false,"pushed_at":"2025-03-25T12:35:48.000Z","size":229,"stargazers_count":66,"open_issues_count":0,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T15:39:45.205Z","etag":null,"topics":["config","configuration","lemp","local-development","mac","macos","mariadb","mariadb-server","mysql","mysql-server","nginx","nginx-configuration","osx","php","php-fpm","php-fpm7","php7","server","wordpress-development"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitoimistodude.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-14T11:18:34.000Z","updated_at":"2025-03-25T12:35:52.000Z","dependencies_parsed_at":"2024-01-08T14:50:18.549Z","dependency_job_id":"6f3e5521-c0b8-4e50-b5bb-41f532776b4a","html_url":"https://github.com/digitoimistodude/macos-lemp-setup","commit_stats":{"total_commits":96,"total_committers":7,"mean_commits":"13.714285714285714","dds":"0.26041666666666663","last_synced_commit":"839985e963f0a857b3297c3c10732e64937a7e0b"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitoimistodude%2Fmacos-lemp-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitoimistodude%2Fmacos-lemp-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitoimistodude%2Fmacos-lemp-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitoimistodude%2Fmacos-lemp-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitoimistodude","download_url":"https://codeload.github.com/digitoimistodude/macos-lemp-setup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557768,"owners_count":20958047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","configuration","lemp","local-development","mac","macos","mariadb","mariadb-server","mysql","mysql-server","nginx","nginx-configuration","osx","php","php-fpm","php-fpm7","php7","server","wordpress-development"],"created_at":"2024-09-24T13:10:22.998Z","updated_at":"2025-10-20T06:37:36.958Z","avatar_url":"https://github.com/digitoimistodude.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LEMP: Local Environment Made Powerful \n[![Build](https://github.com/digitoimistodude/macos-lemp-setup/actions/workflows/build.yml/badge.svg)](https://github.com/digitoimistodude/macos-lemp-setup/actions/workflows/build.yml) [![GitHub release](https://img.shields.io/github/tag/digitoimistodude/macos-lemp-setup.svg)](https://github.com/digitoimistodude/macos-lemp-setup/releases) ![GitHub contributors](https://img.shields.io/github/contributors/digitoimistodude/macos-lemp-setup.svg) ![PHP](https://img.shields.io/badge/PHP-8.3-7a86b8)\n\nJust kidding, it's really **Linux + nginx [engine x] + MySQL + PHP-FPM**, that's where the LEMP comes from. MacOS LEMP Setup is just like Local by Flywheel or XAMPP, WAMP, Hammer, Anvil etc. tools like this, but it concentrates on the native way of running a web server just by using native Linux packages ported for macOS via Homebrew. It's always fast, always on.\n\n## LEMP on other systems\n\n- [Windows version](https://github.com/digitoimistodude/windows-lemp-setup)\n- [Linux version](https://github.com/raikasdev/pop-lemp-setup)\n\n## Still the best way to locally develop WordPress.\n\n![macos-lemp](https://user-images.githubusercontent.com/1534150/159696251-1b8adbee-f752-4107-9183-78107ffb4969.png)\n\n**macOS LEMP Setup is Mac only!**\n\n### Other platforms\n\n- Windows: [Setting up a local server on Windows 10 for WordPress theme development (or any web development for that matter)](https://rolle.design/local-server-on-windows-10-for-wordpress-theme-development).\n- Linux: [Pop!_OS LEMP setup instructions](https://github.com/raikasdev/pop-lemp-setup) by [raikasdev](https://github.com/raikasdev).\n\n## Minimum requirements\n\n* Latest [Homebrew](https://brew.sh/)\n* MacBook Pro M1 (if you like to install this on Intel mac, refer to [this tutorial](https://kevdees.com/macos-12-monterey-nginx-setup-multiple-php-versions/))\n* macOS Monterey 12.3 or later\n\n## Install local LEMP for macOS\n\nFor *Front End development*, a full Vagrant box, docker container per site or Local by Flywheel is not really needed. If you have a Macbook Pro, you can install local LEMP (Linux, nginx, MariaDB and PHP) with this single liner below. \n\nPlease see [installation steps](#installation) instructions first.\n\n```` bash\n/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/digitoimistodude/macos-lemp-setup/master/install.sh)\"\n````\n\nOneliner may not go through in macOS Big Sur and macOS Monterey, in that caes you need to copy and paste commands manually from [install.sh](https://raw.githubusercontent.com/digitoimistodude/macos-lemp-setup/master/install.sh).\n\n**Please note:** Don't trust blindly to the script, use only if you know what you are doing. You can view the file [here](https://github.com/digitoimistodude/osx-lemp-setup/blob/master/install.sh) if having doubts what commands are being run. However, script is tested working many times and should be safe to run even if you have some or all of the components already installed.\n\n## Table of contents\n\n1. [Background](#background)\n2. [Features](#features)\n3. [Requirements](#requirements)\n4. [Installation](#installation)\n5. [Post installations](#post-installations)\n   1. [Mailhog](#MailHog)\n6. [Use Linux-style aliases](#use-linux-style-aliases)\n7. [File sizes](#file-sizes)\n8. [XDebug](#xdebug)\n9. [Redis](#redis)\n10. [Troubleshooting](#troubleshooting)\n\n### Background\n\nRead the full story by [@ronilaukkarinen](https://github.com/ronilaukkarinen): **[Moving from Vagrant to a LEMP stack directly on a Macbook Pro (for WordPress development)](https://medium.com/@rolle/moving-from-vagrant-to-a-lemp-stack-directly-on-a-macbook-pro-e935b1bc5a38)**\n\n### Features\n\n- PHP 8.3\n- nginx 1.25.3\n- Super lightweight\n- Native packages\n- Always on system service\n- HTTPS support\n- Consistent with production setup\n\n### Requirements\n\n- [Homebrew](https://brew.sh/)\n- macOS, preferably 14.2.1 (Sonoma)\n- wget\n- [mkcert](https://github.com/FiloSottile/mkcert)\n\n### Installation\n\n1. Run oneliner installation script `/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/digitoimistodude/macos-lemp-setup/master/install.sh)\"`\n2. Link PHP executable like this: **Run:** `sudo find / -name 'php'`. When you spot link that looks like this (yours might be different version) */usr/local/Cellar/php@8.3/8.3.3/bin/php*, symlink it to correct location to override MacOS's own file: `sudo ln -s /usr/local/Cellar/php@8.3/8.3.3/bin/php /usr/local/bin/php`\n3. Use PHP path from correct location by adding to your ~/.bash_profile file, `sudo nano ~/.bash_profile` (change your PHP version accordingly)\n   ``` shell\n   export PATH=\"$(brew --prefix php@8.3)/bin:$PATH\"\n   ```\n4. Check the version with `php --version`, it should match the linked file.\n5. Brew should have already handled other links, you can test the correct versions with `sudo mysql --version` (if it's something like _mysql  Ver 15.1 Distrib 10.5.5-MariaDB, for osx10.15 (x86_64) using readline 5.1_ it's the correct one) and `sudo nginx -v` (if it's something like nginx version: nginx/1.19.3 it's the correct one)\n6. Add `export PATH=\"$(brew --prefix php@8.3)/bin:$PATH\"` to .bash_profile (or to your zsh profile or to whatever term profile you are currently using)\n7. Go through [post installations](#post-installations)\n8. Enjoy! If you use [dudestack](https://github.com/digitoimistodude/dudestack), please check instructions from [its own repo](https://github.com/digitoimistodude/dudestack).\n\n### Post installations\n\n#### PHP config\n\nYou may want to add your user and group correctly to `/opt/homebrew/etc/php/8.3/php-fpm.d/www.conf` (or wherever your www.conf is, find with `sudo find / -name 'www.conf'`) and set these to the bottom:\n\n````\ncatch_workers_output = yes\nphp_flag[display_errors] = On\nphp_admin_value[error_log] = /var/log/fpm-php.www.log \nslowlog = /var/log/fpm-php.slow.log \nphp_admin_flag[log_errors] = On\nphp_admin_value[memory_limit] = 1024M\nrequest_slowlog_timeout = 10\nphp_admin_value[upload_max_filesize] = 100M\nphp_admin_value[post_max_size] = 100M\n````\n\nPlease note, if the file is not found (as the location may also be something like `/System/Volumes/Data/opt/homebrew/etc/php/8.3/php-fpm.d/www.conf`), you can find the correct location with:\n\n```\nsudo find / -name 'www.conf'\n```\n\n#### Make sure the PHP runs on correct permissions\n\nMake sure you have your user and group defined, use these as base (only change `rolle` to your own Mac username):\n\n````config\n; Unix user/group of processes\n; Note: The user is mandatory. If the group is not set, the default user's group\n;       will be used.\nuser = rolle\ngroup = admin\n````\n\nAlso make sure you have listen set up properly\n\n````config\n; The address on which to accept FastCGI requests.\n; Valid syntaxes are:\n;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on\n;                            a specific port;\n;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on\n;                            a specific port;\n;   'port'                 - to listen on a TCP socket to all addresses\n;                            (IPv6 and IPv4-mapped) on a specific port;\n;   '/path/to/unix/socket' - to listen on a unix socket.\n; Note: This value is mandatory.\nlisten = 127.0.0.1:9000\n````\n\n#### Default nginx config\n\nMake sure you have default vhost for your site (`/etc/nginx/sites-enabled/sitename.test`) could be something like:\n\n```` nginx\nserver {\n  listen 80;\n  root /var/www/example;\n  index index.html index.htm index.php;\n  server_name example.test www.example.test;\n  include php.conf;\n  include global/wordpress.conf;\n}\n````\n\n#### Default MySQL my.cnf\n\nDefault my.cnf would be something like this (already added by install.sh in `/usr/local/etc/my.cnf`:\n\n````\n#\n# This group is read both both by the client and the server\n# use it for options that affect everything\n#\n[client-server]\n\n#\n# include all files from the config directory\n#\n!includedir /usr/local/etc/my.cnf.d\n\n[mysqld]\ninnodb_log_file_size = 32M\ninnodb_buffer_pool_size = 1024M\ninnodb_log_buffer_size = 4M\nslow_query_log = 1\nquery_cache_limit = 512K\nquery_cache_size = 128M\nskip-name-resolve\n````\n\nAgain, if the correct file cannot be found, you can find it with:\n\n```\nsudo find / -name 'my.cnf'\n```\n\nFor mysql, \u003cb\u003eremember to run `sudo mysql_secure_installation`\u003c/b\u003e, answer as suggested, add/change root password, remove test users etc. \u003cb\u003eOnly exception!\u003c/b\u003e Answer with \u003ckbd\u003en\u003c/kbd\u003e to the question \u003ccode\u003eDisallow root login remotely? [Y/n]\u003c/code\u003e. Your logs can be found at `/usr/local/var/mysql/yourcomputername.err` (where yourcomputername is obviously your hostname).\n\nAfter that, get to know [dudestack](https://github.com/digitoimistodude/dudestack) to get everything up and running smoothly. Current version of dudestack supports macOS LEMP stack.\n\nYou should remember to add vhosts to your /etc/hosts file, for example: `127.0.0.1 site.test`.\n\n### Symlinks\n\nYou should find the correct files and link them like in Linux. This helps you to remember the correct paths.\n\nFor example (please note, this is just an example):\n\n```bash\nsudo mkdir -p /usr/local/bin\nsudo ln -s /opt/homebrew/Cellar/php@8.3/8.3.3/bin/php /usr/local/bin/php\nsudo ln -s /opt/homebrew/Cellar/php@8.3/8.3.3/sbin/php-fpm /usr/local/bin/php-fpm\nsudo ln -s /opt/homebrew/Cellar/php@8.3/8.3.3/sbin/php-fpm /usr/local/bin/php-fpm\nsudo ln -s /opt/homebrew/etc/php /etc/php\nsudo ln -s /opt/homebrew/etc/nginx /etc/nginx\nsudo ln -s /opt/homebrew/etc/my.cnf /etc/my.cnf\n```\n\n### Use Linux-style aliases\n\nAdd this to */usr/local/bin/service* and chmod it +x:\n\n```` bash\n#!/bin/bash\n# Alias for unix type of commands\nbrew services \"$2\" \"$1\";\n````\n\nNow you are able to restart nginx and mysql unix style like this:\n\n```` bash\nsudo service nginx restart\nsudo service mariadb restart\n````\n\n#### MailHog\n\nE-mails won't be sent on local environment because there is no email server configured. This is where [MailHog](https://github.com/mailhog/MailHog) comes in.\n\nMailHog should be pre-installed but if not, run following:\n\n``` bash\nbrew update \u0026\u0026 brew install mailhog\n```\n\nEnsure you have the latest [air-helper](https://github.com/digitoimistodude/air-helper) or [MailHog for WordPress](https://wordpress.org/plugins/wp-mailhog-smtp/) activated to enable MailHog routing for local environment.\n\nThen just run:\n\n``` bash\nmailhog\n```\n\nYou should now get a log in command line and web interface is available in http://0.0.0.0:8025/.\n\n### File sizes\n\nYou might want to increase file sizes for development environment in case you need to test compression plugins and other stuff in WordPress. To do so, edit `/usr/local/etc/php/8.3/php-fpm.d/www.conf` and `/usr/local/etc/php/8.3/php.ini` and change all **memory_limit**, **post_max_size** and **upload_max_filesize** to something that is not so limited, for example **500M**.\n\nPlease note, you also need to change **client_max_body_size** to the same amount in `/etc/nginx/nginx.conf`. After this, restart php-fpm with `sudo brew services restart php@8.3` and nginx with `sudo brew services restart nginx`.\n\n### Certificates for localhost\n\nFirst things first, if you haven't done it yet, generate general dhparam:\n\n```` bash\nsudo su -\ncd /etc/ssl/certs\nsudo openssl dhparam -dsaparam -out dhparam.pem 4096\n````\n\nGenerating certificates for dev environment is easiest with [mkcert](https://github.com/FiloSottile/mkcert). After installing mkcert, just run:\n\n```` bash\nmkdir -p /var/www/certs \u0026\u0026 cd /var/www/certs \u0026\u0026 mkcert \"project.test\"\n````\n\nThen edit your vhost as following (change all from *project* to your project name):\n\n```` nginx\nserver {\n  listen 443 ssl;\n  http2 on;\n  root /var/www/project;\n  index index.php;    \n  server_name project.test;\n\n  include php.conf;\n  include global/wordpress.conf;\n\n  ssl_certificate /var/www/certs/project.test.pem;\n  ssl_certificate_key /var/www/certs/project.test-key.pem;\n  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n  ssl_prefer_server_ciphers on;\n  ssl_dhparam /etc/ssl/certs/dhparam.pem;\n  ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';\n  ssl_session_timeout 1d;\n  ssl_session_cache shared:SSL:50m;\n  ssl_stapling_verify on;\n  add_header Strict-Transport-Security max-age=15768000;\n}\n\nserver {\n  listen 80;\n  server_name project.test;\n  return 301 https://$host$request_uri;\n}\n````\n\nTest with `sudo nginx -t` and if everything is OK, restart nginx.\n\n### XDebug\n\n1. Check your PHP version with `php --version` and location with `which php`. If the location points to `/usr/bin/php`, you are mistakenly using macOS built-in PHP. Change PHP path to correct location by adding to your ~/.bash_profile file, `sudo nano ~/.bash_profile` (change your PHP version accordingly):\n   ``` shell\n   export PATH=\"$(brew --prefix php@8.3)/bin:$PATH\"\n   ```\n2. Install xdebug\n\n```bash\nbrew install shivammathur/extensions/xdebug@8.3\n```\n\n``` shell\n$ php --version\nPHP 8.3.3 (cli) (built: Feb 13 2024 15:41:14) (NTS)\nCopyright (c) The PHP Group\nZend Engine v4.3.3, Copyright (c) Zend Technologies\n    with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans\n    with Zend OPcache v8.3.3, Copyright (c), by Zend Technologies\n```\n\n7. Check where your php.ini file is with `php --ini`\n8. Edit php.ini, for example `sudo nano `\n9. Make sure these are on the first lines:\n\n```\nxdebug.mode=develop\nxdebug.client_port=9003\nxdebug.client_host=127.0.0.1\nxdebug.remote_handler=dbgp\nxdebug.start_with_request=yes\nxdebug.discover_client_host=0\nxdebug.show_error_trace = 1\nxdebug.max_nesting_level=250\nxdebug.var_display_max_depth=10\nxdebug.log=/var/log/xdebug.log\n```\n\n10. Save and close with \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003eO\u003c/kbd\u003e and \u003ckbd\u003ectrl\u003c/kbd\u003e + \u003ckbd\u003eX\u003c/kbd\u003e\n11. Make sure the log exists `sudo touch /var/log/xdebug.log \u0026\u0026 sudo chmod 777 /var/log/xdebug.log`\n12. Restart services (requires [Linux-style aliases](#use-linux-style-aliases)) `sudo service php@8.3 restart \u0026\u0026 sudo service nginx restart`\n13. Install [PHP Debug VSCode plugin](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug)\n14. Add following to launch.json (\u003ckbd\u003ecmd\u003c/kbd\u003e + + \u003ckbd\u003eshift\u003c/kbd\u003e + \u003ckbd\u003eP\u003c/kbd\u003e, \"Open launch.json\"):\n\n``` json\n{\n  \"version\": \"0.2.0\",\n  \"configurations\": [\n    {\n      //\"debugServer\": 4711, // Uncomment for debugging the adapter\n      \"name\": \"Listen for Xdebug\",\n      \"type\": \"php\",\n      \"request\": \"launch\",\n      \"port\": 9003,\n      \"log\": true\n    },\n    {\n      //\"debugServer\": 4711, // Uncomment for debugging the adapter\n      \"name\": \"Launch\",\n      \"request\": \"launch\",\n      \"type\": \"php\",\n      \"program\": \"${file}\",\n      \"cwd\": \"${workspaceRoot}\",\n      \"externalConsole\": false\n    }\n  ]\n}\n```\n15. Xdebug should now work on your editor\n16. PHPCS doesn't need xdebug but will warn about it not working... this causes error in [phpcs-vscode](https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs) because it depends on outputted phpcs json that is not valid with the warning _\"Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9003 (through xdebug.client_host/xdebug.client_port) :-(_\". This can be easily fixed by installing a bash \"wrapper\":\n17. Rename current phpcs with `sudo mv /usr/local/bin/phpcs /usr/local/bin/phpcs.bak`\n18. Install new with `sudo nano /usr/local/bin/phpcs`:\n\n``` bash\n#!/bin/bash\nXDEBUG_MODE=off /Users/rolle/Projects/phpcs/bin/phpcs \"$@\"\n```\n\n19. Add permissions `sudo chmod +x /usr/local/bin/phpcs`\n20. Make sure VSCode settings.json has this setting:\n\n``` json\n\"phpcs.executablePath\": \"/usr/local/bin/phpcs\",\n```\n\n### Redis\n\nRedis is an open source, in-memory data structure store, used as a database, cache. We are going to install Redis and php-redis.\n\nBefore installation, make sure you do not use PHP provided by macOS. You should be using PHP installed by homebrew. If you are having problems with testing php-redis after installation, it is most probably caused bacuse of using wrong PHP. See [Troubleshooting: Testing which version of PHP you run](#testing-which-version-of-php-you-run) for more information.\n\n1. Check that `pecl` command works\n2. Run `brew update` first\n3. Install Redis, `brew install redis`\n4. Start Redis `brew services start redis`, this will also make sure that Redis is always started on reboot\n5. Test if Redis server is running `redis-cli ping`, expected response is `PONG`\n6. Install PHP Redis extension `pecl install redis`.\n7. Restart nginx and php-redis should be available, you can test it with `php -r \"if (new Redis() == true){ echo \\\"\\r\\n OK \\r\\n\\\"; }\"` command, expected response is `OK`\n\n### Troubleshooting\n\n#### PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so\n\nIf you get something like this:\n\n```shell\nPHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /opt/homebrew/lib/php/pecl/20190902/redis.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/redis.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/redis.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/php/pecl/20190902/redis.so' (no such file), '/opt/homebrew/lib/php/pecl/20190902/redis.so' (no such file)), /opt/homebrew/lib/php/pecl/20190902/redis.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/redis.so.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/redis.so.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/php/pecl/20190902/redis.so.so' (no such file), '/opt/homebrew/lib/php/pecl/20190902/redis.so.so' (no such file))) in Unknown on line 0\n```\n\nInstall [phpredis](https://github.com/phpredis/phpredis) from source:\n\n```\ngit clone https://www.github.com/phpredis/phpredis.git\ncd phpredis\nphpize \u0026\u0026 ./configure \u0026\u0026 make \u0026\u0026 sudo make install\n```\n\nThen take copy the outputted library path, it will be something like this: `/opt/homebrew/Cellar/php@8.3/8.3.3/pecl/20190902/`.\n\nRun `php --ini` and modify your php.ini with `nano -w /path/to/php.ini`.\n\nReplace `extension=\"redis.so\"` with `extension=\"/opt/homebrew/Cellar/php@8.3/8.3.3/pecl/20190902/redis.so\"` where the path is the one you copied. Restart nginx just in case. After this phpredis should work.\n\n#### Testing which version of PHP you run\n\nTest with `php --version` what version of PHP you are using, if the command returns something like `PHP is included in macOS for compatibility with legacy software` and especially when `which php` is showing /usr/bin/php then you are using macOS built-in version (which will be removed in the future anyway) and things most probably won't work as expected.\n\nTo fix this, first find the PHP:\n\n```bash\nsudo find / -name 'php'\n```\n\nLook for the bin under Cellar or homebrew dirs. Then run command with your php bin, for example: `sudo ln -s /usr/local/Cellar/php@8.3/8.3.3/bin/php /usr/local/bin/php`. This symlinks the homebrew version to be used instead of macOS version OR use bashrc export as defined [here in step 4](https://github.com/digitoimistodude/macos-lemp-setup#installation).\n\n#### PHP or mysql not working at all\n\nIf you have something like this in your /var/log/nginx/error.log:\n\n```\n2019/08/12 14:09:04 [crit] 639#0: *129 open() \"/usr/local/var/run/nginx/client_body_temp/0000000005\" failed (13: Permission denied), client: 127.0.0.1, server: project.test, request: \"POST /wp/wp-admin/async-upload.php HTTP/1.1\", host: \"project.test\", referrer: \"http://project.test/wp/wp-admin/upload.php\"\n```\n\nIf you cannot login to mysql from other than localhost, please answer with \u003ckbd\u003en\u003c/kbd\u003e to the question \u003ccode\u003eDisallow root login remotely? [Y/n]\u003c/code\u003e when running \u003ccode\u003esudo mysql_secure_installation\u003c/code\u003e.\n\n**Make sure you run nginx and php-fpm on your root user and mariadb on your regular user**. This is important. Stop nginx from running on your default user by `brew services stop nginx` and run it with sudo `sudo brew services start nginx`.\n\n\u003ccode\u003esudo brew services list\u003c/code\u003e should look like this:\n\n``` shell\n~ sudo brew services list\nName       Status  User  Plist\ndnsmasq    started root  /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist\nmariadb    started rolle /Users/rolle/Library/LaunchAgents/homebrew.mxcl.mariadb.plist\nnginx      started root  /Library/LaunchDaemons/homebrew.mxcl.nginx.plist\nphp        started root  /Library/LaunchDaemons/homebrew.mxcl.php@8.3.plist\n```\n\nYou may have \"unknown\" or \"error\" as status or different PHP version, that is not a problem if ther server runs. **User** should be like in the list above. Then everything should work.\n\n#### MySQL/MariaDb issues\n\nIf you get problems like:\n\n```\nERROR 2002 (HY000): Can't connect to MySQL server on '127.0.0.1' (36)\n```\n\nIt seems you have messed up with your root password. Try resetting root password with by adding this to your home directory (for example /Users/rolle/mysql-init):\n\nTry resetting root password with (add new password in place of _YOUR_NEW_PASSWORD_):\n\n```\nALTER USER 'root'@'localhost' IDENTIFIED BY 'YOUR_NEW_PASSWORD';\n```\n\nThen kill all mysql processes:\n\n\n```\nsudo ps xa |grep mysql\nkill -9 \u003cpid\u003e\n```\n\n\nThen run:\n\n```\nmysqld --init-file=/Users/rolle/mysql-init \u0026\n```\n\nAfter this:\n\n```\nsudo mysql_secure_installation\n```\n\nAnswer:\n\n```\nNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB\n      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!\n\nIn order to log into MariaDB to secure it, we'll need the current\npassword for the root user. If you've just installed MariaDB, and\nhaven't set the root password yet, you should just press enter here.\n\nEnter current password for root (enter for none): \nOK, successfully used password, moving on...\n\nSetting the root password or using the unix_socket ensures that nobody\ncan log into the MariaDB root user without the proper authorisation.\n\nYou already have your root account protected, so you can safely answer 'n'.\n\nSwitch to unix_socket authentication [Y/n] n\n ... skipping.\n\nYou already have your root account protected, so you can safely answer 'n'.\n\nChange the root password? [Y/n] n\n ... skipping.\n\nBy default, a MariaDB installation has an anonymous user, allowing anyone\nto log into MariaDB without having to have a user account created for\nthem.  This is intended only for testing, and to make the installation\ngo a bit smoother.  You should remove them before moving into a\nproduction environment.\n\nRemove anonymous users? [Y/n] y\n ... Success!\n\nNormally, root should only be allowed to connect from 'localhost'.  This\nensures that someone cannot guess at the root password from the network.\n\nDisallow root login remotely? [Y/n] n\n ... skipping.\n\nBy default, MariaDB comes with a database named 'test' that anyone can\naccess.  This is also intended only for testing, and should be removed\nbefore moving into a production environment.\n\nRemove test database and access to it? [Y/n] y\n - Dropping test database...\n ... Success!\n - Removing privileges on test database...\n ... Success!\n\nReloading the privilege tables will ensure that all changes made so far\nwill take effect immediately.\n\nReload privilege tables now? [Y/n] y\n ... Success!\n\nCleaning up...\n\nAll done!  If you've completed all of the above steps, your MariaDB\ninstallation should now be secure.\n\nThanks for using MariaDB!\n```\n\nIf you are still having problems connecting with WordPress and prompting `Access denied for user 'root'@'127.0.0.1'`, try this in `mysql -u root -p`:\n\n``` sql\nGRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'YOUR_MYSQL_ROOT_PASSWORD' WITH GRANT OPTION;\nGRANT ALL PRIVILEGES ON *.* TO root@127.0.0.1 IDENTIFIED BY 'YOUR_MYSQL_ROOT_PASSWORD' WITH GRANT OPTION;\n```\n\n#### *2 open() \"/var/www/test.txt\" failed (13: Permission denied), client: 127.0.0.1\n\nIf you are getting permission denied by nginx, you need to make sure your php-fpm and nginx are running on the same user. This is stricter on MacBook Pro M1.\n\nOpen `/opt/homebrew/etc/php/8.3/php-fpm.d/www.conf` and change the user, group and listen to following:\n\n```ini\nuser = your_username\ngroup = staff\nlisten = 127.0.0.1:9074\n```\n\nOpen `/opt/homebrew/etc/nginx/nginx.conf` and add to first line:\n\n```ini\nuser your_username staff;\n```\n\n#### \"Primary script unknown\" error in nginx log or \"File not found.\" in browser\n\nThis is caused by php-fpm not running properly. Please [make sure the PHP runs on correct permissions](#make-sure-the-php-runs-on-correct-permissions) section.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitoimistodude%2Fmacos-lemp-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitoimistodude%2Fmacos-lemp-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitoimistodude%2Fmacos-lemp-setup/lists"}