Install NGINX, MySQL and PHP on Fedora and configure it




NGINX is also known as Engine ex. Most of people know about Apache web server suite but NGINX faster alternative than  Apache. It’s done major works like : website with high traffic, advanced configuration, new framework like :

Node.js, Python/Django.

Now let’s see How can we Install it on Fedora

Step 1 : Turn Apache off / Remove from boot cycle

Apache configuration can cause problems when NGINX is put in its place. So we have to stop Apache service.

1. Log into your server via SSH, then get to the root user by running:

sudo su -

2. Shut Apache Down. This will bring down any current websites that are hosted on the server.

service httpd stop

3. If you want you can remove Apache from the boot cycle, so that it doesn’t try to start up during server boot.

systemctl disable httpd

Step 2 : Install NGINX

1. for older releases use YUM.

yum -y install nginx


2. For Fedora 22 and later versions use DNF

dnf install nginx

3. Start NGINX.

service nginx start

4. If you want the server to start NGINX upon reboot use.

systemctl enable nginx

Step 3 : Configure NGINX to serve for User domain

Create a new user for the webspace. First let’s create a UNIX user for your webspace.

1. Type the following command to create your user :

useradd <username>

<username> is goes to your user name like : bd, secupent etc.

2. Give a password :

passwd <password>

<password> contains your personal password like : sec1234, bd9876 etc.

Now you are properly set up.


Step 4 : Create a new directory for the site DocumentRoot

Now, let’s create the directory the “DocumentRoot” for this website. Always use a standard naming convention if you are hosting multiple websites.

1. We’ll follow the standard used by cPanel, and make our DocumentRoot based on the named “public_html”.

mkdir -p /var/www/

2. Now create index.html in this directory for testing the configuration :

vim /var/www/

3. Use the HTML code to test index file :

        <h1>Secupent, We are Award Winning Company</h1>

4. Our directory and test index is created, we have to give ownership of that directory over to the user in question, let’s following our previous example:

chown -R nginxsite:nginxsite /var/www/

5. Now set permissions for this folder :

chmod 755 /var/www/

Our directory is now set up, Now It’s ready to test index.html file.




Step 1 : Add MySQL Yum Repository

1. Go to the Repository page ( in the MySQL Developer Zone. Then Select and download the release package for your platform.

2. Install the downloaded release package with the following command.

3. replacing “platform-and-version-specific-package-name with the name” of the downloaded RPM package.

4. For fedora 22 use this code :

sudo dnf localinstall mysql57-community-release-fc22-{version-number}.noarch.rpm


For fedora 23 use this code :

sudo dnf localinstall mysql57-community-release-fc23-{version-number}.noarch.rpm

 Step 2 : Install MySQL

Install MySQL using this Code for old fedora version :

yum install mysql mysql-server


Install MySQL using this Code for new fedora version :

dnf install mysql mysql-server

 Step 3 : Start MySQL

To start the MySQL server use following command :

sudo service mysqld start

NOTE : If you using the MySQL Yum repository, the latest GA series is selected for installation by default. So you don’t need to use ( Step 2 ) process.





PHP can be work in NGINX through PHP-FPM (FastCGI Process Manager). It’s implementation with some additional features. Like : any size of site, especially busier sites. There’s a php-fpm package in the official Fedora repositories.

Step 1 : Install PHP

Here is the PHP script :

yum install php-fpm php-cli php-mysqlnd php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
php-magickwand php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy

Step 2 : Install Zend OPcache

To speed up your PHP page you have to install Zend OPcache. It’s free and similar to other PHP opcode cachers. Here is the Zend OPcache script :

yum install php-opcache

NOTE : If you have some error with timezone and date you have to open “ /etc/php.ini “ and set “ date.timezone ”.

vi /etc/php.ini

Here is the example of php.ini :

; Defines the default timezone used by the date functions
date.timezone = "Bangladesh/Dhaka"

Step 3 : Startup

You can create the system startup links for php-fpm :

systemctl enable php-fpm.service
systemctl start php-fpm.service