官网下载nginx包
https://nginx.org/en/download.html
![](https://i-blog.csdnimg.cn/blog_migrate/e028927669004dbd2f40a5f801214137.png)
检查gcc和g++
gcc -v
g++ -v
安装openssl
tar -zxvf openssl-1.1.1d.tar.gz
cd openssl-1.1.1d.tar.gz
./config --prefix=/usr/local/openssl
make
make install
安装prce
tar -zxvf pcre-8.44.tar.gz
./configure
make
make install
安装zlib
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
安装nginx
#解压nginx
tar -zxvf nginx-1.16.1.tar.gz
#进入目录
cd nginx-1.16.1
#编译前检查
./configure --prefix=/filedisk/nginxser/nginx --with-openssl=/usr/local/openssl
#编译
make
#安装
make install
安装成功后
#启动nginx
./nginx
#停止
./nginx -s stop
#退出
./nginx -s quit
# 重启
./nginx -s reload
#启动成功后可查看到nginx进程
ps -ef|grep nginx
设置开机启动
#打开配置文件
vi /etc/rc.local
#追加一行nginx启动目录并保存
/usr/local/nginx/sbin/nginx
#进入etc文件并给rc.local文件授权
cd /etc
chmod 755 rc.local
将地形拷贝在/filedisk/nginxser/nginx/html路径下
![](https://i-blog.csdnimg.cn/blog_migrate/1d0fcd3f043a8658273b81ddee6a668d.png)
更改配置文件/filedisk/nginxser/nginx/conf下面的nginx.conf,改为自己设定的端口
![](https://i-blog.csdnimg.cn/blog_migrate/3f283315c0bfbb78f9cddc54567ce060.png)
#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;
client_max_body_size 64m;
#gzip on;
server {
listen 8084;
server_name _;
#charset koi8-r;
#access_log logs/host.access.log main;
#location /git/ {
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header Host $host;
# proxy_set_header REMOTE-HOST $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_pass http://127.0.0.1:3000/;
#}
#location /wmts/ {
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header Host $host;
# proxy_set_header REMOTE-HOST $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_pass http://127.0.0.1:8080;
#}
location / {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials 'true';
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers *;
root html;
index index.html index.htm;
}
#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;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
add_header Access-Control-Allow-Origin *;
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
或者直接拷贝,重启nginx后cesium加载调用
![](https://i-blog.csdnimg.cn/blog_migrate/22f0618685a677d062d40626a142d8db.png)