Install brew nginx with phpbrew php-fpm 7.3.10 on macOS (this installation allows to run nginx and php-fpm (from phpbrew) as root but chrooted with the current user - take care if there is multiple developper account on mac, that will potentially make trouble between accounts).
Last active
March 9, 2024 23:57
-
-
Save abenevaut/c6a70befbe19c545b996febff45cf360 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First follow https://gist.github.com/abenevaut/fd21704ead845e5bc14ca93fa8d0a18f but modify the line 17 like follow | |
// add +fpm to compile php-fpm | |
phpbrew --debug install php-7.3.10 +gd +default +sqlite +mysql +fpm +bz2=/usr/local/Cellar/bzip2/1.0.6_1/ +zlib=/usr/local/Cellar/zlib/1.2.11/ -- --with-gd=shared | |
brew install nginx | |
sudo emacs /usr/local/etc/nginx/nginx.conf | |
sudo emacs /Users/YOUR_MACOS_USERNAME/.phpbrew/php/php-7.1.29/etc/php-fpm.d/www.conf | |
// In previous config files, we set user and group to run nginx and php-fpm as setted user and user group (logic).. | |
// Now we should run nginx and php-fpm as root | |
// So, we need to setup phpbrew for root user | |
sudo su | |
phpbrew init | |
emacs ~/.phpbrew/bashrc | |
// add at top of file | |
export PHPBREW_HOME=/Users/YOUR_MACOS_USERNAME/.phpbrew | |
export PHPBREW_ROOT=/Users/YOUR_MACOS_USERNAME/.phpbrew | |
emacs ~/.bash_profile | |
// add following line | |
[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc | |
source ~/.bash_profile | |
// check phpbrew work | |
phpbrew --version | |
// now leave root user ctrl+C | |
// Now we can start nginx and php-fpm as root to run it as setted user | |
sudo brew services start|stop|restart nginx | |
sudo phpbrew fpm start|stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user YOUR_MACOS_USERNAME YOUR_MACOS_USER_GROUP_NAME; | |
worker_processes 16; | |
events { | |
worker_connections 4096; ## Default: 1024 | |
} | |
http { | |
server { | |
server_name localhost; | |
listen 8000; | |
root /COMPLETE_PATH_TO_SYMFONY_PROJECT; | |
# If user writes the app_xxx.php into the url, remove it: | |
rewrite ^/app_dev\.php/?(.*)$ /$1 permanent; | |
location / { | |
index app_dev.php; | |
rewrite ^/(.*)$ /app_dev.php/$1 last; | |
return 403; # If the rewrite was not succesfull, return error. | |
} | |
# DEV | |
# This rule should only be placed on your development environment | |
# In production, don't include this and don't deploy app_dev.php or config.php | |
location ~ ^/(app_dev|config)\.php(/|$) { | |
# fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_pass unix:/Users/YOUR_MACOS_USERNAME/.phpbrew/php/php-7.3.10/var/run/php-fpm.sock; | |
fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
include fastcgi_params; | |
# When you are using symlinks to link the document root to the | |
# current version of your application, you should pass the real | |
# application path instead of the path to the symlink to PHP | |
# FPM. | |
# Otherwise, PHP's OPcache may not properly detect changes to | |
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 | |
# for more information). | |
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
fastcgi_param DOCUMENT_ROOT $realpath_root; | |
} | |
# return 404 for all other php files not matching the front controller | |
# this prevents access to other php files you don't want to be accessible. | |
location ~ \.php$ { | |
return 404; | |
} | |
error_log /usr/local/var/log/nginx/api_error.log; | |
access_log /usr/local/var/log/nginx/api_access.log; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /Users/YOUR_MACOS_USERNAME/.phpbrew/php/php-7.1.29/etc/php-fpm.d/www.conf then change value of : | |
user = YOUR_MACOS_USERNAME | |
group = YOUR_MACOS_USER_GROUP_NAME |
Author
abenevaut
commented
Dec 10, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment