centos 安装nginx

来源:互联网 发布:新教育网络师范学院 编辑:程序博客网 时间:2024/05/17 22:51

centos平台编译环境使用如下指令

安装make:

yum -y install gcc automake autoconf libtool make


安装g++:

yum install gcc gcc-c++ openssl openssl-devel -y


将pcre和zlib安装包解压到/usr/local/src/下

cd /usr/local/src/

装PCRE库
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 下载最新的 PCRE 源码包,使用下面命令下载编译和安装 PCRE 包:

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.21.tar.gz

tar -xzvf pcre2-10.21.tar.gz

cd pcre2-10.21/

./configure

make && make install


安装zlib库
http://zlib.net/ 下载最新的 zlib 源码包,使用下面命令下载编译和安装 zlib包:

wget http://zlib.net/zlib-1.2.11.tar.gz

tar -xzvf zlib-1.2.11.tar.gz

cd zlib-1.2.11/

./configure

make && make install


安装nginx

wget http://nginx.org/download/nginx-1.9.9.tar.gz

tar -xzvf nginx-1.9.9.tar.gz

cd nginx-1.9.9/

./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module

make && make install


启动
确保系统的 80 端口没被其他程序占用,运行/usr/local/nginx/nginx 命令来启动 Nginx,

netstat -nlpt | grep 80

如果查不到结果后执行,有结果则忽略此步骤:

/usr/local/nginx/nginx


打开浏览器访问此机器的 IP,如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。


1 0
原创粉丝点击