This article will show you how to configure an NGINX server to serve PHP applications such as the Multicraft panel. To follow this guide you will first need to SSH into your Dedicated Server

Installing NGINX

To install NGINX you will need to run the following sequence of commands:

yum update -y
yum remove -y httpd - Removes the default Apache webserver
yum install -y epel-release
yum install -y nginx
systemctl enable --now nginx
If your machine uses firewalld, run firewall-cmd --zone=public --permanent --add-service=http; firewall-cmd --zone=public --permanent --add-service=https; firewall-cmd --reload;

After this you should be able to type the machine's IP into your browser to see an NGINX example page

Installing PHP

yum install -y yum-utils
yum-config-manager --enable remi-php73
yum install -y php php-fpm php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd
sed -i 's/user = .*/user = nginx/' /etc/php-fpm.d/www.conf; sed -i 's/group = .*/group = nginx/' /etc/php-fpm.d/www.conf - Fixes the permissions on the webserver
chown -R root:nginx /var/lib/php/session
systemctl enable --now php-fpm
mkdir /etc/nginx/includes
Place the following file as /etc/nginx/includes/php.conf:

location ~ .php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

Making your first NGINX config

Each individual website you would like to run, needs to have an NGINX config to serve it, and a folder on the system for the files to go in. In this tutorial we will set up, so replace this for your domain in each command

mkdir -p /var/www/; echo "<?php phpinfo(); ?>" > /var/www/ - Makes the folder and a test PHP file
Make sure you have set up an A Record pointing to your dedicated server's IP, on the domain
Add a file at /etc/nginx/conf.d/ with the following contents:

server {
listen 80;
listen [::]:80;
index index.php index.html index.htm;
location / {
root /var/www/;
include includes/php.conf;

systemctl restart nginx - Allows NGINX to pick up the new configuration file
Browse to in your browser - it should show the test file!
rm -rf /var/www/ - Remove the test file and upload your real website files
chown -R nginx:nginx /var/www - Run this after any file changes to ensure permissions are configured correctly
Was this article helpful?
Thank you!