Site hosted by Angelfire.com: Build your free website today!
Install APACHE on Linux

--Installing on Fedora/CentOS/Red Hat Enterprise Linux.

sudo yum install httpd
sudo systemctl enable httpd
sudo systemctl start httpd

--Installing on Ubuntu/Debian/Mant.

sudo apt install apache2
sudo service apache2 start --> To start apache server.
sudo service apache2 stop --> To stop apache server.
sudo service apache2 restart --> To restart apache server.

I am using Mint 19 and Apache2 2.4

--Did it work?
Open your web braser and type localhost in the address bar.
If it did you will see "Apache2 Ubuntu Default Page".

--Will apache run cgi scripts. No.
You can change the index.html file and add html file.
But not CGI scripts.

--Getting Apache to run CGI script.
All the files that need to be edited are root access only.
Menu (Bottem left conner of your desktop) -> Sisten Tools -> Terminal. Open it.
New we need a root text editor. To do this you need to know the name of yours.
Menu -> System Tools -> Text Editor.
Right-click Edit Properties on the command line is the name of your text editor.
I have both gedit and xed. I will use gedit.
In the terminal type sudo gedit .
New you have a root editor. Don't close the terminals.
In the terminal File -> Open Tab. For more terminal tabs.

--We need to change the system's hosts file.
In the root text editor. Open /etc/hosts.
In the hosts file add the line 127.0.0.1 myserver.loc
If you use an other servicer name then myserver.loc. That fine.
Your Form's Action line will need to be changed. To reflact that.

--In the root editor open /var/www/html/index.html and save it as Docs.html.
Open /var/www/html/index.html agen and delete every thing in it and add
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>

<CENTER>My Web Server</CENTER>
<FORM ACTION="http://myserver.loc/cgi-bin/CGI_Test1.pl" METHOD="POST">
<INPUT TYPE="SUBMIT" VALUE="CGI_Test1.pl"></CENTER>
</FORM>



myserver.loc </body> </html>

--New we need a directory. Open a terminal and type sudo mkdir /var/www/cgi-bin
This is ware your CGI scripts go.
--We need a script to test the server.
In the terminal type sudo apt-get install perl
It shud be installed. But if not it is new.
--We will create a CGI script.
In your root editor. Create a new document.
#!/usr/bin/perl -T
print "Content-type: text/html\n\n";
print "Hello, World.\n";
Save as /var/www/cgi-bin/CGI_Test1.pl

--Copy the /etc/apache2/sites-available/000-default.conf to /etc/apache2/sites-enabled/myserver.loc.conf
Or what every you put in the hosts file with the extension .conf .
In your root editor open /etc/apache2/sites-enabled/myserver.loc.conf.
Add the following lines.
    ServerAdmin webmaster@myserver.loc
    DocumentRoot /var/www/html
	
    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    <Directory "/var/www/cgi-bin">
             AllowOverride None
             Options +ExecCGI
             AddHandler cgi-script .cgi .pl .php .sh .py
             Require all granted
    </Directory>
Save it.

In the terminal tab type sudo chown -R www-data:www-data /var/www
sudo chmod -R 775 /var/www/html
sudo chmod 775 /var/www/cgi-bin/CGI_Test1.pl
sudo a2enmod cgi
Reboot.

After reboot open the terminal and type.
sudo /etc/init.d/apache2 start
Open your web browser and enter 127.0.0.1
Press the link myserver.loc
CGI_Test1.pl button.
Did it work? I hope so.