AWS · मराठी आवृत्ती
6.7 Config files ची रचना समजून घेऊ
या page मध्ये
Config म्हणजे web server ला दिलेल्या सूचना. इथे मोठा नकाशा पाहू; Chapter 8 मध्ये line by line.
Nginx
# /etc/nginx/nginx.conf (simplified)
user nginx; # www-data on Ubuntu
worker_processes auto; # one worker per CPU core
events { worker_connections 1024; }
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
include /etc/nginx/conf.d/*.conf; # your site files
# Ubuntu also has: include /etc/nginx/sites-enabled/*;
server { # default server block
listen 80;
server_name _;
root /usr/share/nginx/html;
location / { try_files $uri $uri/ =404; }
}
}
user worker identity; worker_processes workers; events connections; http मध्ये MIME/logs/includes; server म्हणजे site; root files चा folder; location URL path हाताळतो. हे simplified example आहे. Effective default server फक्त server_name _ मुळे ठरत नाही; listen/default_server आणि block order महत्त्वाचे.
Apache
# /etc/httpd/conf/httpd.conf (AL2023/CentOS, simplified)
Listen 80
User apache
Group apache
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Options Indexes FollowSymLinks
# change None to All to allow .htaccess files
AllowOverride None
Require all granted
</Directory>
ErrorLog "logs/error_log"
IncludeOptional conf.d/*.conf
Listen port, User/Group process identity, DocumentRoot folder आणि Directory permissions. AllowOverride None असेल तर .htaccess बंद; आवश्यक directives पुरतं override द्या. Options Indexes मुळे directory listing शक्य; production मध्ये गरज नसेल तर बंद करा.
Chapter 8 मध्ये root, ports आणि virtual hosts सविस्तर बदलू.
Lab
sudo grep -v '^\s*#' /etc/nginx/nginx.conf | grep -v '^$' ने config वाचा. user, worker_processes, include आणि root चा अर्थ स्वतः लिहा.