centos安装nginx
程序员文章站
2024-02-27 14:11:09
...
1.安装依赖项
yum install -y make cmake gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
下载nginx
wget http://nginx.org/download/nginx-1.14.2.tar.gz
解压
tar zxvf nginx-1.14.2.tar.gz && cd nginx-1.14.2
编译配置’
./configure && make && make install
启动
cd /usr/local/nginx/sbin/
./nginx
查看pid
ps -aux | grep nginx
启动
cd /usr/local/nginx/sbin
./nginx
在浏览器输入ip地址即可访问
nginx每个server为一个站点
做文件映射
配置nginx.conf
server {
listen 8011;#配置端口
server_name localhost;
location / {
root /usr/local; #需要映射的地目录
autoindex on;
}
}
反向代理:
server {
listen 8012;#配置端口
server_name localhost;
location / {
root html; #需要映射的地目录
proxy_pass http://192.168.122.122:8080;#http端口
index index.html index.htm;
}
}