lnmp环境搭建

Linux 下安装nginx:
http://www.92csz.com/study/linux/17.htm < LNMP安装>

一. Nginx
===============================================================================================
1.
1)Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件代理服务器,并在一个BSD-like 协议下发行。
2)特点: 占有内存少, 并发能力强 , 事实上nginx的并发能力确实在同类型的网页服务器中表现较好。

=================== 开始安装 ==================

1.安装前环境准备:

#首先确认是不是有安装编译包和一些依赖包
# yum install gcc gcc-c++ openssl openssl-devel zib-devel zib
# 创建运行nginx的用户
# groupadd www
# useradd -M -s /sbin/nologin -g www www

2.安装pcre
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
#tar zxvf pcre-8.39.tar.gz
编译安装
# cd pcre-8.39
# ./configure --prefix=/usr/local/pcre
# make && make install

3.安装nginx
# wget http://nginx.org/download/nginx-1.6.2.tar.gz
# tar -zxvf nginx-1.6.2.tar.gz
# cd nginx-1.6.2
# ./configure --prefix=/usr/local/nginx --with-pcre --with-http_stub_status_module
# make && make install

4.编辑nginx配置文件
# vi /usr/local/nginx/conf/nginx.conf
=======================以下是配置文件内容===========================
worker_processes 8 #设置跟cpu核数一样就行
worker_rlimit_nofile 309600;
events {
worker_connections 309600;
use epoll;
}

http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 4;
gzip_vary on;
gzip_types text/plain text/css text/xml application/x-javascript application/xml application/atom-xml text/javascript;
sendfile on;
keepalive_timeout 15;
client_max_body_size 100m;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_body_buffer_size 128k;
server {
listen 80; #监听端口
server_name demo.yunfancdn.com; #主机名
root /webroot/demo.yunfancdn.com; #网站根目录
client_max_body_size 2M;
index index.html ;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 15d;
}
location ~ .*\.(js|css)?$
{
expires 20m;
}

}
}


5.启动nginx
检查nginx配置文件语法有没问题
#/usr/local/nginx/sbin/nginx -t
如果没有会出现,下面提示
nginx: the configuration file /usr/local/nginx-1.4.6/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.4.6/conf/nginx.conf test is successful

启动nginx
#/usr/local/nginx/sbin/nginx
重新加载nginx
#/usr/local/nginx/sbin/nginx –s reload

--> 到这一步没有什么错误,就可以ip访问了.

<======= 注意以下 =======>
* 如果是阿里云的经典网络可直接公网ip访问就可以了.
* 如果是阿里云的专有网络需要在平台安装组设置安全规则才能访问.
* http://blog.csdn.net/assassinsshadow/article/details/72874911 (专有网络配置介绍)


==========================Nginx安装错误总结=======================================
1.nginx安装 nginx: [emerg] getpwnam(“www”) failed 错误?
解决方法1:
在nginx.conf中 把user nobody的注释去掉既可.

===========================================

解决方法2:
错误的原因是没有创建www这个用户,应该在服务器系统中添加www用户组和用户www,如下命令:
#/usr/sbin/groupadd -f www
#/usr/sbin/useradd -g www www


2.解决nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed错误
解决方法:
[root@localhost nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
http://blog.csdn.net/zhouyufengqingyang/article/details/45420775 相关文章

3.http://www.cnblogs.com/cnsanshao/p/3652510.html 解决报错lib.so
4. ./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel

错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.

解决办法:
yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx
make
make install


============= 配置重写 ===================
http://blog.csdn.net/zqtsx/article/details/24729485 配置Url重写

转载于:https://www.cnblogs.com/qiufengfeng/p/7845008.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值