我是在root权限下安装的,切换root用户:
su root
下载nginx
wget http://nginx.org/download/nginx-1.13.9.tar.gz
解压
tar -zxvf nginx-1.13.9.tar.gz
安装所需要的依赖库文件:
yum install pcre yum install pcre-devel yum install zlib yum install zlib-devel
安装c++编译环境(安过可略过)
yum install gcc-c++
进行配置,/usr/local/nginx为安装的目录
cd nginx-1.13.9 && ./configure --prefix=/usr/local/nginx
编译安装
make && make install configure
查看Nginx安装位置
whereis nginx
启动Nginx(以我的安装目录为例)
/usr/local/nginx/sbin/nginx
查看
http://localhost:80
重启&关闭(重启必须是未关闭的情况下)
/usr/local/nginx/sbin/nginx -s reload /usr/local/nginx/sbin/nginx -s stop
在nginx.conf添加配置,反像代理b站主页
访问:http://localhost:8888 代理转向 http://www.bilibili.comserver { listen 8888; server_name localhost; location / { proxy_pass http://www.bilibili.com; } }