1.可以使用wget 命令下载或者使用工具上传
这里我是使用wget下载
wget http://nginx.org/download/nginx-1.9.9.tar.gz
2.把这个压缩包使用tar 命令解压
tar -zxvf nginx-1.9.9.tar.gz
3.这是我们进入解压文件夹
cd nginx
4.nginx下面有个文件configure,使用
./configure
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
这是如果报错,不要慌张,仔细看错误,是让我们
by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
这里我们忽略这个功能
./configure --without-http_rewrite_module
如果在报错就如此操作
我的报了二个 所以我使用
/configure --without-http_rewrite_module --without-http_gzip_module
注意我们可能看到如下错误
[root@localhost nginx]# make install
make -f objs/Makefile install
make[1]: Entering directory`/usr/local/nginx'
test -d '/usr/local/nginx' || mkdir -p'/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \
||mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \
||mv '/usr/local/nginx/sbin/nginx' \
'/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \
||mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp: ‘conf/koi-win’ and‘/usr/local/nginx/conf/koi-win’ are the same file
make[1]: *** [install] Error 1
make[1]: Leaving directory`/usr/local/nginx'
make: *** [install] Error 2
[root@localhost nginx]# mv /usr/local/nginx
mv: missing destination file operand after‘/usr/local/nginx’
Try 'mv --help' for more information.
这是我们的安装目录和源码目录冲突,我们应该把解压的文件放在其他位置,不要放在、usr/local下面
5.使用make命令编译
make
然后再使用make install
make install
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/root/nginx'
结尾为这个命令就说明你安装成功了。
6.开启nginx
当我们安装成功后,、usr/local下会多一个nginx文件夹
cd /usr/local/
[root@admin local]# ls
aegis bin games lib libexec native redis-4.0.8 share tomcat
apr etc include lib64 mysql nginx sbin src
进入nginx下面sbin
cd nginx/
[root@admin nginx]# ls
conf html logs sbin
[root@admin nginx]# cd sbin/
[root@admin sbin]# ls
nginx
这是使用如下命令启动
./nginx
查看进程,这时我们的进程就启动成功了。