nginx 安装
Last updated on May 9, 2025 am
🧙 Questions
☄️ Ideas
linux安装
sudo yum install -y nginx
- 默认config目录:
/etc/nginx/nginx.conf
- 默认html目录:
/usr/share/nginx/html
- 默认日志目录:
/var/log/nginx/access.log
- 默认bin目录:
/usr/sbin/nginx
启动项目
nginx
源码安装
wget http://nginx.org/download/nginx-1.20.2.tar.gz
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g-dev
sudo apt-get install openssl libssl
./configure --prefix=/opt/elap/embedded --conf-path=/opt/elap/conf/nginx/nginx.conf --http-log-path=/var/log/elap/nginx/access.log --error-log-path=/var/log/elap/nginx/error.log --with-http_ssl_module --with-http_stub_status_module --with-debug --with-ld-opt=-L/opt/elap/embedded/lib --with-cc-opt='-L/opt/elap/embedded/lib -I/opt/elap/embedded/include' --with-stream
make -j8
make install
/opt/elap/embedded
/opt/elap/conf/nginx/nginx.conf
/opt/elap/embedded/sbin/nginx
stream {
server {
listen 8088;
listen [::]:8088;
proxy_pass 10.9.6.1:31013;
proxy_timeout 100s;
proxy_connect_timeout 100s;
}
}
docker安装
mkdir -p config
mkdir -p html
cd config
vim default.conf
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
cd html
vim index.html
<html>
<head><title>hello world</title></head>
<body>
<center><h1>hello world</h1></center>
</body>
</html>
docker run \
--name isxcode-nginx \
--privileged=true \
--restart=always \
-d \
-p 30188:80 \
-v /Users/ispong/Downloads/config:/etc/nginx/conf.d \
-v /Users/ispong/Downloads/html:/usr/share/nginx/html \
nginx:1.27.0
🔗 Links
nginx 安装
https://ispong.isxcode.com/vue/nginx/nginx 安装/