ServBay Directory Structure
ServBay's directory structure is simple and straightforward. If you have a basic understanding of Linux/Unix systems, you'll find both quite similar.
A typical ServBay directory structure is as follows:
ServBay
|____backup
| |____config
| |____hosts
|____bin
|____data
| |____servbay
|____db
| |____redis
|____etc
|____logs
|____package
| |____bin
| |____common
| | |____imap-uw
| | |____include
| | |____lib
| | |____libexec
| | |____openssl
| | |____share
| |____etc
| | |____caddy
| | |____dnsmasq
| | |____mariadb
| | |____openldap
| | |____php
| | |____redis
| | |____scws
| |____mariadb
| | |____x.x
| |____node
| | |____xx
| |____php
| | |____x.x
| |____sbin
| |____var
| | |____log
| | |____run
|____sbin
|____script
|____ssl
| |____caddy
|____tmp
|____www
| |____servbay
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Next, we'll detail the purpose of various directories.
Main Directory
The main directory of ServBay is located at /Applications/ServBay
, where all files are stored.
For backup purposes (e.g., using Time Machine or other backup methods), make sure to fully backup this directory.
Web Root Directory
The root directory for websites is located at /Applications/ServBay/www
. It is recommended to create a separate folder for each host to store files, making the structure clear and easy to manage.
For example:
/Applications/ServBay/www
|____com
| |____servbay
| | |____web # web.servbay.com
| | |____support # support.servbay.com
| | |____api # api.servbay.com
|____local
| |____sam
| | |____www # www.sam.local
| |____servbay
| | |____new # new.servbay.local
2
3
4
5
6
7
8
9
10
11
Configuration Files Directory
The configuration files directory is located at /Applications/ServBay/etc
, which is a symbolic link, with the actual files stored at /Applications/ServBay/package/etc
.
Generally, you can directly use /Applications/ServBay/etc
.
Here are examples of configuration files for common software packages:
PHP
The PHP configuration file directory has a two-tier structure. Under etc/php
, there are directories for different versions, such as 5.6
, 7.4
, 8.3
, etc. Here is a typical structure:
php
|____5.6
| |____conf.d
|____7.0
| |____conf.d
| |____php-fpm.d
|____7.4
| |____conf.d
| |____php-fpm.d
|____8.3
| |____conf.d
| |____php-fpm.d
|____8.4
| |____conf.d
| |____php-fpm.d
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Each version directory contains files like php.ini
, php-fpm.conf
, pear.conf
, and so on. After modifying these files, you need to restart the corresponding PHP service to apply the latest settings.
conf.d
directory is for PHP extension configurations, including xdebug.ini
, opcache.ini
, redis.ini
, etc. Editing these files allows you to load, unload, or modify various PHP extensions. Similarly, after modification, you need to restart the corresponding PHP service to apply the latest settings.
Note: Each minor version shares the configuration with the major version. For example, 8.3.3
and 8.3.5
share the configuration of 8.3
.
MariaDB
The MariaDB configuration file directory also has a two-tier structure, such as etc/mariadb/11.2
. Only one my.cnf
file is in the folder, and after modification, you need to restart to take effect. Each minor version shares the configuration with the major version.
Caddy
Note: Caddyfile is automatically generated by ServBay, do not modify it. After modification, it will be automatically overwritten. For custom settings, please configure directly in ServBay's hosts
.
dnsmasq
The directory contains two main files: dnsmasq.conf
and domains.conf
. dnsmasq.conf
is the default configuration file, and domains.conf
is the automatically generated domain file.
Note: dnsmasq.conf
and domains.conf
files are automatically generated by ServBay; do not modify them. Any modifications will be automatically overwritten.
ServBay Settings Directory
/Applications/ServBay/data
This directory contains the configuration files and information needed for ServBay to function correctly. Please back up and avoid deleting or altering any files inside.
Executable Files and Scripts Directory
/Applications/ServBay/bin -> package/bin
/Applications/ServBay/sbin -> package/sbin
/Applications/ServBay/script
2
3
All executable files of ServBay are located in the bin
and sbin
directories. This includes various versions of PHP, Node, etc., with symbolic links created to these two directories.
These directories contain a lot of common tools such as curl
, openssl
, frpc
, as well as various versions of PHP and Node.
For example, you can use php-5.6
to specify PHP 5.6 to run a script, or use node-15
to execute a non-LTS Node.js 15 script.
Particularly, the script
directory contains system scripts for ServBay, used for starting and stopping services, database initialization, and other operations. You can directly execute these scripts, but do not modify or delete them.
These scripts are all packaged into servbayctl
. You can directly execute servbayctl
for operations, for example:
servbayctl start php 7.0
Database Files Directory
/Applications/ServBay/db
Like the etc
directory, the db
directory also has a multi-tier structure, with each minor version and major version sharing a database. Please back up this directory regularly during daily development.
Logs Directory
/Applications/ServBay/logs -> package/var/log
All ServBay logs are stored here. Except for PHP and XDebug, which generate quite a few files and are stored in secondary directories, other logs are stored in the subdirectories of their corresponding services.
Website access logs are stored in the caddy
directory, organized by domain names.
PHP logs are divided into two: php-fpm.log
(logs generated by php-fpm) and errors.log
(error logs). errors.log
is only generated when there's a runtime error in the code that is not captured and stored by the PHP framework.
For example, Laravel
generated error logs will be stored in the Laravel
framework's storage/logs/laravel.log
, while WordPress
and trongate
generated error logs might be found in errors.log
.
Note: Log files can occupy a lot of space, please clean them up in time.
Package Directory
/Applications/ServBay/package
This directory contains all the software packages installed by ServBay, structured as PackageName/MajorVersion/MinorVersion
. For example package/php/8.3/8.3.7
.
Old versions that are no longer needed after an upgrade can be deleted manually to save space.
Note: Each folder contains a symbolic link named current
, which points to the latest version of the software package. Do not delete it, otherwise, it will cause the service to fail to start.
SSL Certificates Directory
/Applications/ServBay/ssl
This directory stores SSL certificates, including the local SSL root certificate (CA).
Backup Directory
/Applications/ServBay/backup
ServBay's automatic backup directory is currently only for backing up the /etc/hosts
file.
Temporary Files Directory
/Applications/ServBay/tmp
This directory stores .pid
files generated during the running of various services, as well as Socket files
of PHP, MariaDB, PostgreSQL, such as php-cgi.sock
, mysql.sock
, etc.
During daily development, besides accessing php-fpm, databases via TCP port, you can also access php-fpm and databases via socket files. Socket files usually have higher throughput, better performance, and lower latency than TCP ports.
Public Components and Development Library
/Applications/ServBay/package/common
This directory stores the public components required by all ServBay applications, such as various *.dylib
files.
If you have installed ServBay Development Library
, it will also have an include
directory here, and the lib
will have various *.la
, *.a
files. These are the libraries and headers required for secondary compilation.
Note: Do not delete lib/*.dylib
files, otherwise, it will cause the program to run abnormally due to missing necessary library files.