在rhel6 64位环境下部署LNMP环境
实验前提:此实验除Nginx和php需要重新编译外,其他相关软件与LAMP安装方式相同,
故删除之前LAMP架构中的Apache和PHP,编译安装Nginx和PHP
实验环境:RHEL61_64 nginx-1.0.9 php-5.2.17
内核版本:2.6.32-131.0.15.el6.x86_64
实验步骤:
1.Nginx-1.0.9 编译安装
./configure --prefix=/usr/local/nginx --user=daemon --group=daemon --with-rtsig_module --with-select_module --with-poll_module
--with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_p_w_picpath_filter_module --with-http_sub_module
--with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module
--with-http_secure_link_module --with-http_degradation_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
--pid-path=/var/run/nignx/nginx.pid --http-client-body-temp-path=/tmp/nginx_http --http-proxy-temp-path=/tmp/nginx_proxy --http-fastcgi-temp-path=/tmp/nginx_fcgi
--with-cpu-opt=pentium4 --without-http_uwsgi_module --without-http_scgi_module --with-http_stub_status_module --with-http_perl_module --with-perl=/usr/bin/perl
--with-perl_modules_path=/usr/share/perl5 --with-pcre
检查安装时会显示:
nginx path prefix: "/usr/local/nginx" ----nginx安装路径
nginx binary file: "/usr/local/nginx/sbin/nginx" ----nginx启动脚本
nginx configuration prefix: "/usr/local/nginx/conf" ----nginx配置文件所在位置
nginx configuration file: "/usr/local/nginx/conf/nginx.conf" ----nginx配置文件
nginx pid file: "/var/run/nignx/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/tmp/nginx"
nginx http proxy temporary files: "/tmp/nginx"
nginx http fastcgi temporary files: "/tmp/nginx"
apache和nginx通信机制对比:
apache --> mod_libphp5.so --> /usr/local/bin/php --> php.ini -> socket -> mysql
nginx --> tcp/ip -> /usr/local/bin/php-fcgi -> php.ini -> tcp/ip -> mysql
nginx简单配置:
vim /usr/local/nginx/conf/nginx.conf
user daemon;
worker_processes 5; 打开的进程数量
error_log /var/log/nginx/error.log info;
pid /var/run/nginx/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"';
access_log /var/log/nginx/access.log main;
sendfile on; 允许文件上传
keepalive_timeout 65;
虚拟主机配置
server { --------------------------------
listen 80;
server_name www.cluster.com;
charset gb2312;
access_log /var/log/nginx/www.access.log main;
location / {
root /www;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html; 定义错误代码
location = /50x.html {
root html;
}
}
}
[root@station10 nginx-1.0.9]# /usr/local/nginx/sbin/nginx -t <-检查nginx.conf配置文件是否有语法错误
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@station10 nginx-1.0.9]# /usr/local/nginx/sbin/nginx <- 启动服务器
[root@station10 nginx-1.0.9]# /usr/local/nginx/sbin/nginx -s stop <- 关闭服务器
2.编译安装php-5.2.17
./configure --enable-fastcgi --enable-force-cgi-redirect --disable-ipv6 --with-libxml-dir=/usr --with-openssl --with-zlib --with-bz2
--enable-calendar --with-curl --with-curlwrappers --with-pcre-dir=/usr/local --enable-ftp --with-gd=/usr/local
--with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-xpm-dir --with-freetype-dir=/usr/local --enable-gd-native-ttf
--enable-gd-jis-conv --enable-mbstring --with-mcrypt=/usr/local --with-mhash=/usr/local --with-mysql=/usr/local/mysql
--with-mysql-sock=/var/run/mysqld/mysql5.socket --with-mysqli=/usr/local/mysql/bin/mysql_config --with-ncurses=/usr
--with-snmp=/usr --enable-zip --enable-sockets
编译之后会生成/usr/local/bin/php-cgi 此为连接nginx和php的工具
一般情况下并发访问不大的时候:
启动 tcp ->开启9000端口,用于连接nginx和php
/usr/local/bin/php-cgi -b 127.0.0.1:9000 -c /usr/local/lib/php.ini -a &
在虚拟主机中增加
location ~ \.php$ {
root /www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;
include fastcgi_params;
}
接下来重启nginx,就可以支持php,php与mysql的连接通过php.ini定义mysql的socket来实现
注意:
当并发访问非常大的时候,此时/usr/local/bin/php-cgi就会由于压力而死掉,但nginx可能还会正常工作,
依然能解释静态页面,而php页面将不被解析!
解决方法:
为保持php的稳定性,使用spawn-fcgi-1.6.3.tar.gz产蛋工具,可以解决此问题
spawn-fcgi-1.6.3.tar.gz
./configure --enable-extra-warnings&& make && make install
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 200 -f /usr/local/bin/php-cgi -u daemon -g daemon
\-将会生成200个/usr/local/bin/php-cgi后台进程
转载于:https://blog.51cto.com/peishuangcai/737090
在rhel6 64位环境下部署LNMP环境相关推荐
- 手把手教你在64位Win7下部署16位汇编学习环境
实现方式是VirtualBox虚拟机+精简的32位xp系统.指导小白用,高手就直接跳过吧. 一.背景 初学者学习汇编语言通常是从16位汇编开始,但是现在的64位Win7系统明确表示不支持16位的程序. ...
- Ubuntu16.4(64位)下gcc-linaro-arm-linux-gnueabihf交叉编译环境安装
1. 下载压缩包 文件分享 2. 新建目录并解压 3. 配置环境变量 sudo gedit /etc/bash.bashrc 添加路径并更新路径:(PATH=$PATH之间无空格) PATH=$PAT ...
- docker中lnmp访问php页面,Docker下部署LNMP工作环境的教程(详细步骤)
本篇文章给大家带来的内容是关于Docker下部署LNMP工作环境的教程(详细步骤),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 普通PC环境也可以用以下配置,只是MYSQL那里换回 ...
- RHEL6 64位系统安装ORACLE 10g 64bit 数据库
RHEL6 64位系统安装ORACLE 10g 64bit 数据库 2013-08-10 22:12 by 潇湘隐者, 9673 阅读, 2 评论, 收藏, 编辑 记得去年4月份的时候,为公司部署测试 ...
- 64位centos 下编译 hadoop 2.6.0 源码
64位os下为啥要编译hadoop就不解释了,百度一下就能知道原因,下面是步骤: 前提:编译源码所在的机器,必须能上网,否则建议不要尝试了 一. 下载必要的组件 a) 下载hadoop源码 (当前最新 ...
- 关于64位Linux配置android开发环境出现 No such file or directory
前几天在64位系统上部署android开发环境的时候出现了这种问题 /aapt: No such file or directory 通过谷老师,知道原理android SDK里面的程序全是32位的, ...
- 64位系统下,一个32位的程序究竟可以申请到多少内存,4GB还是更多
前言: cpu的位是指一次性可处理的数据量是多少,1字节=8位,32位处理器可以一次性处理4个字节的数据量,依次类推.32位操作系统针对的32位的CPU设计.64位操作系统针对的64位的CPU设计.操 ...
- Win10 64位系统下PCL + Visual Studio + cmake + (Qt) 安装调试
Win10 64位系统下PCL + Visual Studio + cmake + (Qt) 安装调试 在这里只介绍all in one方式安装 1.软件准备 安装pcl(点云库)需要涉及pcl.pc ...
- 64位系统下一个32位的程序究竟可以申请到多少内存?
64位系统下一个32位的程序究竟可以申请到多少内存? cpu的位是指一次性可处理的数据量是多少,1字节=8位,32位处理器可以一次性处理4个字节的数据量,依次类推.32位操作系统针对的32位的CPU设 ...
- python3.7 win10 64位系统下用pyinstaller打包的程序在32位系统下无法运行
问题背景: 在64位的win10系统下,用python 3.7.4 写了个定时报警的小玩意儿,主要用到了pyaudio模块,写完之后,使用pyinstaller打包成.exe文件,在其他64位的电脑下 ...
最新文章
- 自定义权限 android,Android权限控制之自定义权限
- C# WinForm程序退出的方法
- python语言的核心理念是_Python 编程语言的核心是什么?
- python linux 命令_Python Linux 命令行 sudo
- shell编程之 cut命令详解
- Mac/Ubuntu/Windows使用VNC Viewer远程控制Ubuntu Server
- 10.程序员的自我修养---内存
- android 动态创建数据库表,简析Android数据库中创建表与LitePal的基本用法
- Java常见面试题:数据库优化策略有哪些?
- bottleneck resnet网络_ResNet网络结构分析
- python-网易云简单爬虫
- Vue 2.6.13 源码解析(四) Observer、Dep、Watcher与订阅
- Ajax——AJAX实现省市联动
- 空气质量提醒 BMI指数计算 Python123题解
- 有道云笔记客户端不显示图片
- compileflow流程引擎使用
- wifi查看密码显示
- [附源码]SSM计算机毕业设计政府公用车辆管理系统JAVA
- 分享我的疯狂Linux内核知识
- 软件行业薪酬待遇调查:涨薪不给力致员工跳槽
热门文章
- 制作CDKEY:有效期的处理
- 全网首发:Could NOT find JNI (missing: JAVA_AWT_INCLUDE_PATH) 解决办法
- 开源项目:RGB转BMP
- #!/bin/sh与#!/bin/bash有区别
- 昨天发现,博客排名进行了两次
- WORD必学技巧:使用项目编号
- 说不尽的洒脱:不义而富且贵,于我如浮云
- 净空法师质疑,人的生命真的变长了吗
- 遇到Python中文目录名问题,未解决
- python常见变量数据类型_【python基础】常见的变量、数据类型、运算符