1:安装C++编译环境
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
如果提示404或者其他问题,导致安装不成功。那么可能是yum源的问题,配置一个新的yum源
1.1:首先备份现有的yum源。在这个目录下/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载对应的centos版本yum源,通过wget下载或者通过本地下载通过上传的方式。
CentOS5 :http://mirrors.163.com/.help/CentOS5-Base-163.repo
CentOS6 :http://mirrors.163.com/.help/CentOS6-Base-163.repo
CentOS7 :http://mirrors.163.com/.help/CentOS7-Base-163.repo
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
对其进行重命名
mv CentOS6-Base-163.repo CentOS-Base.repo
运行以下命令生成缓存
yum clean all
yum makecache
具体可以参考http://www.runoob.com/linux/linux-yum.html
完成之后再次尝试安装c++环境(nginx的运行环境)
成功之后下载PCRE(PCRE 作用是让 Nginx 支持 Rewrite 功能。)
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
解压安装包: tar zxvf pcre-8.35.tar.gz
进入安装包目录 cd pcre-8.35
编译安装 ./configure && make && make install
查看pcre版本 pcre-config --version
下载 Nginx,下载地址:http://nginx.org/download/nginx-1.6.2.tar.gz
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/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
make && make install
在启动之前先查看ngin的安装位置 whereis nginx
查看nginx版本 nginx的安装位置/sbin/nginx -v
启动nginx nginx的安装位置/sbin/nginx
1.用whereis libpcre.so.1命令找到libpcre.so.1在哪里
2.用ln -s /usr/local/lib/libpcre.so.1 /lib64命令做个软连接就可以了
3.用sbin/nginx启动Nginx
4.用ps -aux | grep nginx查看状态
[root@localhost nginx]# whereis libpcre.so.1
[root@localhost nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[root@localhost nginx]# sbin/nginx
[root@localhost nginx]# ps -aux | grep nginx
至此完成nginx的安装。
详细可参考
https://www..com/taiyonghai/p/6728707.html
http://www.runoob.com/linux/nginx-install-setup.html
-------------------------------------------------分隔线------------------------------------------------------------
nginx的配置文件解析
user -- nginx运行使用的用户
worker_processes --nginx进程,一般设置和cpu核心数相同
error_log-- 错误日志存放位置
pid -- 进程PID存放位置
worker_rlimit_nofile -- 最大文件打开数(连接)
events -- 工作模式和连接数上限
{
use epoll; #epoll是多路复用IO(I/O Multiplexing)中的一种方式,但是仅用于linux2.6以上内核,可以大大提高nginx的性能
worker_connections 1024; #;单个后台worker process进程的最大并发链接数
}