1.下载nginx包
2.解压安装
#创建安装目录
mkdir /usr/local/nginx
#下载nginx所需依赖
yum install -y gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel
#将下载好的包拖进来,然后解压
tar -zxvf nginx-1.24.0.tar.gz
#进入目录
cd /usr/local/nginx/nginx-1.24.0/
#编译
./configure --prefix=/usr/local/nginx
#安装
make && make install
#查看安装位置
whereis nginx
这个时候就可以访问了
3.启动相关命令
cd /usr/local/nginx/sbin/
./nginx #启动
./nginx -s stop #停止
./nginx -s quit #退出
./nginx -s reload #重启
./nginx -s reopen #重新打开日志文件
4.简单配置
server {
listen 80;
server_name localhost;
location / {
root /opt/vue/dist;
index index.html index.htm;
}
location /vitepress-project/ {
alias /opt/vue/dist/; #静态资源
}
}