lnmp环境搭建

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

一. 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 wwwcss

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;
}html

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;
}java

}
}linux


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 successfulnginx

启动nginx
#/usr/local/nginx/sbin/nginx
从新加载nginx
#/usr/local/nginx/sbin/nginx –s reload
c++

--> 到这一步没有什么错误,就能够ip访问了. web

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


==========================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重写

相关文章
相关标签/搜索