Migrating from Apache to NGINX

Last Updated on

NGINX has many benefits over Apache in a production environment including the ability to scale easier and lower system overhead.

1
sudo yum install nginx -y

New config file for NGINX derived from previous Apache configuration:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#/etc/nginx/sites-enabled/vassox
server {
listen 80;
listen [::]:80;

server_name www.vassox.com;

root /var/www/html/;
index index.html index.php;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}

location ~ /\.ht {
deny all;
}

}
Lima

About the author

Lima is the visual nautical indicator for "stop instantly."

Leave a Reply