一、在Linux环境中安装Nginx
1、安装依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2、下载Nginx的tar包
//创建文件夹
cd /usr/local
mkdir nginx
cd nginx
//下载tar包
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.g
3、安装Nginx
//进入nginx目录
cd /usr/local/nginx/nginx-1.13.7
//执行命令
./configure
//执行make命令
make
//执行make install命令
make install
4、Nginx虚拟域名配置及测试验证
//编辑nginx.conf
sudo vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost:8080;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://127.0.0.1:8080;
}
...
5、Nginx启动
//进入nginx安装目录
cd sbin
sudo ./nginx
//测试启动
http://ip地址