How to Install code-server on Ubuntu Server Latest

This tutorial will guide you through the installation process of code-server on Ubuntu Server Latest.

Prerequisites

Before starting the installation process, make sure you have the following prerequisites:

Step 1: Update the system

To avoid potential conflicts, we need to update the system before installing any new software.

Start by logging in to your Ubuntu Server Latest machine and executing the following command in a terminal or via SSH:

sudo apt-get update
sudo apt-get upgrade

This will update the package lists and upgrade any outdated software on your machine.

Step 2: Install Node.js

code-server requires Node.js to run. To install it, execute the following command:

sudo apt-get install nodejs

Once the installation is complete, verify the installation by checking the installed version:

node -v

If the command returns the version number of Node.js, you are good to go.

Step 3: Install code-server

To install code-server, you can use the prebuilt binaries or compile the source code yourself. For this tutorial, we will be using the prebuilt binaries.

Execute the following command to download the latest version of code-server:

curl -fsSL https://code-server.dev/install.sh | sh

This will download and execute the installation script. Wait for the installation to complete. Once it's done, you should see a message that looks like this:

To have code-server start at boot, run:
  sudo systemctl enable --now code-server@$USER
Installation complete!

This message confirms that code-server is now installed on your machine.

Step 4: Configure code-server

By default, code-server runs on port 8080. You can change this by creating a configuration file at ~/.config/code-server/config.yaml.

To make code-server available on port 80, add the following line to the configuration file:

bind-addr: 0.0.0.0:80

Note that running code-server on port 80 requires root privileges. You can either start code-server as root or use a reverse proxy like NGINX to proxy requests to port 80.

For more information on configuring code-server, refer to the official documentation.

Step 5: Start code-server

To start code-server, execute the following command:

code-server

This will start code-server and display a URL that you can use to access the web interface.

Conclusion

Congratulations! You have successfully installed and configured code-server on your Ubuntu Server Latest machine. You can now use code-server to write and edit code from anywhere with a web browser.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!