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)"
DATABASE_IMAGE="Docker image used"
Variables must be completed
Example:
- My project is
myproject
- My Domain URL is
myproject.test
- My Docker image database is
mysql:5.7
It will look like:
COMPOSE_PROJECT_NAME=myproject
DOMAIN_URL=myproject.test
DATABASE_IMAGE=mysql:5.7
Edit the file config/pleaz/macos/docker-compose.yml
and replace all content by: docker-compose.php.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
-
Edit the sites configuration file
config/pleaz/macos/services/nginx/<DOMAIN_NAME>includes/sites.conf
and replace all content by: sites.conf- Modify the upstream
fastcgi_backend
variable with the correct PHP version used (e.g.fastcgi_backend<PHP_VERSION>
). See upstream variable NGINX - Configuration
- Modify the upstream
-
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
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 services
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