linux下安装nginx详细教程

来源:互联网 发布:win7 tcp监听端口阻塞 编辑:程序博客网 时间:2024/06/04 17:51
window10操作系统下 安装好VMware workstation12 使用CentOS-7.0-1406-x86_64-DVD.iso操作系统
准备好所依赖的包

nginx包:

准备好安装nginx所需的包之后
第一步:将所有包拷贝到centos桌面
第二部:安装gcc-6.1.0.tar.gz (注:因为我手动安装此处出错,所以选择的在线安装)
打开终端(使用root账户 ,使用命令:su 回车 然后输入密码进行切换)
[root@localhost mrms]#tar -zxvf gcc-6.1.0.tar.gz 
[root@localhost mrms]# cdgcc-6.1.0
[root@localhostgcc-6.1.0]# ./config 
[root@localhostgcc-6.1.0]#make
[root@localhostgcc-6.1.0]#makeinstall

因为在安装gcc执行make命令时,出现找不到mikefile文件.所以我选择了在线安装 在线安装需要连接网络
centos7中这个图标表示联网图标 (可点击这图标进行联网,图为已联网状态)

安装nginx所需要的依赖包是gcc-c++
因此执行命令yum install gcc-c++进行在线安装(我在线安装的版本为4.8)
若执行此命令出现
Another app is currently holding the yum lock; waiting for it to exit...
说明yum被锁定 此时使用:rm -rf /var/run/yum.pid 强行解锁 此时yum就可以运行了
解锁后再次运行安装命令 当下载完成后会进行提示,并出现[y/d/N]?这个提问
此时输入y 回车.等待安装完成。

第三步:安装openssl-fips-2.0.12.tar.gz
依次执行如下命令:
[root@localhost mrms]#tar -zxvf openssl-fips-2.0.12.tar.gz 
[root@localhost mrms]# cd openssl-fips-2.0.12
[root@localhost openssl-fips-2.0.12]# ./config 
[root@localhost openssl-fips-2.0.12]#make
[root@localhost openssl-fips-2.0.12]#makeinstall
第四步:安装zlib-1.2.8.tar.gz
若不是在root账户下进行安装,会报:cp: cannot create regular file ‘/usr/local/lib/libz.a’: Permission denied错误
依次执行如下命令:
[root@localhost mrms]#tar -zxvf zlib-1.2.8.tar.gz
[root@localhost mrms]# cd zlib-1.2.8
[root@localhost zlib-1.2.8]# ./configure 
[root@localhost zlib-1.2.8]#make
[root@localhost zlib-1.2.8]#makeinstall
第五步:安装pcre-8.39.tar.gz
[root@localhost mrms]#tar -zxvf pcre-8.39.tar.gz
[root@localhost mrms]# cd pcre-8.39
[root@localhost pcre-8.39]# ./configure 
[root@localhost pcre-8.39]#make
[root@localhost pcre-8.39]#makeinstall
第六步:安装nginx-1.8.0.tar.gz
[root@localhost mrms]#tar -zxvf nginx-1.8.0.tar.gz 
[root@localhost mrms]# cd nginx-1.8.0
[root@localhost nginx-1.8.0]# ./configure
[root@localhost nginx-1.8.0]#make
[root@localhost nginx-1.8.0]#makeinstall
检查是否安装成功使用命令:
root@localhost nginx-1.8.0]# cd /usr/local/nginx/sbin
[root@localhost sbin]# ./nginx -t
当出现以下信息时为安装成功:

启动nginx
[root@localhost sbin]# ./nginx
查看端口
[root@localhost sbin]# netstat -ntlp
0 0