linux nginx部署前端项目
时间: 2023-08-30 07:07:53 浏览: 234
linux环境安装nginx【纯内网版本】
在部署前端项目之前,您需要先安装和配置Nginx。以下是一些步骤供您参考:
1. 首先,您需要下载Nginx的源文件并解压缩。您可以将源文件放在/u01/micsdev/software目录下,然后使用以下命令解压缩文件:
```
cd /u01/micsdev/software
tar zxvf nginx-1.15.10.tar.gz
```
2. 进入解压后的Nginx目录:
```
cd /u01/micsdev/software/nginx-1.15.10
```
3. 运行配置命令,指定Nginx的安装路径和一些可选的模块:
```
./configure --prefix=/software/nginx --without-http_rewrite_module --without-http_gzip_module
```
4. 编译Nginx:
```
make
```
5. 安装Nginx:
```
make install
```
6. 删除源文件(可选):
```
rm -rf /u01/micsdev/software/nginx-1.15.10
```
7. 创建Nginx的启动脚本并添加配置:
```
sudo vi /etc/init.d/nginx
```
在脚本中添加以下内容:
```
#!/bin/sh
# nginx - this script starts and stops the nginx daemon
chkconfig: - 85 15
description: NGINX is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
processname: nginx
config: /etc/nginx/nginx.conf
config: /etc/sysconfig/nginx
pidfile: /var/run/nginx.pid
Source function library.
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
chmod a+x /etc/init.d/nginx
```
8. 更改Nginx的默认站点配置:
```
vi /software/nginx/conf/nginx.conf
```
9. 启动Nginx服务:
```
service nginx start
```
10. 停止Nginx服务:
```
service nginx stop
```
11. 重启Nginx服务:
```
systemctl restart nginx.service
```
这些步骤将帮助您在Linux上部署前端项目使用Nginx。请根据您的实际情况进行相应的调整。
#### 引用[.reference_title]
- *1* *2* *3* [Linux配置nginx服务器,用于部署前端项目](https://blog.csdn.net/qq_40823910/article/details/89192404)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文