Mar 23

It occur to me how to add somekind like .htaccess user login authentication on nginx, it was called NginxHttpAuthBasicModule. You need to go to your nginx.conf.  Here is some example :

# vim /etc/nginx/nginx.conf

root /usr/local/www/page;
index  index.php;
location  /user  {
auth_basic            “Restricted”;
auth_basic_user_file  /usr/local/www/user.pass

location ~ \.php$ {
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME /usr/local/www/page$fastcgi_script_name;
include        fastcgi_params;

then create user.pass using htpasswd

# /usr/bin/htpasswd -c /usr/local/www/user.pass admin

New password:
Re-Type new password:
Adding password for user admin

then restart your nginx

# /etc/init.d/nginx stop

#/etc/init.d/nginx start

And now you can access the page http://localhost/user

Jan 26

installing nginx + php-fpm using & EPEL repo

I have create post about installing nginx + php-fpm from source before in here In this tutorial i will create a more simple way installing nginx + php-fpm using yum with & EPEL repo.

Here it’s goes:

– Create repo
# cd /etc/yum.repos.d
# vim rusia-repo.repo

– and paste this

name=CentOS-$releasever – rusia packages for $basearch

– Enable EPEL repo
# rpm -Uvh$(uname -m)/epel-release-5-3.noarch.rpm

– Install nginx and php-fpm

# yum install nginx php-fpm

– you will see this package
Package         Arch        Version                      Repository       Size
nginx               x86_64      0.6.39-2.el5                 epel            319 k
nginx               i386        0.8.32-1.el5                 rusia-repo      393 k
php-fpm         i386        5.3.1-2.el5                  rusia-repo      1.2 M
Installing for dependencies:
bzip2-libs      i386        1.0.3-4.el5_2                base             37 k
db4                  i386        4.3.29-10.el5                base            909 k
gdbm              i386        1.8.0-26.2.1                 base             27 k
gmp                 i386        4.1.4-10.el5                 base            664 k
libedit            i386        2.11-2.20080712cvs.el5       epel             79 k
libevent        i386        1.4.12-1.el5                 rusia-repo      128 k
libxml2         i386        2.6.26-               base            795 k
pcre                i386        6.6-2.el5_1.7                base            112 k
perl                 i386        4:5.8.8-27.el5               extras           12 M
php-common      i386        5.3.1-2.el5                  rusia-repo      553 k

Transaction Summary
Install     13 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 17 M)
Remove       0 Package(s)

Total download size: 7.4 M

– go to nginx configuration file: “/usr/local/nginx/conf/nginx.conf” , and add  the php configuration

location ~ \.php$ {
root /usr/share/nginx/html; # itmena the root of the coument are located on

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;

– Go to /usr/share/nginx/html and create php files
# vi index.php
<?php phpinfo(); ?>

– Start the nginx and php-fpm
# service php-fpm start
# service nginx start

You can go to your server domain / ip address to see the phpinfo files