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 openSUSE 12.1 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 openSUSE 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
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 403 Forbidden, this is due to no index.html file in /srv/www/htdocs directory.
The default nginx document root on openSUSE 12.1 is /srv/www/htdocs. 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.
Before starting PHP-FPM; we need to have the configuration file, copy the sample configuration file to /etc/php5/fp/php-fpn.conf.
Edit the /etc/php5/fpm/php-fpm.conf file, change the error_log to /var/log/php-fpm.log and uncomment pm.min_spare_servers and pm.max_spare_servers.
Start or restart the PHP-FPM service.
Rrestart the Nginx server.
Enabling and Testing PHP-FPM Support on Virtual Host:
Lets create name based virtual host on Nginx server for the following details.
Server Name : geeksite.local
Document Root : /srv/www/htdocs/geeksite.local
We can place the configuration file under the /etc/nginx/vhosts.d directory which doesn’t exists, so create the directory.
Create the configuration file called virtual.conf and Edit /etc/nginx/conf.d/virtual.conf.
Add the following content.
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.