1、安装好centos7 已经配置好网卡。
2、关闭centos7 的防火墙
参加:
http://blog.csdn.net/shen1936/article/details/39696953
3、下载nginx,并上传到Linux中
http://nginx.org/en/download.html
4、安装
[root@localhost opt]# ls
nginx-1.7.5.tar.gz
[root@localhost opt]# tar zxvf nginx-1.7.5.tar.gz
[root@localhost nginx-1.7.5]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
查看 configure的依赖包,并安装
[root@localhost nginx-1.7.5]# yum install ./configure
[root@localhost nginx-1.7.5]# yum install gcc
可以通过执行 configure 来进行编译安装
[root@localhost nginx-1.7.5]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@localhost nginx-1.7.5]# cd /home/
[root@localhost home]# ls
[root@localhost home]# mkdir nginx
[root@localhost home]# cd /opt/
[root@localhost opt]# cd nginx-1.7.5
[root@localhost nginx-1.7.5]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
<pre name="code" class="plain">[root@localhost nginx-1.7.5]# ./configure --prefix=/home/nginx/
在执行过程中出错
./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.
还是缺少包,解决办法
将包安装好后,继续上一个命令
[root@localhost nginx-1.7.5]# ./configure --prefix=/home/nginx/
结果
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1: using system crypto library
+ using system zlib library
nginx path prefix: "/home/nginx/"
nginx binary file: "/home/nginx//sbin/nginx"
nginx configuration prefix: "/home/nginx//conf"
nginx configuration file: "/home/nginx//conf/nginx.conf"
nginx pid file: "/home/nginx//logs/nginx.pid"
nginx error log file: "/home/nginx//logs/error.log"
nginx http access log file: "/home/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"
make && make install
安装完成,启动nginx
[root@localhost nginx-1.7.5]# cd /home/nginx/
conf/ html/ logs/ sbin/
[root@localhost nginx-1.7.5]# cd /home/nginx/
[root@localhost nginx]# ls
conf html logs sbin
nginx的启动目录程序放在sbin下
[root@localhost nginx]# cd sbin/
[root@localhost sbin]# ls
nginx
[root@localhost sbin]# ./nginx
查看是否启动
[root@localhost sbin]# ps -ef |grep nginx
root 6998 1 0 23:07 ? 00:00:00 nginx: master process ./nginx
nobody 6999 6998 0 23:07 ? 00:00:00 nginx: worker process
root 7003 2320 0 23:08 pts/1 00:00:00 grep --color=auto nginx
启动完成,可以输入IP浏览下