Aim:
Install Apache HTTP Server 2.4.x using the binary distribution and configure it for various purposes.
Installation Steps
Step 1: Download and Extract Apache HTTP Server
- Download the Apache HTTP Server 2.4.x binary distribution from the official website.
- Extract the downloaded tarball:
tar xvf httpd-2.4.x.tar.gz
Step 2: Configure and Install Apache HTTP Server
- Navigate to the extracted directory:
cd httpd-2.4.x
- Configure Apache with necessary modules and options:
./configure --enable-proxy --enable-proxy-http --enable-ssl --enable-rewrite
- Compile and install Apache:
make
sudo make install
Step 3: Configure Forward Proxy
- Edit Apache configuration file to enable forward proxy:
sudo nano /usr/local/apache2/conf/httpd.conf
- Add the following lines:
ProxyRequests On
ProxyVia On
ProxyTimeout 300
Step 4: Configure Reverse Proxy to Apache Tomcat
- Edit Apache configuration file:
sudo nano /usr/local/apache2/conf/httpd.conf
- Add the following lines for reverse proxy to Apache Tomcat:
ProxyPass "/tomcat/" "http://localhost:8080/"
ProxyPassReverse "/tomcat/" "http://localhost:8080/"
Step 5: Configure Virtual Host
- Edit Apache configuration file:
sudo nano /usr/local/apache2/conf/httpd.conf
- Add virtual host configuration:
<VirtualHost *:80> ServerName example.com DocumentRoot /path/to/document/root </VirtualHost>
Step 6: Configure Rewrite Rules
- Edit Apache configuration file:
sudo nano /usr/local/apache2/conf/httpd.conf
- Add rewrite rules as needed:
RewriteEngine On
RewriteRule ^/old-path$ /new-path [R,L]
Step 7: Enable SSL
- Generate SSL certificate and key (if not already generated).
- Edit Apache configuration file:
sudo nano /usr/local/apache2/conf/httpd.conf
- Add SSL configurations:
SSLEngine On
SSLCertificateFile /path/to/certificate.crt
SSLCertificateKeyFile /path/to/private-key.key
Verification:
Verify the Apache configuration and restart the server:
sudo /usr/local/apache2/bin/apachectl configtest
sudo /usr/local/apache2/bin/apachectl restart
To start the server in the installed folder, open the terminal and type:
/usr/local/apache2/bin/apachectl -k start
Comments
Post a Comment