lnmp安装过程

NGINX

Cd /data/samb

Tar zxf php-5.4.45.tar.gz

Cd php-5.4.45.tar.gz

Yum install libxml2-devel freetype-devellibjpeg-devel libpng-devel openssl-devel pcre pcre-devel libcurl-devel �Cy

rpm -ivh"http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm"

yum install -y  libmcrypt-devel

安装php

./configure \

--prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc\

--enable-fpm \

--with-fpm-user=php-fpm \

--with-fpm-group=php-fpm \

--with-mysql=/usr/local/mysql \

--with-mysql-sock=/tmp/mysql.sock \

--with-libxml-dir \

--with-gd \

--with-jpeg-dir \

--with-png-dir \

--with-freetype-dir \

--with-iconv-dir \

--with-zlib-dir \

--with-mcrypt \

--enable-soap \

--enable-gd-native-ttf \

--enable-ftp \

--enable-mbstring \

--enable-exif \

--enable-zend-multibyte \

--disable-ipv6 \

--with-pear \

--with-curl \

--with-openssl

Make && make install

Echo $?

0安装无问题

Cp

 

Nginxphp-fpm-conf文件

[global]

pid = /usr/local/php/var/run/php-fpm.pid

error_log =/usr/local/php/var/log/php-fpm.log

[www]

listen = /tmp/www.sock 监听文件

user = php-fpm 使用用户

group = php-fpm

listen.owner = nobody

listen.group = nobody

pm = dynamic 动态

pm.max_children = 50

pm.start_servers = 20

pm.min_spare_servers = 5

pm.max_spare_servers = 35

pm.max_requests = 500

rlimit_files = 1024

[www1]

listen = /tmp/www1.sock

user = php-fpm

group = php-fpm

pm = dynamic

pm.max_children = 50

pm.start_servers = 20

pm.min_spare_servers = 5

pm.max_spare_servers = 35

pm.max_requests = 500

rlimit_files = 10

保存退出

/usr/local/php/sbin/php-fpm -t

[29-Sep-2015 07:50:57] NOTICE:configuration file /usr/local/php/etc/php-fpm.conf test is successful

检查配置文件是否正确出现successful为配置正确

cp/data/samba/php-5.4.45/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

拷贝开机文件到启动位置

Chmod 755 /etc/init.d/php-fpm

给启动文件授权

php-fpm 加入开机启动

Chkconfig php-fpm on

 

 

开始安装nginx

Cd /data/samba

Wget http://nginx.org/download/nginx-1.4.4.tar.gz

Tar xzf nginx-1.4.4.tar.gz

安装nginx

./configure \

--prefix=/usr/local/nginx \

--with-http_realip_module \

--with-http_sub_module \

--with-http_gzip_static_module \

--with-http_stub_status_module  \

--with-pcre

Make && make install

 cp/usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak

>nginx.conf

Vim nginx.conf

 

nginx.conf配置文件

 

user nobody nobody;

worker_processes 2;

error_log/usr/local/nginx/logs/nginx_error.log crit;

pid /usr/local/nginx/logs/nginx.pid;

worker_rlimit_nofile 51200;

 

events

{  

   use epoll;

   worker_connections 6000;

}

 

http

{

   include mime.types;

   default_type application/octet-stream;

   server_names_hash_bucket_size 3526;

   server_names_hash_max_size 4096;

   log_format combined_realip '$remote_addr $http_x_forwarded_for[$time_local]'

   '$host "$request_uri" $status'

   '"$http_referer" "$http_user_agent"';

   sendfile on;

   tcp_nopush on;

   keepalive_timeout 30;

   client_header_timeout 3m;

   client_body_timeout 3m;

   send_timeout 3m;

   connection_pool_size 256;

client_header_buffer_size1k;

large_client_header_buffers8 4k;

    request_pool_size 4k;

    output_buffers 4 32k;

    postpone_output 1460;

    client_max_body_size 10m;

    client_body_buffer_size 256k;

    client_body_temp_path/usr/local/nginx/client_body_temp;

    proxy_temp_path /usr/local/nginx/proxy_temp;

    fastcgi_temp_path/usr/local/nginx/fastcgi_temp;

    fastcgi_intercept_errors on;

    tcp_nodelay on;

    gzip on;

    gzip_min_length 1k;

    gzip_buffers 4 8k;

    gzip_comp_level 5;

    gzip_http_version 1.1;

    gzip_types text/plain application/x-javascripttext/css text/htm application/xml;

    include vhosts/*.conf;

}

Mkdir /usr/local/nginx/conf/vhosts�Cp 创建虚拟主机文件夹

Cd vhosts

Vim default.conf

Vhostsdefault.conf配置

server

{

    listen 80 default_server;

    server_name localhost;

    index index.html index.htm index.php;

    root /tmp/1234;

    deny all;

    }

Test.conf另外一个文件

 

~     

用户认证

 

server

{

    listen 80;

    server_name www.test123.com;

    index index.html index.htm index.php;

    root /data/www;

 location ~ \.php$ {

            #fastcgi_pass   127.0.0.1:9000;

            fastcgi_pass   unix:/tmp/www.sock;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /data/www$fastcgi_script_name;

            include        fastcgi_params;

        }

}

server

{

    listen 80;

    server_name www.test123.com;

    index index.html index.htm index.php;

    root /data/www;

    location ~ \.*admin\.php$ {

        auth_basic "aminglinux auth";

        auth_basic_user_file/usr/local/nginx/conf/.htpasswd;

         include fastcgi_params;

        fastcgi_pass unix:/tmp/www.sock;

    #   fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME/data/www$fastcgi_script_name;

                   include        fastcgi_params;

 

}

 

    location ~ \.php$ {

        include fastcgi_params;

        fastcgi_pass unix:/tmp/www.sock;

    #   fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME/data/www$fastcgi_script_name;

            include        fastcgi_params;

    }

}

如果是认证目录 下面的php解析可以注释掉

server

{

    listen 80;

    server_name www.test123.com;

    index index.html index.htm index.php;

    root /data/www;

     location /abc/ { 注如果加入 location~ ^ /abc/.*就是保护abc目录下所有文件

        auth_basic "aminglinux auth";

        auth_basic_user_file/usr/local/nginx/conf/.htpasswd;

#        include fastcgi_params;

 #      fastcgi_pass unix:/tmp/www.sock;

    #   fastcgi_pass 127.0.0.1:9000;

  #     fastcgi_index index.php;

   #    fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

 

}

 

    location ~ \.php$ {

        include fastcgi_params;

        fastcgi_pass unix:/tmp/www.sock;

    #   fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME/data/www$fastcgi_script_name;

    }

}

集群环境

location /admin/{

      proxy_pass http://cluster/mgmt/;

      auth_basic "QuanLeiAuth.";

      auth_basic_user_file/usr/local/ngnix/conf/authdb;

}


你可能感兴趣的:(LNMP)