# Apache Setup Guide

## Apache Installation and Configuration Guide for Ubuntu

This guide provides a step-by-step process for installing and configuring Apache on an Ubuntu server. We will cover the installation of Apache, configuring the `AllowOverride` directive, and customizing the `000-default.conf` file.

### Table of Contents

1. Introduction
2. Prerequisites
3. Installation
4. Configuration
   * AllowOverride
   * 000-default.conf
5. Starting Apache
6. Testing Configuration
7. Laravel Project Setup
8. Conclusion

### Introduction

This guide provides a step-by-step process for installing and configuring Apache on an Ubuntu server. We will cover the installation of Apache, configuring the `AllowOverride` directive, and customizing the `000-default.conf` file.

### Prerequisites

* A server running Ubuntu 20.04 or later
* A user with sudo privileges

### Installation

1. **Update your package index:**

   ```bash
   sudo apt update
   ```
2. **Install Apache:**

   ```bash
   sudo apt install apache2
   ```

### Configuration

#### AllowOverride

The `AllowOverride` directive controls whether directives in `.htaccess` files override the main server configuration.

1. **Open the default configuration file:**

   ```bash
   sudo nano /etc/apache2/apache2.conf
   ```
2. **Find the `<Directory /var/www/>` section and modify the `AllowOverride` directive:**

   ```apache
   <Directory /var/www/>
       Options Indexes FollowSymLinks
       AllowOverride All
       Require all granted
   </Directory>
   ```
3. **Save and exit the file.**

#### 000-default.conf

The `000-default.conf` file contains the default virtual host configuration.

1. **Open the default virtual host configuration file:**

   ```bash
   sudo nano /etc/apache2/sites-available/000-default.conf
   ```
2. **Modify the file to include the desired configurations. Here is an example:**

   ```apache
   <VirtualHost *:80>
       ServerAdmin webmaster@localhost
       DocumentRoot /var/www/html

       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined

       <Directory /var/www/html>
           Options Indexes FollowSymLinks
           AllowOverride All
           Require all granted
       </Directory>

   </VirtualHost>
   ```
3. **Save and exit the file.**

### Starting Apache

1. **Enable the `mod_rewrite` module:**

   ```bash
   sudo a2enmod rewrite
   ```
2. **Restart Apache to apply changes:**

   ```bash
   sudo systemctl restart apache2
   ```

### Testing Configuration

1. **Create a `.htaccess` file in your document root:**

   ```bash
   sudo nano /var/www/html/.htaccess
   ```
2. **Save and exit the file.**
3. **Open your browser and navigate to `http://your-server-ip/test`. You should see the Apache default page if the configuration is correct.**

### CSS-BABS Project Setup

1. **Upload the `cssbans.zip` file to `/var/www/html`:**
   * Use an SFTP client or any other method to upload the `cssbans.zip` file to the `/var/www/html` directory on your server.
2. **Extract the `cssbans.zip` file:**

   ```bash
   cd /var/www/html
   sudo apt install unzip
   sudo unzip cssbans.zip
   ```
3. **Set the correct permissions:**

   ```bash
   sudo chmod -R 755 /var/www/html/cssbans
   ```

### Conclusion

You have successfully installed and configured Apache on your Ubuntu server, and set up a css bans project by uploading and extracting `cssbans.zip` to `/var/www/html`. The `AllowOverride` directive is set to `All` in both `apache2.conf` and `000-default.conf` to allow the use of `.htaccess` files. If you encounter any issues, check the Apache error logs for more details.

For more advanced configurations and optimizations, refer to the [official Apache documentation](https://httpd.apache.org/docs/2.4/).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://css-bans.gitbook.io/css-bans-counterstirkesharp-admin-web-panel/self-hosting-optional/apache-setup-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
