···2121* [Canonical TypeScript code](https://github.com/bluesky-social/atproto)
2222* [Experimental Go code](https://github.com/bluesky-social/indigo)
23232424-## Self-hosting a PDS
2424+## Self-hosting PDS
25252626Self-hosting a Bluesky PDS means running your own Personal Data Server that is capable of federating with the wider Bluesky social network.
27272828-### Launch your server
2828+### Preparation for self-hosting PDS
29293030Launch a server on any cloud provider, [Digital Ocean](https://digitalocean.com/) and [Vultr](https://vultr.com/) are two popular choices.
3131+3232+Ensure that you can ssh to your server and have root access.
31333234**Server Requirements**
3335* Public IPv4 address
···3537* Public inbound internet access permitted on port 80/tcp and 443/tcp
36383739**Server Recommendations**
3838-3940| | |
4041| ---------------- | ---------------- |
4141-| Operating System | Ubuntu 22.04 LTS |
4242+| Operating System | Ubuntu 22.04 |
4243| Memory (RAM) | 2+ GB |
4344| CPU Cores | 2+ |
4445| Storage | 40+ GB SSD |
4546| Architectures | amd64, arm64 |
46474747-### Install your server
4848-4949-Install your Ubuntu 22.04 server, and then ensure that you can ssh to it.
5050-5148**Note:** It is a good security practice to restrict inbound ssh access (port 22/tcp) to your own computer's public IP address. You can check your current public IP address using [ifconfig.me](https://ifconfig.me/).
52495353-### Open your firewall
5050+### Open your cloud firewall for HTTP and HTTPS
54515552One of the most common sources of misconfiguration is not opening firewall ports correctly. Please be sure to double check this step.
56535757-It may be helpful to use a remote [port scanning](https://dnschecker.org/port-scanner.php) service to verify that access is permitted. Once your server is fully configured, this service should display the ports as open.
5858-5959-#### Open ports on your cloud provider's firewall
6060-6154In your cloud provider's console, the following ports should be open to inbound access from the public internet.
62556356* 80/tcp (Used only for TLS certification verification)
···65586659**Note:** there is no need to set up TLS or redirect requests from port 80 to 443 because the Caddy web server, included in the Docker compose file, will handle this for you.
67606868-#### Open ports on your Linux firewall
6969-7070-If your server is running a Linux firewall managed with `ufw`, you will also need to open these same ports on the server itself.
7171-7272-```bash
7373-$ sudo ufw allow 80/tcp
7474-$ sudo ufw allow 443/tcp
7575-```
7676-7761### Configure DNS for your domain
78627963From your DNS provider's control panel, set up a domain with records pointing to your server.
···8973* Some providers may use the `@` symbol to represent the root of your domain.
9074* The wildcard record is required when allowing users to create new accounts on your PDS.
91757676+7777+7878+## Automatic install on Ubuntu 22.04 or Debian 11
7979+8080+On your server via ssh, run the installer script:
8181+8282+```bash
8383+curl https://raw.githubusercontent.com/bluesky-social/pds/main/installer.sh | sudo bash
8484+```
8585+8686+## Installing manually on Ubuntu 22.04
8787+8888+### Open ports on your Linux firewall
8989+9090+If your server is running a Linux firewall managed with `ufw`, you will also need to open these same ports on the server itself.
9191+9292+```bash
9393+$ sudo ufw allow 80/tcp
9494+$ sudo ufw allow 443/tcp
9595+```
9696+9297### Install Docker
93989499On your server, install Docker CE (Community Edition), using the the following instructions. For other operating systems you may reference the [official Docker install guides](https://docs.docker.com/engine/install/).
···211216* `watchtower` Daemon responsible for auto-updating containers to keep the server secure and federating
212217213218```bash
214214-curl https://raw.githubusercontent.com/bluesky-social/pds/main/compose.yaml >compose.yaml
219219+curl https://raw.githubusercontent.com/bluesky-social/pds/main/compose.yaml | sudo tee /pds/compose.yaml
215220```
216221222222+#### Create the systemd service
223223+224224+```bash
225225+ cat <<SYSTEMD_UNIT_FILE >/etc/systemd/system/pds.service
226226+[Unit]
227227+Description=Bluesky PDS Service
228228+Documentation=https://github.com/bluesky-social/pds
229229+Requires=docker.service
230230+After=docker.service
231231+232232+[Service]
233233+Type=oneshot
234234+RemainAfterExit=yes
235235+WorkingDirectory=/pds
236236+ExecStart=/usr/bin/docker compose --file /pds/compose.yaml up --detach
237237+ExecStop=/usr/bin/docker compose --file /pds/compose.yaml down
238238+239239+[Install]
240240+WantedBy=default.target
241241+SYSTEMD_UNIT_FILE
242242+```
217243218218-#### Run docker compose
244244+#### Start the service
219245220220-Run `docker compose up` to start the three required containers.
246246+```bash
247247+sudo systemctl daemon-reload
248248+```
221249222250```bash
223223-sudo docker compose up --wait --detach
251251+sudo systemctl start pds
224252```
225253226226-You should see output similar to this:
254254+**Ensure that containers are running**
227255256256+There should be a caddy, pds, and watchtower container running.
257257+258258+```bash
259259+sudo systemctl status pds
228260```
229229-[+] Running 3/3
230230- ✔ Container watchtower Healthy 1.1s
231231- ✔ Container pds Healthy 1.1s
232232- ✔ Container caddy Healthy 1.0s
261261+262262+```bash
263263+sudo docker ps
233264```
234265235266### Verify your PDS is online
···2482791. Download the Bluesky app
2492801. Enter the URL of your PDS (e.g. `https://example.com/`)
2502811. Create an account
282282+1. Create a post
251283252284## PDS environment variables
253285