How do I configure Nginx or Apache on Linux

To configure Nginx or Apache on Linux, you need to follow several steps depending on which web server software you prefer to use. Below are basic examples for configuring both Nginx and Apache:

Nginx Configuration Example

Here is a simple Nginx configuration file that serves a static website:

server { listen 80; server_name example.com; root /var/www/html; index index.html index.htm; location / { try_files $uri $uri/ =404; } }

Apache Configuration Example

Below is a basic configuration for Apache that serves a static site:

ServerAdmin webmaster@example.com DocumentRoot /var/www/html ServerName example.com Options Indexes FollowSymLinks AllowOverride None Require all granted ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

Nginx configuration Apache configuration Linux web server setup web server configuration static website hosting