How to Install Nginx With PHP-FPM And MySQL On Fedora 16 “Verne”

Nginx is a free, open-source, high-performance HTTP server. Nginx is known for its stability, rich feature set, simple configuration, and low resource consumption. This tutorial shows how to install Nginx on an Fedora 16 with PHP5 support (through PHP-FPM) and MySQL support. PHP-FPM is an alternative PHP FastCGI implementation. it has some additional features useful for sites of any size, especially busier sites).
The first thing you need to do is to login as root. You can login as root in Fedora by typing in the terminal:

Installing MySQL 5:

Step 3: To make the MySQL to start during the every boot, Type the following on terminal and hit Enter.

[root@geesksite~/]# systemctl enable mysqld.service

Next is to make the MySQL secure by using the mysql_secure_installation command.

This program enables you to improve the security of your MySQL installation in the following ways:

You can set a password for root accounts.

You can remove root accounts that are accessible from outside the local host.

You can remove anonymous-user accounts.

You can remove the test database (which by default can be accessed by all users, even anonymous users), and privileges that permit anyone to access databases with names that start with test_.

[root@geeksite~/]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we’ll need the currentpassword for the root user. If you’ve just installed MySQL, andyou haven’t set the root password yet, the password will be blank,so you should just press enter here.

By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.

Remove anonymous users? [Y/n] <– ENTER … Success!

Normally, root should only be allowed to connect from ‘localhost’. Thisensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <– ENTER … Success!

By default, MySQL comes with a database named ‘test’ that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.

Test Your Nginx installation by opening your web browser and Navigate to http://127.0.0.1. You will get the following web page saying “Welcome to Nginx on Fedora!“.

The default nginx document root on Fedora 16 is /usr/share/nginx/html. The configuration files are under /etc/nginx directory.

Auto-Start the Nginx.

[root@geeksite~/]# systemctl enable nginx.service

Installing PHP5-FPM:

Next is to install PHP5 through PHP-FPM (PHP-FPM (FastCGI Process Manager), it is an alternative PHP FastCGI implementation. it has some additional features useful for sites of any size, especially busier sites). Install it by issuing the following command.

For testing the PHP, Place one PHP file on to the document root of the created virtual host.

Restart Nginx and PHP-FPM services.

[root@geeksite~/]# systemctl restart nginx.service

[root@geeksite~/]# systemctl restart php-fpm.service

In the terminal copy/paste the following line:

[root@geeksite~/]# vi /usr/share/nginx/html/geeksite.local/index.php

This will open up a file called index.php.

Copy/Paste this line into the index.php file:

<?php phpinfo(); ?>

Save and close the file. use Esc + ;wq for saving the file.

Now open you’re web browser and type the following into the web address:

http://geeksite.local

The page look like below:

From the above screen shot , PHP5 is working, and it’s working through FPM/FastCGI, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5.

Scroll down the browser and look for the MySQL support information.

You will find the MySQL modules list that are not listed before the installation of support package.