Linux 安裝 Nginx 命令

2021-10-11 18:16:07 字數 4478 閱讀 1660

yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel

cd /usr/local/src

#wget

wget

tar -zxvf nginx-1.16.1.tar.gz

cd nginx-1.16.1

#./configure

#如果要https模組,要這麼寫配置:

#如果已安裝,請參考:

關閉nginx

./nginx -s stop

重新記載nginx配置檔案

./nginx -s reload

配置當做檔案伺服器

注意listen的埠

配置跨域,在server中

add_header access-control-allow-origin *;

add_header access-control-allow-headers *;

add_header access-control-allow-methods get,post;

**本地,在server中,注意windows需要雙反斜槓

location / {

if ($request_method = "options") {

add_header 'access-control-max-age' 86400;

add_header 'access-control-allow-methods' '*';

add_header 'access-control-allow-headers' '*';

add_header 'content-length' 0;

add_header 'content-type' 'text/plain, charset=utf-8';

return 204;

#**本地資料夾

root /video-project;

autoindex on;

配置中文字符集,在server中

charset utf-8;

示例

linux示例:

linux下命令安裝nginx

參考文章 一般要首先裝pcre,zlib,ssl 1 安裝pcre wget tar zxvf pcre 8.36.tar.gz configure make make install 2 安裝zlib wget tar zxvf zlib 1.2.8.tar.gz configure make m...

nginx安裝和命令

1.nginx安裝 1.1 mac上安裝 brew search nginx brew install nginx mac上nginx的安裝位置 usr local etc nginx nginx.conf usr local var www usr local cellar nginx 1.17....

Linux系統安裝Nginx

yum y install make zlib zlib devel gcc c libtool openssl openssl devel如果是ubuntu系統,請使用 sudo apt get install openssl sudo apt get install libssl dev 將ub...