MicroHost

MicroHost

Did You Know?

How Can We Help?

Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started

How to Install Nginx and PHP-FastCGI on Fedora

Table of Content

In this article you will know How to Install Nginx and PHP-FastCGI on Fedora. The Nginx web server is a fast, light server that can handle the needs of both low-traffic and high-traffic websites well. It is often used to serve static content, but it can also handle pages that change.

The DevOps community loves Nginx the most when it comes to HTTP web servers. And programmers love the PHP programming language because it lets them build and launch interactive websites quickly.

Because of this, it's not surprising that so many system administrators have to set up Nginx, PHP, and PHP-FPM on both Linux and Windows servers.

Prerequesties:

  • A fedora installed server with yum repository configured.
  • A super user( root) or any normal user with SUDO privileges.

Install required packages

Run the commands for upgrading your framework and downloading the web server, PHP and compiler software of nginx:

[console]# yum install php php-cli nginx -y
# chkconfig --add nginx
# systemctl start nginx
# systemctl enable nginx [/console]

If you're done with the installation, you may want to ensure that nginx works via the server IP address. The default NGINX listing is to be provided.

Install Nginx and PHP-FastCGI on Fedora

Configure Your Site

Run the below commands to edit the default virtualhost of the site and add the highlighted content.

[console]# vi /etc/nginx/nginx.conf [/console]

server {
    listen       80;
    listen       [::]:80;
    server_name  _;
    root         /usr/share/nginx/html;
    location / {
    index index.html index.php;
    }
    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    error_page 404 /404.html;
    location = /404.html {
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
    location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass  127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/abc.com/www/public_html$fastcgi_script_name;
     }
}

Now place your website source code in '/usr/share/nginx/html' directory

Test PHP with FastCGI

To check whether you have enabled the php in your server, follow the below step.

Build a file in the "/var/www/html" directory named "info.php" with the following content:

[console]# vi /usr/share/nginx/html/info.php [/console]

<?php

phpinfo();

?>

The regular "PHP data" output is displayed when you go to http://server_ip/info.php in your browser.

Install Nginx and PHP-FastCGI on Fedora

I hope you now know about how to install Nginx and PHP-FastCGI on Fedora.

Thank for Reading......

Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started
Table of Contents