作者:Gome--李想 | 来源:互联网 | 2017-07-06 19:12
1.安装pcre-develyum-yinstallgccgcc-c++rpm-buildmysql*php*automakeautoconflibtoolmake--skip-brokenpcre是Nginx所需的pcre-devel库,安装pcre库是为了让Nginx支持HTTPRewrite模块pcre下载地址:http://down.51cto.c
1.安装pcre-devel
yum -y install gcc gcc-c++ rpm-build mysql* php* automake autoconf libtool make --skip-broken
pcre是Nginx 所需的pcre-devel库,安装pcre库是为了让Nginx支持HTTPRewrite模块
pcre下载地址:http://down.51cto.com/data/904014
[root@vb01 src]#unzip pcre-8.33.zip
[root@vb01 src]#cd pcre-8.33
[root@vb01 pcre-8.33]#./configure
[root@vb01 pcre-8.33]#make
[root@vb01 pcre-8.33]#make install
2. 安装nginx
下载地址:http://nginx.org/ 这里下载的是nginx-1.4.2稳定版
[root@vb01 src]#tar zxvf nginx-1.4.2.tar.gz
[root@vb01 src]# cd nginx-1.4.2
[root@vb01 nginx-1.4.2]# ./configure --help #查看可使用的模块,比如:
--prefix=PATH set installation prefix # 设置安装目录为PATH
--with-http_stub_status_module enable ngx_http_stub_status_module #用来启用NginxStatus功能,以监控Nginx的当前状态。
--with-google_perftools_module enable ngx_google_perftools_module #使Nginx支持google-perftools的模块,使用TCMALLOC优化Nginx的性能时会用到。
[root@vb01 nginx-1.4.2]# ./configure --with-http_stub_status_module --prefix=/usr/local/nginx
[root@vb01 nginx-1.4.2]# make
[root@vb01 nginx-1.4.2]# make install
3.Nginx的全局配置
Nginx的整个配置配置文件是以block的形式组织的,每个block一般以一个大括号“{}”来表示,block可以分为几个层次,整个配置文件中main指令位于最高层,在main层下面可以有Events,HTTP等层级,而在HTTP层中又包含server层,即server block,server block中又可分为location层,并且一个server block中可以包含多个location block.