linux 安裝 Nginx

来源:互联网 发布:网络调研常见的方法 编辑:程序博客网 时间:2024/05/14 16:35

1.下載nginx url:http://nginx.org/en/download.html

2.安裝

1 )解压 : tar -zxvf nginx-xxx.tar.gz

2)cd 到解压的目录

3)执行./configure

发现报错

./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using --with-pcre=<path> option.
报错信息说缺少以来PCRE

3.安装依赖

yum -y install pcre-devel

4.再次执行./configure

发现还是报错

./configure: error: the HTTP gzip module requires the zlib library.You can either disable the module by using --without-http_gzip_moduleoption, or install the zlib library into the system, or build the zlib librarystatically from the source with nginx by using --with-zlib=<path> option.
继续安装依赖

yum -y install zlib-devel

5.再次执行./configure

Configuration summary  + using system PCRE library  + OpenSSL library is not used  + using system zlib library  nginx path prefix: "/usr/local/nginx"  nginx binary file: "/usr/local/nginx/sbin/nginx"  nginx modules path: "/usr/local/nginx/modules"  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"

出现上面的信息,表示成功了 (虽然没有报错,但还是建议安装上openssl,yum -y install openssl)

然后依次

make

make install

cd 到解压的nginx文件夹下的sbin目录

./nginx -v 查看版本

./nginx 运行

6.查看进程

[root@localhost sbin]# ps -A | grep nginx16509 ?        00:00:00 nginx16510 ?        00:00:00 nginx
访问 http://localhost (nginx默认端口80,所以不需要指定端口号)


原创粉丝点击