准备工作我就不写了,引入博友的记录,
选首先安装这几个软件:GCC,PCRE(Perl Compatible Regular Expression),zlib,OpenSSL。
Nginx是C写的,需要用GCC编译;Nginx的Rewrite和HTTP模块会用到PCRE;Nginx中的Gzip用到zlib;
用命令“# gcc”,查看gcc是否安装;如果出现“gcc: no input files”信息,说明已经安装好了。
否则,就需要用命令“# yum install gcc”,进行安装了!一路可能需要多次输入y,进行确认。
安装好后,可以再用命令“#gcc”测试,或者用命令“# gcc -v”查看其版本号。
同样方法,用如下命令安装PCRE,zlib,OpenSSL(其中devel,是develop开发包的意思):
# yum install -y pcre pcre-devel
# yum install -y zlib zlib-devel
# yum install -y openssl openssl-devel
2、下载并安装
然后,从官方地址(http://nginx.org/)下载,解压,配置,编译,安装:
// 这个是下载
# wget http://nginx.org/download/nginx-1.7.3.tar.gz
// 然后解压
# tar xzf nginx-1.7.3.tar.gz
// 回到解压目录
# cd nginx-1.7.3
// 检查当前的环境是否满足要安装软件的依赖关系,但并不是所有的tar包都是源代码的包,
// 楼主可以ls看看有没有configure这个文件,也许你下的是二进制的包,如果是二进制的包,
// 解压后直接就能使用
# ./configure
// 编译
# make
// 安装
# make install
// 这个是找到nginx在哪里
# whereis nginx
nginx: /usr/local/nginx
---------------------
作者:wildpen
来源:CSDN
原文:https://blog.csdn.net/wildpen/article/details/76204486
版权声明:本文为博主原创文章,转载请附上博文链接!
好了以上是我引用的博友安装教程
默认的安装路径为:/usr/local/nginx;跳转到其目录下sbin路径下,便可以启动或停止它了。
但是我们还需要进行配置一下配置文件在我们安装好目录下的nginx/conf中
然后配置下路径 我这里的默认端口80被httpd占用了,我改成了8088
我配置的图片存放路径:/home/boycamera/images/
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8088;
server_name localhost 127.0.0.1 47.100.245.18;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://localhost:8086;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
#root html;
#index index.html index.htm;
}
// 这就是路径
location /images {
alias /home/boycamera/images/;
autoindex on;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
然后是服务器上的图片所在位置
然后就是访问路径了: