---
# System prepended metadata

title: 伺服器配置

---

## 安裝 nginx
```
apt install nginx -y
```

## 安裝PHP 8.0
```
apt install ca-certificates apt-transport-https software-properties-common -y

add-apt-repository ppa:ondrej/php

apt update

apt install php8.0 php8.0-fpm php8.0-dev php8.0-gd php8.0-curl php8.0-mysql php8.0-mbstring php8.0-xml php8.0-zip php8.0-bcmath php8.0-redis -y
```

## 安裝 composer
```
curl -o- https://getcomposer.org/installer | php

mv composer.phar /usr/local/bin/composer
```

## 安裝 Docker 
```
curl -o- https://get.docker.com | bash

curl -fsSL https://github.com/docker/compose/releases/download/v2.18.0/docker-compose-linux-x86_64 -o docker-compose

sudo chmod +x /usr/local/bin/docker-compose
```

## 安裝 MySQL 
```
sudo apt-get install apt-transport-https curl

sudo mkdir -p /etc/apt/keyrings

sudo curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'


apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'

add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirrors.xtom.com/mariadb/repo/10.11/ubuntu focal main'

apt update

apt install mariadb-server -y

mysql_secure_installation
```

## 安裝 Node.js 
```
curl -sL https://deb.nodesource.com/setup_15.x | bash -

apt install -y nodejs

```

## 安裝 MeiliSearch
```
curl -o- https://install.meilisearch.com | sh

chmod +x meilisearch

mv ./meilisearch /usr/local/bin/

useradd -d /var/lib/meilisearch -b /bin/false -m -r meilisearch


chown -R meilisearch:meilisearch /var/lib/meilisearch

chmod 750 /var/lib/meilisearch

touch /etc/systemd/system/meilisearch.service
```

## 配置 MeiliSearch - meilisearch.toml
```
mkdir -p /var/lib/meilisearch/data /var/lib/meilisearch/dumps /var/lib/meilisearch/snapshots

chown -R meilisearch:meilisearch /var/lib/meilisearch

chmod 750 /var/lib/meilisearch

cat << EOF > /etc/meilisearch/meilisearch.toml
env = "production"
master_key = "YOUR_MASTER_KEY_VALUE"
db_path = "/var/lib/meilisearch/data"
dump_dir = "/var/lib/meilisearch/dumps"
snapshot_dir = "/var/lib/meilisearch/snapshots"
EOF

cat << EOF > /etc/systemd/system/meilisearch.service
[Unit]
Description=Meilisearch
After=systemd-user-sessions.service

[Service]
Type=simple
WorkingDirectory=/var/lib/meilisearch
ExecStart=/usr/local/bin/meilisearch --config-file-path /etc/meilisearch.toml
User=meilisearch
Group=meilisearch

[Install]
WantedBy=multi-user.target
EOF
```