目录
4.安装g++、gcc、openssl-devel、pcre-devel和zlib-devel
5.在/usr/local/nginx-1.17.9/目录下执行安装命令
1.在/usr/local/目录下安装nginx
cd /usr/local/
2.将nginx压缩包上传到服务器
rz
3.解压nginx
tar -xvf nginx-1.17.9.tar.gz
4.安装g++、gcc、openssl-devel、pcre-devel和zlib-devel
安装nginx前,我们首先要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件
安装g++:
yum install gcc-c++
安装pcre-devel:
yum -y install zlib zlib-devel pcre pcre-devel
安装openssl-devel:
yum -y install openssl openssl-devel
5.在/usr/local/nginx-1.17.9/目录下执行安装命令
执行安装命令(带https):
./configure --prefix=/usr/local/nginx --with-http_ssl_module
如果需要使用https安装时需要加上https认证模块:--with-http_ssl_module
带https安装:
./configure --with-http_ssl_module
不带https安装:
./configure --prefix=/usr/local/nginx
6.执行(和路径无关直接执行):make
Make是最常用的构建工具,只要某个文件有变化,就要重新构建的,都可以用Make构建
make
7.最后执行:make install
make install安装已经编译好的程序
make install
8.启动nginx
如果启动不成功 需要配置nginx环境变量 参考:目录12
cd /usr/local/nginx/sbin
启动nginx命令:
./nginx
9.查看是否启动成功
ps -ef|grep nginx
10.nginx访问地址
http://ip:端口
11.如需要修改nginx配置文件
修改 /usr/local/nginx/conf下的配置文件
cd /usr/local/nginx/conf
vi conf
12.nginx配置环境变量
vi /etc/profile
如下内容添加到profile文件最后一行
export PATH=$PATH:/usr/local/nginx/sbin
将配置文件生效命令:
source /etc/profile
13.nginx.conf配置文件
#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;
sendfile on;
server {
listen 8012;
server_name 82.156.176.157;
client_max_body_size 300m;
location /zwzw {
proxy_pass http://82.156.176.157:8080;
}
location /mapobj-api-ftzw {
proxy_pass http://82.156.176.157:9999;
}
}
}