How to Install VS Code-Server on AlmaLinux | Rocky Linux 8

Install Code-Server on Almalinux 8 or Rocky Linux 8 server to run VS Code using Web browser with the help of command terminal and script.

Microsoft Visual Studio Code is a free editor for various different but popular programming languages. Code-Server is an open source platfrom that includues VS Code to run with a server-side process in the browser.  This platform uses is a web server that can be started from any location and then accessed via a browser. The editor then works on the server-side file system. Microsoft doesn’t allow access to its own marketplace, although most of the extensions found there are open source therefore, the user can install them directly from the web inteface of Code-Server, further, installation of extensions is also possible by directly importing VSIX package.

To start working with Code Server- we just only need to start its instaces installed either on cloud, desktop, laptop, server, container or virtual machine. Network access to it is of course also necessary.

 

Steps to install VS Code-Server on Almalinux 8 or Rocky Linux 8

The commands given here can be used on other Redhat based Linux systems such as CentOS, Oracle Linux… running locally or on cloud (AWS, GCP, DigitalOcean etc.).

1. Requirements

There is no unique requirement to install Code-Server, just the regular ones:

Almalinux | Rocky Linux |Redhat | CentOS server or desktop
A non-root user with sudo rights
1 GB of RAM coupled with 2 CPU cores

 

2. Run system update

As usual before starting any tutorial run the system update command to ensure all the installed packages are up to date. This will also reresh the system repository cache.

sudo dnf update -y

Also install Curl & nano tool

sudo dnf install curl nano -y

 

3. Install Code-server on AlmaLinux or Rocky 8

Instead of downloading Code-Server RPM package manbaully, let use the script that automciatlly fetch the required packages and after that installs the same. Hence, less manual work need to do.

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

Wait for few seconds, the script will setup everything including the systemd service for VS Code server.

Install vs code server rocky or Almalinux 8

 

4. Start Systemd VS Code-server service

Once the script completed the process, we have to start the service created by it for Code-Server. Witthout starting it we won’t be able to access this web-based VS code editor.

sudo systemctl start [email protected]$USER

In case those who want to start its service automatically with system boot, they also need to enable it; here is the command:

sudo systemctl enable [email protected]$USER

To check the status:

sudo systemctl status [email protected]$USER

 

5. Access VS Code Web Interface

By default, the VS code server will only allow to access its web interface using the localhost, hence, if you are using a CLI server or want to access VS code out side your home or office network then edit its YML file. It is a configuration file.

nano ~/.config/code-server/config.yaml

Change 127.0.0.0 to 0.0.0.0.

Access VS Code Server Web Interface

Save the file Ctrl+O, hit the Enter and then use Ctrl+X to exit.

Restart Code server service:

sudo systemctl restart [email protected]$USER

 

6. Allow ports in Firewall

The default port used by Code-Server is 8080, we need to open it in the system firewall to access VS Code remotely. Also, if you are planning to use some domain name over http/https, then open port 80 & 443 as well.

sudo firewall-cmd --add-port={8000,80,443}/tcp --permanent

To apply change refresh the firewall.

sudo firewall-cmd --reload

Now, open any web bowser and point it to the serevr IP-address along port 8080 where you have installed the Code-server Instance.

For example:

http://server-ip-addres:8080

Note: server-ip-addres replace wiht your actual address.

 

6. Login Code Server running on Almalinux | Rocky Linux 8

You would already have the login interface of Code Server. There you have to enter the password which you will get again in the YML confgiuration file:

nano ~/.config/code-server/config.yaml

Copy the password given in the file and enter to login.

VS code server login password

 

VS code server installation on Almalinux or Rocky Linux 8

 

7. How to upgrade

Well this VS code web platform has not been installed using the system repsitory, hence, it is not possible to update or upgrade Code-Server using the dnf update commnad. Therefore whenever you want to install the latest version, simply run the follwing script.

Don’t worry this will not remove user data resides in ~/.local/share/code-server

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

 

8. Use Let’s Encryot with Nginx

Well, if you are planning to use already exists sub-domain & Cloudflare then you don’t need Nginx or Let’s necrypt; simply point A record of your DNS to yoru Serevr ip-address.

Nevertheles, if you own DNS and Domain to use with Code-Server then install Nginx as a reverse proxy and then Let’s encrypt, here is the offcial Guide on it.

 

9. Uninstall or Remove Code-server

When you don’t require this VS code server on your system anymore then completely remove the same using the dnf package manager.

sudo dnf remove code-server

Delete data:

rm -rf ~/.local/share/code-server ~/.config/code-server

rm -rf ~/.local/lib/code-server-*

 

Other Articles:

Install Code-Server for VS code on Ubuntu 22.04 or 20.04 LTS
2 Ways to install VS code on Debian 11 Bullseye Linux
4 Ways to install VS Code Editor on Ubuntu 22.04 | 20.04 LTS

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.