linux5.4下nginx 的安装和配置

nginx 的安装和配置

环境:linux5.4  

软件包:

libevent-2.0.16-stable.tar.gz

nginx-1.0.11.tar.gz

nginx 的安装与配置:

libevent的安装:

tar  -zxvf  libevent-2.0.16-stable.tar.gz  -C  /usr/local/src

cd  /usr/local/src/libevent-2.0.16-stable/

./configure --prefix=/usr/local/libevent

make   && make install

cd   /usr/local/libevent/   ll  (查看)



创建库文件:  vim /etc/ld.so.conf.d/libevent.conf   库路径:/usr/local/libevent/lib

刷新缓存:ldconfig

连接头文件:

ln  -s  /usr/local/libevent/include  /usr/include/libevent


pcre 共享库的安装(nginx依赖的库):

pcre   (Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正规表达式库.这些在执行正规表达式模式匹配时用与Perl 5同样的语法和语义是很有用的。因此改用pcre来解决C语言中使用正则表达式的问题

rpm  -ivh  /mnt/cdrom/Server/pcre-devel-6.6-2.el5_1.7.i386.rpm


nginx的安装:

创建账号

groupadd  -r  nginx

useradd  -r  -g  nginx  -s  /bin/false   -M  nginx


tar  -zxvf  nginx-1.0.11.tar.gz  -C  /usr/local/src

  cd   /usr/local/src/nginx-1.0.11/

配置:

./configure \

--conf-path=/etc/nginx/nginx.conf \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--user=nginx \

 --group=nginx \

--with-http_ssl_module \

--with-http_flv_module \

--with-http_stub_status_module \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/tmp/nginx/client/ \

--http-proxy-temp-path=/var/tmp/nginx/proxy/ \

--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \

--with-pcre



make

make  install


cd  /usr/local/nginx/sbin/

创建目录用于存放临时文件:mkdir  -pv  /var/tmp/nginx/client

测试:

停止:./nginx  -s  stop

测试性能:

rpm  -ivh/mnt/cdrom/Server/httpd-2.2.3-31.el5.i386.rpm


service  httpd  start (注意:nginxhttpd之间只能同时运行一个。)

测试(相同页面):

cp  /usr/local/nginx/html/index.html   /var/www/html/

ab  -c 1000  -n  10000  http://192.168.100.129/index.html  

service  httpd  stop

cd  /usr/local/nginx/sbin

启动nginx:   ./nginx

ab  -c  1000 -n  10000  http://192.168.100.129/index.html


你可能感兴趣的:(nginx)