Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

[Tutorial] How to setup Nginx, MySQL, & PHP on Fedora [Tutorial]


~ Introduction ~

Hello everyone today I'm going to be teaching you how to install the web server Nginx on your Fedora server. I've been setting up and configuring web servers for a couple years now and I have a vast knowledge of CentOS, Debian, Ubuntu, & Fedora. I've setup Apache, Litespeed, & Nginx multiple times and have helped many people setting them up as well.

~ The Meat & Potatoes ~
* Some of the following instructions have been taken from this tutorial

~ Preliminaries ~

1. Basic knowledge of Linux
2. Have a VPS/Dedicated server & puTTy
3. yum remove httpd
php*
4. yum install gcc nano

~ MySQL ~

1. yum install mysql mysql-server
2. chkconfig --levels 235 mysqld on
3. service mysqld start
4. mysql_secure_installation
5. Hit enter
6. Type "Y" without the quotations and hit enter
7. Enter your desired password
8. Type "Y" without the quotations and hit enter
9. Type "N" without the quotations and hit enter
10. Type "Y" without the quotations and hit enter
11. Type "Y" without the quotations and hit enter

~ Nginx ~

1. yum install nginx
2. chkconfig --levels 235 nginx on
3. service nginx start

~ PHP5 ~

1. yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy
2. nano /etc/php.ini
3. Find the below lines and change "; cgi.fix_pathinfo=1" to "cgi.fix_pathinfo=0"

Code
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting
; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://www.php.net/manual/en/ini.core.php#ini.cgi.fix-pathinfo
cgi.fix_pathinfo=0

3. chkconfig --levels 235 php-fpm on
4. service php-fpm start

~ Configuring nginx ~

1. nano /etc/nginx/conf.d/default.conf
2. Add "root /usr/share/nginx/html;" under "server_name _;"
2. Find "index index.html index.htm;" and replace with "index index.php index.html index.htm;"
3. The most important part. Find and uncomment your "location ~ \.php$ {}" stanza. Please make sure that you change the fastcgi_param line to "fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;" because otherwise the PHP interpreter won't find the PHP script that you call in your browser.

Code
location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

4. service nginx restart
5. nano /usr/share/nginx/html/info.php

Code
<?php
phpinfo();
?>
6. Visit http://YOURSERVERIP/info.php

~ Summary ~

Thank you all for taking the time to read my tutorial. I hope you had as much fun reading it as I did writing it up for you. If you have any questions feel free to PM me or post here and I will help you to the best of my ability. If you want to repost this tutorial just give a link back to this thread. Also if there is anything I missed please PM me or post here and I will update the guide asap. If there is any other guides you would like me to write just pitch an idea and I will see :D.
Looks very nice. Wish I had this a few months ago!
Tell yo' paps you love'm while he here.
(Apr 10, 2012 09:45 PM)Hunion Wrote:  Looks very nice. Wish I had this a few months ago!

Thought I would finally start posting some tutorials and giving back :D I did all this while watching Code Geass. Thank you.
Thanks for this tutorial, I can tell you put tons of effort into this and this helped me lot. You made it noob friendly and easy to follow with the titles. This tutorial was organized, simple and yet detailed.

Thanks again,
-iOBV
(Apr 10, 2012 09:46 PM)Reseller Wrote:  Thanks for this tutorial, I can tell you put tons of effort into this and this helped me lot. You made it noob friendly and easy to follow with the titles. This tutorial was organized, simple and yet detailed.

Thanks again,
-iOBV

Thank you very much :D I made it as simple and straight forward as possible. Nginx is amazing and alot more people should be using it. Same with Fedora.
Nice tutorial. I will start posting some soon.
(Apr 11, 2012 05:33 AM)M0D3M Wrote:  Nice tutorial. I will start posting some soon.

Thank you. I look forward to reading them.
thanks for tutorial i liked it.i really liked it
(Apr 11, 2012 08:22 AM)Sheldon McCallister Wrote:  thanks for tutorial i liked it.i really liked it

Thank you very much :D If you have any questions feel free to ask.
Bumping this tutorial up. It's great for people to learn linux and how to setup a webserver. Also exploring a new webserver other than apache is great for webmasters.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by lgfINCApr 30, 2021 02:54 PM 1 162 Apr 30, 2021 02:54 PM
Last Post: Warrioя
by Rorschach.Feb 13, 2018 06:14 AM 14 276 Feb 13, 2018 06:14 AM
Last Post: Owl
by foxtrott50Sep 20, 2017 12:40 PM 13 287 Sep 20, 2017 12:40 PM
Last Post: SIM-1456221