手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程

[日期:2013-09-05] 来源:Linux社区  作者:heisedeyan [字体: ]

五:安装Nginx
Nginx的rewrite需要perl库,所以先安装下。

tar zxf pcre-8.33.tar.gz
cd pcre-8.33
./configure
make && make install
cd ../

在安装Nginx前,先对Nginx做一些修改,如隐藏真实版本号,取消debug模式,利用TCMalloc库提升Nginx对内存的使用效率。

#set TCMalloc
wget http://ftp.twaren.net/Unix/NonGNU//libunwind/libunwind-1.1.tar.gz
tar zxf libunwind-1.1.tar.gz
cd libunwind-1.1
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install
cd ..
wget https://gperftools.googlecode.com/files/gperftools-2.0.tar.gz
tar zxf gperftools-2.0.tar.gz
cd gperftools-2.0
./configure
make && make install
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig
tar zxf nginx-1.2.9.tar.gz
cd nginx-1.2.9
sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION      "1.5.4"@g' src/core/nginx.h
sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER          "tengine/" NGINX_VERSION@g' src/core/nginx.h
sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@g' auto/cc/gcc
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx  \
--conf-path=/etc/nginx/nginx.conf --with-pcre \
--http-client-body-temp-path=/usr/local/nginx/tmp/client_body \
--http-proxy-temp-path=/usr/local/nginx/tmp/proxy --http-fastcgi-temp-path=/usr/local/nginx/tmp/fastcgi \
--http-uwsgi-temp-path=/usr/local/nginx/tmp/uwsgi --http-scgi-temp-path=/usr/local/nginx/tmp/scgi \
--pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx  \
--with-http_ssl_module --with-http_realip_module --with-http_addition_module \
--with-http_image_filter_module --with-http_sub_module --with-http_dav_module \
--with-http_gzip_static_module --with-http_random_index_module \
--with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module \
--with-file-aio
make && make install

为tcmalloc添加线程目
mkdir /tmp/tcmalloc
chmod 0777 /tmp/tcmalloc

在nginx.conf中添加一行配置

google_perftools_profiles /tmp/tcmalloc;

到此,LNMP环境就搭建完成了。接下来就是配置文件的修改和具体参数的调整了。任务依旧艰巨啊!

安装Nginx,配置参数少了一个--with-google_perftools_module,不然Nginx不会支持

linux
相关资讯       LNMP 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款