Nginx 是一个高性能的 Web 和反向代理服务器
nginx安装
cd /usr/local/src
wget https://nginx.org/download/nginx-1.15.2.tar.gz
wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz
yum install pcre-devel zlib-devel -y
cd/usr/local/src/nginx-1.15.2
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-openssl=../openssl-1.0.2k
make
make install
启动nginx
/usr/local/nginx/sbin/nginx默认加载的配置文件
/usr/local/nginx/conf/nginx.conf
配置文件内容
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}启动之后,通过url访问http://test41/:
增加一个端口链接例如8082端口:增加如下配置
server {
listen 8082;
root /home/admin;
location / {
autoindex on;
}
}配置文件变成如下内容:
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8082;
root /home/admin;
location / {
autoindex on;
}
}
}重新加载配置文件
/usr/local/nginx/sbin/nginx -s reload
通url链接访问http://test41:8082/
成功!
谢谢!
领取专属 10元无门槛券
私享最新 技术干货