Setting up GraphQL server on Ubuntu

Setting up GraphQL server can be a daunting task if you don’t know the  steps, because, lot’s of time goes into trial and error to find out the exact steps. So here I am going to jot down the steps need to set up GraphQL on Ubuntu server.

I will be using Mysql as the database and thus I will also install Phpmyadmin to manage the database. To install  Phpmyadmin we either need LAMP stack or LEMP stack. We will go for LEMP stack because we might need Nginx as reverse proxy for our Node application.

I am using Digital Ocean and it has one click install of LEMP server, so, I will install LEMP using one click install feature. You can find out newly installed MySql password by using command below :

Next, I will stall phpmyadmin using the command below :

And enable the PHP mcrypt and mbstring extensions using the command below :

Now, we need to create symbolic link of phpmyadmin we just installed, in nginx publicly accessible directory, so that nginx web server can find phpmyadmin. Using the command below we create phpmyadmin symbolic link :

So we have completed phpmyadmin installation. You can check installation by opening the url http://dropletipaddress/phpmyadmin, where you need to replace your droplet’s ip address with ‘dropletipaddress’ in the url .  To login enter ‘root’ as username and MySql password that we found above.

Next, we will install Nodejs using the command below :

In the above command instead of 9.x you can use the latest available node js version. To check the version of nodejs that has been installed use the command below:

Next, we will install PM2, Nodejs application process manager, that will run our node app in background. Use the command below to install PM2 :

Next, we will open a port on Ubuntu to run our Node application using the command below :

So, I have opened port 4000 and we can run our app on port 4000 and access it.

Now, we can transfer our GraphQL app on server and run it with the command below :

To access graphiql and test some queries go to following url :


In the above url you need to replace your droplet’s IP address with ‘dropletipaddress‘.

Video Tutorial