How to install fcgiwrap for Nginx on Ubuntu 20.04
Fcgiwrap is a simple server used to run CGI applications via FastCGI. We can use it to provide clean CGI support for nginx webserver. It is a lightweight server with zero configuration options, allowing to use the same group to run different websites. Here's how to install fcgiwrap on Ubuntu 20.04.
CGI (Common Gateway Interface) is the original method for creating dynamic websites. The instructions below assume that you have installed and configured the Nginx server on Ubuntu Linux 20.04 LTS.
Install fcgiwrap on Ubuntu 20.04
Open a terminal and enter the following commands to update security installed packages on Ubuntu 20.04:
$ sudo apt update $ sudo apt upgrade
To install fcgiwrap packages for Nginx, run the following command as root user with the help of [nixmcd name = 'apt']:
$ sudo apt install fcgiwrap
Enable fcgiwrap service on Ubuntu 20.04
Use the systemctl command as follows:
$ sudo systemctl enable fcgiwrap $ sudo systemctl start fcgiwrap $ sudo systemctl status fcgiwrap
Configure fcgiwrap for Nginx
Now we have fcgiwrap installed, followed by creating a new configuration for the FastCGI file:
sudo nano /etc/nginx/fcgiwrap.conf
Connect the following configurations:
location /cgi-bin/ { # Disable gzip (it makes scripts feel slower since they have to complete # before getting gzipped) gzip off; # Set the root to /usr/lib (inside this location this means that we are # giving access to the files under /usr/lib/cgi-bin) root /usr/lib; # Fastcgi socket fastcgi_pass unix:/var/run/fcgiwrap.socket; # Fastcgi parameters, include the standard ones include /etc/nginx/fastcgi_params; # Adjust non standard parameters (SCRIPT_FILENAME) fastcgi_param SCRIPT_FILENAME /usr/lib$fastcgi_script_name; }
Edit nginx.conf or virtual domain file. For example:
sudo nano /etc/nginx/nginx.conf ## OR ## sudo nano /etc/nginx/sites-enabled/default
Next, locate the server and add the following directive:
## Trun on /cgi-bin/ support to run CGI apps ## include /etc/nginx/fcgiwrap.conf;
Save and close the file. Reload or restart the Nginx server:
$ sudo nginx -t $ sudo nginx -s reload
Writing basic CGI scripts
Writing a basic CGI script using FastCGI is quite simple. First, we have to create a cgi-bin directory in / usr / lib / using the mkdir command:
$ sudo mkdir -vp /usr/lib/cgi-bin/ mkdir: created directory '/usr/lib/cgi-bin/'
Hello World CGI Script in Bash

Open a text editor and create the following file:
sudo vi /usr/lib/cgi-bin/hello.cgi
Append the following bash code:
#!/usr/bin/env bash echo "Content-type: text/html" echo "" now="06/07/2020" echo 'Hello World - CGI app' echo '' echo '
Hello World!
' echo "Computer name : $HOSTNAME
" echo "The current date and time : ${now}
" echo '' echo ''
Set execution rights on /usr/lib/cgi-bin/hello.cgi with chmod and chown:
$ sudo chmod +x -v /usr/lib/cgi-bin/hello.cgi mode of '/usr/lib/cgi-bin/hello.cgi' changed from 0644 (rw-r--r--) to 0755 (rwxr-xr-x)
Check by opening the web browser and entering the url:
https://your-domain-here/cgi-bin/hello.cgi ## For instance ## https://www.cyberciti.biz/cgi-bin/hello.cgi
You can write CGI applications or scripts in any programming language. CGI for applications / scripts can appear simple and easy, but to write those applications is not simple.
You should read it
- 12 best Linux server operating systems
- Distinguish Ubuntu and Linux Mint
- 3 Linux mobile operating systems you can install today
- 10 reasons to switch to Linux right in 2012
- How to Install Ubuntu Linux
- Pop! _OS What is it? Is it like Ubuntu?
- Tips and tricks after installing Ubuntu
- How to create dual boot Linux and Windows 10 on Linux
May be interested
- How to Install CyberPanel on Ubuntu 20.04cyberpanel is a control panel designed to be user-friendly for non-technical users. cyberpanel is easy to learn as it uses a simple layout that most hosting companies are familiar with.
- Instructions for installing Ubuntu on VMware Workstation - Part 2in the previous section of the article, we jointly established vmware and ubuntu desktop. and the next section below, please continue with the steps to install ubuntu desktop on vmware workstation.
- 5 things to do when installing Ubuntu on PCubuntu is a powerful linux distribution suitable for a wide variety of use cases, ideal for both beginners and seasoned linux users.
- How to install µTorrent (uTorrent) in Ubuntu 20.04µtorrent provides clients for windows and macos x, however it is installed as a server in ubuntu linux and provides a web ui for managing downloads.
- How to Install Ubuntu Linux Without CD (Windows)want to install ubuntu on your windows computer, but don't have a dvd or cd drive? there are a couple of different ways that you can install ubuntu on computers that don't have disc drives. the most common way is to create a bootable usb...
- How to Install ClickHouse on Ubuntu 22.04clickhouse is a modern, fast and open source database management system used for online analytical processing (olap).
- How to install MySQL on Ubuntu 20.04in this article, tipsmake will show how to install mysql version 8.0 on ubuntu 20.04 server. by completing it, you'll have an active relational database that can be used to build your next website or app.
- How to install AVG Antivirus on Ubuntuin addition to windows, you can install avg antivirus on ubuntu easily and quickly to ensure that damage is minimized in the most optimal way. along with tipsmake, see how to install avg antivirus on ubuntu below.
- How to install Ubuntu on a VMware virtual machinehow to install ubuntu on a vmware virtual machine. ubuntu is a very popular operating system nowadays parallel to windows and macos. but ubuntu still makes many users wonder before upgrading should use on their own computers, so we still have a way to experience ubuntu.
- Ways to install Ubuntu on Windows, run in parallel or run separatelythere are many ways to install ubuntu on your computer, such as installing ubuntu from usb, cd, installing ubuntu running in parallel with windows, installing it