Setting up CGI parameters and HTTP/2 Protocol

  • Make a group wadmins. This will help us in organizing the users on our server.
    • Open the terminal. Connect to the server with ssh. Execute
      sudo addgroup wadmins
    • Add mprogrammer (or your username if you chose a different one) and www-data to this group.
      sudo usermod -a -G wadmins mprogrammer
      sudo usermod -a -G wadmins www-data
  • Create a subfolder for a test website.
    • Execute
      sudo mkdir /var/www/html/test01
    • Change the group of the folder to wadmins
      sudo chgrp wadmins /var/www/html/test01
    • Change the mode of the folder to 770 or 775
      sudo chmod 770 /var/www/html/test01
    • Restart the server
      sudo reboot
  • Configure cgi
    • Log in back to the server with ssh
    • Execute
      sudo nano /etc/apache2/conf-available/cgi-enabled.conf
    • Type the following text
      <Directory "/var/www/html">
      Options +ExecCGI
          AddHandler cgi-script .cgi
      </Directory>
      
    • Execute
      sudo a2enconf cgi-enabled
      sudo systemctl reload apache2
    • Edit the file /etc/apache2/apache2.conf
      sudo nano /etc/apache2/apache2.conf
      Add the line to the end of the document
      LimitRequestBody 5500000
  • Install the programs necessary for HTTP/2 protocol.
    • sudo apt install php7.4-fpm
    • sudo a2enmod proxy_fcgi
    • sudo a2enconf php7.4-fpm
    • sudo a2dismod php7.4
    • sudo a2dismod mpm-prefork
    • sudo a2enmod mpm-event
  • Restart the apache2 program.
    sudo service apache2 restart
  • Enable the module http2.
    sudo a2enmod http2
    sudo systemctl restart apache2
  • Edit the file /etc/apache2/apache2.conf
    sudo nano /etc/apache2/apache2.conf
    Go to the end of the document and add the following line
    Protocols h2 http/1.1
  • Change the group of html to be wadmins.
    sudo chgrp -R wadmins /var/www/html
  • Install the libraries libcgicc-dev and libpng++-dev.
    sudo apt install libcgicc-dev
    sudo apt install libpng++-dev
  • Enable cgi.
    sudo a2enmod cgid
    sudo systemctl restart apache2