Top Left Text cha

Website Development Services

These instructions are specifically for Nginx.  Unlike Apache, Nginx doesn't contain a native PHP processor so PHP-FPM (PHP fastCGI processing manager), so it will need to be installed manually.

Install php-fpm, php-mysql, and other modules that may be needed.  Some of these can be left off if they won't be used.  But if not sure, it won't hurt to install all of them as so...
sudo apt-get install php-fpm php-mysql php-curl php-gd php-pear php-imagick php-imap php-mcrypt php-recode php-tidy php-xmlrpc

Php-fpm will need to be configured.  Open the configuration file and edit with nano.
sudo nano /etc/php/7.0/fpm/php.ini

Find cgi.fix_pathinfo.  It will be commented out with a semicolon like:
;cgi.fix_pathinfo=1

Uncomment it and change the value to 0.  This is required for the security of your PHP files.  It should look like this after:
cgi.fix_pathinfo=0
Save and close the file.

Restart the PHP processor.
sudo systemctl restart php7.0-fpm

Configure Nginx to use the new PHP processor (php-fpm)

Open the Nginx default server configuration file with nano.
sudo nano /etc/nginx/sites-available/default
Below is an example of the most recent block regarding php-fpm in the file.  Don't forget to add index.php to the index...
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name [your ip should be here];

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


# pass the PHP scripts to FastCGI server listening on ...
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;

# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
  • No comments found

Leave your comments

Post comment as a guest

0
Your comments are subjected to administrator's moderation.
X