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:
First we will install the MySQL by issuing the following command.
Start MySQL server.
Step 3: To make the MySQL to start during the every boot, Type the following on terminal and hit Enter.
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
- You can remove
rootaccounts that are accessible from outside the local host.
- You can remove anonymous-user accounts.
- You can remove the
testdatabase (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
Nginx is already available in the Fedora Package, so issue the following command to install Nginx.
Start the Nginx after the installation.
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.
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.
Start or restart the PHP-FPM service.
Rrestart the Nginx server.
Enabling and Testing PHP-FPM Support on Virtual Host:
Lets create one name based virtual host on Nginx server.
Server Name : geeksite.local
Document Root : /usr/share/nginx/html/geeksite.local
Add the following content at the end of the file
Create host entry for geeksite.local domain in /etc/hosts file.
add the entry for geeksite.local, the line should look like below.
Create the document root directory
For testing the PHP, Place one PHP file on to the document root of the created virtual host.
Restart Nginx and PHP-FPM services.
In the terminal copy/paste the following line:
This will open up a file called index.php.
Copy/Paste this line into the index.php file:
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:
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.