nginx的安装与配置

一.软件包安装方法:apt-get install nginx

二.源码编译安装:

先在网上查了下nginx编译安装需要的支持类库(pcre,openssl,zip)(从官网或者其他路径下载,通过man xxx 查看是否安装)

第一步先安装需要的支持类库:

如pcre的安装

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.zip

unzip pcre-8.32.zip

cd pcre-8.32/

make

make install

第二步:nginx源码下载安装


wget http://nginx.org/download/nginx-1.0.10.tar.gz
cd nginx-1.0.10/
./configure
make
sudo make install


ps:nginx的编译信息

支持的类库 
Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library
安装的路径(一般来说./configure不指定目录安装的话是安装在/usr/local/nginx、如果迩想指定其它目录用上
--prefix=xxx目录、如果迩是安装在默认目录的话、执行个软链接命令把nginx连去/usr/bin目录下 例如
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
) nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"


第四步:启动/重启nginx


1./usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
2./usr/local/nginx/sbin/nginx -s  reload

ps:如果遇到error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory,系统找不到某某库、把/usr/local下做个软链接搬过来就是了

ln -s /usr/local/lib/libpcre.so.1 /usr/lib/libpcre.so.1

访问:localhost,显示

ps:如果apache的服务占用了80端口、把它停掉就可以了

sudo /etc/init.d/apache2 stop
附属:转的一篇nginx优化,不知道靠谱不?日后验证

http://www.cnblogs.com/TonyZ/archive/2012/08/13/2636621.html


你可能感兴趣的:(nginx的安装与配置)