MEMP Stack. MacOSX + Nginx + MySQL + PHP
- install => https://brew.sh/
brew install nginx
brew install php
// or spesific version
brew install php@7.4
brew install mysql
- start service mysql
brew services start mysql
- configuration mysql
mysql_secure_installation
- follow the instructions until finish
- start mysql serve
mysql.server start
- login to mysql from terminal with password your first setup
mysql -u root -p
- Change the authentication method for root as mysql_native_password to support login in phpmyadmin
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
- Reload grant tables
FLUSH PRIVILEGES;
- finish and exit
exit
- export path php
sudo nano ~/.zshrc
// or
sudo nano ~/.bash_profile
- add
export PATH="/usr/local/opt/php@7.3/bin:$PATH"
note: php@7.3 same with installed php in your mac
- check your php and php-pfm
php -v
php-fpm -v
- create config nginx for your project with ext *.conf, ex: phpmyadmin.conf
server {
listen 9090;
index index.php;
server_name phpmyadmin.local;
root /root/for/your/project;
access_log /usr/local/etc/nginx/logs/phpmyadmin.access.log;
error_log /usr/local/etc/nginx/logs/phpmyadmin.error.log;
client_max_body_size 100m;
client_body_buffer_size 512k;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/etc/nginx/fastcgi.conf;
}
}
- put to directory /usr/local/etc/nginx/servers note : show hidden file with keyboard shortcuts cmd + shift + .
- make dir for log nginx
mkdir /usr/local/etc/nginx/logs
- cek your config health with
nginx -t
- start
sudo nginx
- stop
sudo nginx -s stop
- reload
sudo nginx -s reload
- start
mysql.server start
- stop
mysql.server stop
note: after change config file .conf nginx must be check config with nginx-t and reload nginx with sudo nginx -s reload
cek your with localhost:9090 (config port on file *.conf)
note : first on your laptop must be run service nginx (if not active), php-fpm (if not active) and mysql (if nor active)