
教程八:Linux(centos7.7)安装nginx
发布日期:2021-05-07 22:41:53
浏览次数:23
分类:精选文章
本文共 2602 字,大约阅读时间需要 8 分钟。
centos7.7安装nginx1.8教程
文章目录
一、安装插件:
查看gcc:gcc -v [root@yu /]# gcc -v -bash: gcc: command not found [root@yu /]#
yum -y install gccyum install -y pcre pcre-develyum install -y zlib zlib-develyum install -y openssl openssl-devel------------------------------------------[root@yu /]# gcc -v.........Thread model: posixgcc version 4.8.5 20150623 (Red Hat 4.8.5-39)
二、下载安装nginx
安装方式:http://nginx.org/en/download.html
(1.官网链接: . 下载tar.gz 文件,上传到Linux,继续如下的第二步开始 (2.wget直接下载安装:如下
1、下载nginx安装包
稳定版:
wget http://nginx.org/download/nginx-1.18.0.tar.gz
2、解压
# tar -zxvf 源文件 -C 目标路劲tar -zxvf nginx-1.18.0.tar.gz -C /opt/
3、切换到 nginx-1.18.0/ :编译安装
1、yum -y install pcre-devel openssl openssl-devel2、./configure --prefix=/usr/local/nginx1183、make4、make install
5、切换到/usr/local/nginx安装目录
[root@yu nginx-1.18.0]# cd /usr/local/nginx/[root@yu nginx]# lltotal 4drwxr-xr-x. 2 root root 4096 Mar 3 19:26 confdrwxr-xr-x. 2 root root 40 Mar 3 19:26 htmldrwxr-xr-x. 2 root root 6 Mar 3 19:26 logsdrwxr-xr-x. 2 root root 19 Mar 3 19:26 sbin[root@yu nginx]# pwd/usr/local/nginx
6、查看端口
[root@yu nginx]# pwd/usr/local/nginx[root@yu nginx]# cat conf/nginx.conf---------------------------------#keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; }
7、启动nginx服务
参考文献:[阿豪聊干货] https://www.cnblogs.com/hafiz/p/6891458.html
启动nginx命令:[root@yu /]# cd /usr/local/nginx/sbin[root@yu nginx]# cd sbin/[root@yu sbin]# lltotal 3240-rwxr-xr-x. 1 root root 3313712 Mar 3 19:26 nginx[root@yu sbin]# ./nginx
停止:
1).暴利kill(不推荐使用) kill -9 processId2).快速停止 cd /usr/local/nginx/sbin && ./nginx -s stop 此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程3).完整停止(建议使用) cd /usr/local/nginx/sbin && ./nginx -s quit 此方式停止步骤是待nginx进程处理任务完毕进行停止
重启:
1.先停止再启动 ./nginx -s quit && ./nginx2.重新加载配置文件 ./nginx -s reload
8、查看nginx服务
[root@yu sbin]# ps -ef | grep nginxroot 4037 1 0 19:28 ? 00:00:00 nginx: master process ./nginxnobody 4038 4037 0 19:28 ? 00:00:00 nginx: worker processroot 4040 1623 0 19:29 pts/0 00:00:00 grep --color=auto nginx
9、wind端 测试:前提是wind端配置好IP映射
http://localhost:80
Welcome to nginx!If you see this page, the nginx web server is successfully installed and working. Further configuration is required.For online documentation and support please refer to nginx.org.Commercial support is available at nginx.com.Thank you for using nginx.
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2025年03月25日 10时49分52秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
开发者社区公告【MW移动端钱包】开发公示
2019-03-05
Vue01常见指令,axios
2019-03-05
Vue路由嵌套刷新后页面没有重新渲染
2019-03-05
Vue使用bus进行组件间、父子路由间通信
2019-03-05
数据库三个级别封锁协议
2019-03-05
操作系统:缓冲技术的相关介绍
2019-03-05
函数与指针分析、回调函数
2019-03-05
新型类型转换
2019-03-05
类的实例
2019-03-05
Java中数据类型和运算符
2019-03-05
PAT 锤子剪刀布
2019-03-05
tomcat加载部署webapps目录下的项目
2019-03-05
ACM/NCPC2016 C Card Hand Sorting(upc 3028)
2019-03-05
方法重写
2019-03-05
Threading Programming Guide(多线程编程指南)
2019-03-05
Swift--14类型扩展
2019-03-05
Socket通信原理和基础实践
2019-03-05
Java求逆波兰表达式的结果(栈)
2019-03-05
SDWebImage--http图片加载不出来的问题
2019-03-05
Application received signal SIGSEGV
2019-03-05