So i want to create an apache2 webserver on debian using aws. I'm in needed to what to write so with the codes to make me see everything in order.
I tried installing apache2 and succeeded, but i do not know how to make the self signed certificate, but using the codes from the debian wiki didn't work.
You can set up an Apache2 web server on AWS Debian with SSL.
sudo apt update
sudo apt upgrade -y
sudo apt install apache2 -y
sudo a2enmod ssl
sudo a2enmod rewrite
sudo apt install openssl -y
sudo mkdir -p /etc/apache2/ssl
cd /etc/apache2/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/apache2/ssl/apache.key \
-out /etc/apache2/ssl/apache.crt
sudo nano /etc/apache2/sites-available/default-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
</IfModule>
sudo a2ensite default-ssl.conf
sudo nano /etc/apache2/sites-available/000-default.conf
Add this configuration:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
Redirect permanent / https://your-domain-or-ip/
</VirtualHost>
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
sudo apache2ctl configtest
sudo systemctl restart apache2
sudo systemctl status apache2