# 7.7 Combination 2: AL2023 + Apache

Source: https://ravindrabagale.com/mr/aws/ch07-static-website-hosting-3-oses-2-web-servers/7-7-combination-2-amazon-linux-2023-apache.html
Language: mr (Marathi with English technical terms)

आधी Nginx stop/disable करून port 80 मोकळा करा, मग Apache:

sudo service nginx stop 2>/dev/null     # free port 80 if Nginx was installed
sudo systemctl disable nginx 2>/dev/null
sudo yum install -y httpd
sudo service httpd start
sudo systemctl enable httpd

sudo tee /etc/httpd/conf.d/mysite.conf > /dev/null <<'EOF'
<VirtualHost *:80>
    ServerName mysite.local
    DocumentRoot /var/www/mysite
    <Directory /var/www/mysite>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorDocument 404 /404.html
    ErrorLog  /var/log/httpd/mysite_error.log
    CustomLog /var/log/httpd/mysite_access.log combined
</VirtualHost>
EOF

sudo apachectl configtest && sudo service httpd reload
curl -s http://localhost | head -5

Apache site कसा निवडतो?

एकाच address:port साठी Host जुळला नाही तर पहिला loaded vhost default होतो. इथे तो एकमेव असेल तर public IP requests देखील त्याच्याकडे येतात. Domain मिळाल्यावर योग्य ServerName/ServerAlias www.example.com द्या.

Options -Indexes म्हणजे index नसताना folder list दाखवू नका. AllowOverride All मुळे .htaccess परवानगी; साध्या static site ला गरज नसेल तर None ठेवा. WordPress चे rules main config मध्येही ठेवता येतात.

Lab

Localhost वर page पाहा. फक्त lab मध्ये index.html तात्पुरतं index.bak करा, curl -I ने listing ऐवजी 403 येतो का पाहा आणि नाव लगेच परत ठेवा.

रवींद्र बागले यांची tip

Config line copy करताना अर्थ समजून घ्या. Static content ला सर्व .htaccess overrides देण्याची गरज नसते.
