第一步:
安装编译工具及库文件
# yum -y install gcc-c++
# yum -y install pcre
# yum -y install pcre-devel
# yum -y install zlib
# yum -y install zlib-devel
# yum -y install openssl
# yum -y install openssl-devel
第二步:
切换到 /usr/local 目录,下载软件包
# cd /usr/local //进入到/usr/local
# wget http://nginx.org/download/nginx-1.8.0.tar.gz //下载1.8版本
第三步:
解压安装包
# tar -zxvf nginx-1.8.0.tar.gz //解压
第四步:
安装nginx
# cd nginx-1.8.0 //进入nginx-1.8.0目录
# make //编译
# make install //安装
注意:
在 /usr/local/目录 下创建一个文件夹 logs
# cd /usr/local/
# mkdir logs //创建logs文件夹,用来存放日志
第五步:
验证安装
进入 /usr/local/nginx/sbin目录下
# cd /usr/local/ngingx/sbin
# ./nginx //启动nginx
查看nginx是否启动成功
# ps -ef | grep nginx
成功图片:
启动nginx 后在浏览器输入虚拟机地址,回车,如果打印出以下信息则证明安装成功。
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.