LNMP环境配置

在linux下安装 nginx、php以及php扩展总结:

一、到官网下载nginx相应的版本:官网地址:http://www.nginx.org/
下载完成后解压 进入目录:
开始安装编译:(默认安装到usr/local/nginx目录下)
./configure
make
make install
安装完成后可以修改配置 /usr/local/nginx/conf/nginx.conf
启动nginx服务  
/usr/local/nginx/sbin/nginx
重启
 /usr/local/nginx/sbin/nginx -s reload


nginx.conf  基本配置:

user nobody;

worker_processes  1;

worker_rlimit_nofile  8192;

pid        logs/nginx.pid;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    

     log_format      main       '$remote_addr - $remote_user [$time_local] "$request" '

                                     '$status $body_bytes_sent "$http_referer" '

                                     '"$http_user_agent" "$http_x_forwarded_for" "$request_body" "$http_HEADER"';

     log_format      debug       '[$time_local] "$request" '

                                     '$body_bytes_sent "$http_HEADER" "$request_body"';

          sendfile                    on;

          tcp_nopush                  on;

          keepalive_timeout           3000;

          tcp_nodelay         on;

          gzip                        on;

          gzip_comp_level             5;

          gzip_http_version           1.0;

          gzip_min_length             1024;

          gzip_buffers                4  8k;

          gzip_types                  text/plain application/x-javascript text/css application/xml;

          client_header_buffer_size   4k;

          large_client_header_buffers 4 16k;

      proxy_connect_timeout 60;

      proxy_send_timeout    120;

      proxy_read_timeout    120;

      proxy_buffer_size     64k;

      proxy_buffers         64 16k;

      proxy_busy_buffers_size 256k;

      upstream hhvmfastcgi {

          server 127.0.0.1:90 weight=1;

      }

}


conf/vhosts 目录下配置站点:

server {

          

          listen       80;

          server_name  www.xxx.com;


          root   /www

          index  index.php index.html;

 

          charset utf-8;

 

          access_log  logs/www.xxx.com.log  main;

           error_page   500 502 503 504  /50x.html;

          location / { 

    if (-f $request_filename) {

           break;

    }

    if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {

        break;

    }

    if (!-e $request_filename) {

        rewrite . /index.php last;

    }

          location = /50x.html {

              root   html;

          }

          location ~ .+\.(php|do)?$

          {

  fastcgi_pass hhvmfastcgi;

          fastcgi_connect_timeout 600;

          fastcgi_send_timeout    1200;

          fastcgi_read_timeout    1200;

          fastcgi_buffers             64 16k;

          fastcgi_buffer_size         64k;

              fastcgi_busy_buffers_size   256k;

          fastcgi_temp_file_write_size 256k;

              fastcgi_index         index.php;

              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

              include               fastcgi_params;

          }

 

      location ~ .+\.(dat|sql|tgz|gz|tar|zip)?$

          {

          deny all;

          }

 

          location ~ /\.ht {

              deny  all;

          }

      }




二、安装php
    同样到官网下载php源码:官网地址:http://www.php.net/

开始安装编译:(默认安装到usr/local/nginx目录下)
./configure --prefix=/usr/local/php --enable-sockets=shared  --with-mysql=shared,mysqlnd (指定安装目录,默认安装mysql扩展支持)
make
make install


更详细的配置安装:

./configure --prefix=/usr/local/php --enable-fpm --with-gd --with-curl --with-freetype-dir=/usr/local/freetype --enable-gd-native-ttf --enable-mbstring --enable-calendar --with-gettext --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd 


配置文档
 /usr/local/lib/php.ini

扩展安装
在php/ext/目录下有很多的php扩展,需要安装就进入相应的目录然后执行以下命令,生成configure等文件进行编译,编译完成后在php.ini添加扩展支持即可。
 /usr/local/bin/phpize

./configure --with-php-config=/usr/local/bin/php-config

php启动
/usr/local/bin/php-fpm



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lambp314

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值