Ravindra Bagale · AWSसर्व coursesया course चे lessonsशोधाEnglish

AWS · मराठी आवृत्ती

7.7 Combination 2: AL2023 + Apache

रवींद्र बागले यांच्या course वर आधारित · सहज मराठीत explanation

या page मध्ये

आधी 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 येतो का पाहा आणि नाव लगेच परत ठेवा.