==============================================================================
==============================================================================
Install and configure the following services
The majority of tools are installed via the Homebrew tool. We will refer the Homebrew root directory with <HOMEBREW_[package]>, which can be retrieved via the command
brew --prefix [package]
-
At the root of your project, add a config directory (e.g.
config/pleaz
). This will be used to store all important files for the services. -
Add the docker config files
touch config/pleaz/macos/{.env,docker-compose.yml}
- Create the directory for the NGINX
server block
.
Replace
<DOMAIN_NAME>
by your domain name
mkdir -p config/pleaz/macos/services/nginx/<DOMAIN_NAME>/includes
touch config/pleaz/macos/services/nginx/<DOMAIN_NAME>/{server.conf,includes/sites.conf}
The structure should look like this:
config/
└── pleaz/
└── macos/
├── .env
├── docker-compose.yml
└── nginx/
└── <DOMAIN_NAME>/
├── server.conf
└── includes/
└── sites.conf
Edit the file config/pleaz/macos/.env
and replace all content by:
COMPOSE_PROJECT_NAME="Name of your project"
DOMAIN_URL="Your domain URL without http(s)"
ELASTICSEARCH_IMAGE="Docker image used"
DATABASE_IMAGE="Docker image used"
REDIS_IMAGE="Docker image used"
Variables must be completed
Example:
- Project name is
myproject
- Domain URL is
myproject.test
- Docker image for the database is
mariadb:10.2
- Docker image for Elasticsearch is
magento/magento-cloud-docker-elasticsearch:7.9-1.2.2
- Docker image for Redis is
redis:6.0
- Docker image for RabbitMQ is
rabbitmq:3.8
It will look like:
COMPOSE_PROJECT_NAME=myproject
DOMAIN_URL=myproject.test
DATABASE_IMAGE=mariadb:10.2
ELASTICSEARCH_IMAGE=magento/magento-cloud-docker-elasticsearch:7.9-1.2.2
REDIS_IMAGE=redis:6.0
RABBITMQ_IMAGE=rabbitmq:3.8
To find existing official version of the service images
Edit the file config/pleaz/macos/docker-compose.yml
and replace all content by: docker-compose.magento.yml
For easier maintenance, the point of entry of projects in the configuration of NGINX has been centralized.
The web root directory of the NGINX by default is /usr/local/var/www
. We are going to create a symbolic link from our project to this directory.
ln -s <ABSOLUTE_PATH_PROJECT_DIRECTORY> /usr/local/var/www/<DOMAIN_NAME>
Example:
- My project is
/Users/johndoe/Sites/myproject
- My Domain Name is
myproject.test
ln -s /Users/johndoe/Sites/myproject /usr/local/var/www/myproject.test
-
Edit the server configuration file
config/pleaz/macos/services/nginx/<DOMAIN_NAME>/server.conf
and replace all content by: server.conf- Replace
<PHP_VERSION>
by your version[7.3|7.4|<MAJOR.MINOR>]
- Replace
<DOMAIN_NAME>
by your domain name - Replace
<RELATIVE_PATH_SOURCE>
by your relative path of your source code (example:src/store
)
- Replace
-
Copy the content of the provided Magento 2 NGINX config file
nginx.conf.sample
intoconfig/pleaz/macos/services/nginx/<DOMAIN_NAME>/includes/sites.conf
cp <MAGENTO_SOURCE_CODE>/nginx.conf.sample config/pleaz/macos/services/nginx/<DOMAIN_NAME>/includes/sites.conf
If you don't have the file
nginx.conf.sample
into your project magento2, you can use this file sites.conf
- In the
sites.conf
file, modify the upstreamfastcgi_backend
variable with the correct PHP version used (e.g.fastcgi_backend<PHP_VERSION>
). See upstream variable NGINX - Configuration - Park your project in the NGINX servers directory via a symlink.
- Replace
<DOMAIN_NAME>
by your domain name
- Replace
ln -s <PROJET_ROOT>/config/pleaz/macos/services/nginx/<DOMAIN_NAME> $(brew --prefix nginx)/servers/
Example:
- PHP version is 7.3.
- The project is located in
/Users/johndoe/Sites/myproject
- The Domain Name is
myproject.test
- Configure the
server.conf
- Edit the fastcgi backend in the
sites.conf
(Replacefastcgi_backend
byfastcgi_backend7.3
)
sed -i "" "s/fastcgi_backend/fastcgi_backend7.3/" config/pleaz/macos/services/nginx/<DOMAIN_NAME>/includes/sites.conf
- Park the project
ln -s /Users/johndoe/Sites/myproject/config/pleaz/macos/services/nginx/myproject.test $(brew --prefix nginx)/servers/
Please see instruction here: SSL certificates
For Magento2
, you must create a wildcard SSL Certificate with the name magento.crt
and magento.key
Open a terminal and execute:
mkcert -cert-file $(brew --prefix nginx)/certs/ssl/magento.crt -key-file $(brew --prefix nginx)/certs/ssl/magento.key "*.local.test"
For multiple-Domain Wildcard SSL, just add domain at the end of the command:
ie: *.local.test
and *.dev.test
mkcert -cert-file $(brew --prefix nginx)/certs/ssl/magento.crt -key-file $(brew --prefix nginx)/certs/ssl/magento.key "*.local.test" "*.dev.test"
You can either use the native command or the
Pleaz
CLI.
$ cd config/pleaz/macos
## Start docker services
$ docker-compose up -d
## Stop docker services
$ docker-compose down
## Native
sudo brew services start nginx
sudo brew services start dnsmasq
sudo brew services start mailhog
sudo brew services start php@<PHP_VERSION>
## Pleaz CLI
pleaz service:start nginx
pleaz service:start dnsmasq
pleaz service:start mailhog
pleaz service:start php <PHP_VERSION>
- Document Project Root in ->
/usr/local/var/www/
- Locally trusted SSL Certificates in ->
<HOMEBREW_[nginx]>/certs/ssl/
Server Block
directory -><HOMEBREW_[nginx]>/servers
pleaz
Configuration directory -><PROJET_ROOT>/config/pleaz