How To Enable or Disable CGI Scripts in Apache?
Last Updated :
24 Apr, 2025
This article will guide you on how to enable or disable CGI scripts in Apache. Configuring CGI scripts in Apache is a crucial aspect of managing dynamic content generation on web servers. The Common Gateway Interface (CGI) provides a standardized protocol for executing programs, allowing websites to produce dynamic output. Whether enabling or disabling CGI scripts, Apache's configuration plays a pivotal role. This article guides you through the necessary steps to seamlessly control the execution of CGI scripts on your Apache server, ensuring a tailored and secure environment for dynamic web content in Python.
Enable or Disable CGI Scripts in Apache
To enable or disable CGI scripts in Apache, we will create a sample CGI script and demonstrate the straightforward steps for both enabling and disabling CGI scripts. Follow the outlined steps below to gain a clear understanding of how to manage CGI script execution in Apache.
Create Folder
First, create a folder named “GeeksforGeeks” in the “htdocs” directory. Inside this “GeeksforGeeks” folder, create two files: “html.html” and “python.py”. In the “html.html” file, design the registration form.
In the “python.py” file, write a CGI script to retrieve data from the registration form and generate a card with a success message.

Write HTML Code
This HTML code defines a webpage with a title, "Welcome to GeeksforGeeks," and a form that collects user input for a name. The form has a submit button, and the page includes some basic styling using inline CSS to set the color of the heading and style the form elements.
The form is set to submit data to a Python script named "python.py" using the POST method.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Welcome to GeeksforGeeks</title>
<style>
/* Style for the "GeeksforGeeks" heading */
h2{
color: green;
}
/* Style for form labels and input fields */
label {
display: block;
margin-bottom: 5px;
}
input[type="submit"] {
background-color: green;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<h2>Welcome to GeeksforGeeks</h2>
<div class="form-container">
<h3>fill below data</h3>
<form action="python.py" method="post">
<label for="name">Name:</label>
<input type="text" name="name" required><br><br>
<input type="submit" name="Register">
</form>
</div>
</body>
</html>