-
下载压缩包 并上传
-
安装依赖
- yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
-
创建一个文件夹,上传本地提供的nginx包
-
tar -zxvf nginx-1.18.0.tar.gz 解压文件
-
cd nginx-1.18.0
-
./configure
-
make
-
make install
-
-
默认安装路径
- /usr/local/nginx
-
访问配置
cd /usr/local/nginx/sbin./nginx
以下为安装SSL模块
1.如果安装了nginx需要先删除 rm -rf /usr/local/nginx
2.进入nginx的源码目录执行
/configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
3.make
4.make install
5.查看是否成功
/usr/local/nginx/sbin/nginx -V
6.报错信息
- nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
- 解决方案
-
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
7.配置文件
server {
listen 80;
server_name www.chutzpah-tech.com;
return 307 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name www.chutzpah-tech.com;
#ssl on;
index index.html;
ssl_certificate /usr/software/ssl/7535582_chutzpah-tech.com.pem;
ssl_certificate_key /usr/software/ssl/7535582_chutzpah-tech.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root /usr/share/nginx/html; #对应的文件夹
index index.html index.htm;
}
location /img {
alias /usr/local/deploy/img;
}
location /api/front {
proxy_pass http://lbs;
proxy_redirect default;
}
}
upstream lbs {
server 121.41.67.2:9002;
#server 121.40.127.122:8080;
}