网站首页 > 技术教程 正文
1、Nginx下载
Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,目前使用比较广泛。
下载地址: nginx: download
2、安装
将Nginx安装在/usr/local/nginx目录下
# yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
# ./configure --prefix=/usr/local/nginx --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module
# make && make install
3、启动Nginx
执行如下命令启动:
# /usr/local/nginx/sbin/nginx
为了方便启动,我们可以做下软链接
# ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
这样我们执行如下命令即可启动Nginx
# nginx
查看nginx是否启动成功:
# ps -ef | grep nginx
输入ip,浏览器访问
4、开机启动
首先创建nginx.service文件
# vim /lib/systemd/system/nginx.service
写入内容:
[Unit]
Description=nginx service
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[Unit]:服务的说明
Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
[Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3
加入开机启动:
# systemctl enable nginx.service
如果取消开机启动的话,可以执行:
# systemctl disable nginx.service
其他相关命令:
# systemctl start nginx.service 启动nginx服务
# systemctl stop nginx.service 停止服务
# systemctl restart nginx.service 重新启动服务
# systemctl list-units --type=service 查看所有已启动的服务
# systemctl status nginx.service 查看服务当前状态
# systemctl enable nginx.service 设置开机自启动
猜你喜欢
- 2024-10-14 Centos7常用命令总结(centos7.5命令大全)
- 2024-09-30 centos7使用nginx+uwsgi+daphne+supervisor+redis部署Django
- 2024-09-30 Centos7利用gz包安装Nginx(centos7.5安装gcc)
- 2024-09-30 Centos 7下安装配置Nginx(centos7安装mysql8)
- 2024-09-30 CentOS7常用软件的安装(JDK+Tomcat+Nginx+Redis+MySQL)
- 2024-09-30 centos7系统下Nginx配置搭建(centos7 搭建部署conflunce)
- 2024-09-30 一文读懂服务器centos7.0安装指导指南(详细)
- 2024-09-30 为何还有人在百度centos7环境下安装nginx?
- 2024-09-30 CentOS7 - 安装NGINX作为负载平衡器
- 2024-09-30 Kali与编程:Centos7上搭建web服务器
你 发表评论:
欢迎- 08-06linux 和 windows文件格式互相转换
- 08-06谷歌 ChromeOS 已支持 7z、iso、tar 文件格式
- 08-06Linux下比较文件内容的6种方法
- 08-06文件格式及功能汇总
- 08-0610个Linux文件内容查看命令的实用示例
- 08-06Linux-如何区分不同文件类型
- 08-06Zabbix技术分享——监控windows进程资源使用情况
- 08-06Linux系统卡顿?学会ps命令这三招,轻松定位问题进程
- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)