宁波网站建设公司哪个好,陕西省建设执业资格注册中心网站,他达拉非副作用,站的免费网站如果你想拥有你从未拥有过的东西#xff0c;那么你必须去做你从未做过的事情 想要在网页上访问到代码那么就需要用到应用服务类中间件#xff0c;国外的有Nginx#xff0c;Tomcat等#xff0c;国内的有金蝶web#xff0c;东方通的服务中间件#xff08;Tongweb#xff0… 如果你想拥有你从未拥有过的东西那么你必须去做你从未做过的事情 想要在网页上访问到代码那么就需要用到应用服务类中间件国外的有NginxTomcat等国内的有金蝶web东方通的服务中间件Tongweb等等今天就来介绍和安装一下Nginx~~~~ 目录
一、查询我的公网出网IP
二、服务架构框架
三、Nginx服务安装
发现无法访问页面
关闭防火墙
四、Nginx服务管理
五、部署一个好看的前端界面 欢迎交流在学习过程中如果你有任何疑问或想法欢迎在评论区留言我们可以共同探讨学习的内容。你的支持是我持续创作的动力 点赞、收藏与推荐如果你觉得这篇文章对你有所帮助请不要忘记点赞、收藏并分享给更多的小伙伴你们的鼓励是我不断进步的源泉 推广给更多人如果你认为这篇文章对你有帮助欢迎分享给更多对Linux感兴趣的朋友让我们一起进步共同提升 一、查询我的公网出网IP
[rootweb01 heavenly-music-master]#curl cip.cc
IP : ***.**.**.***
地址 : 中国 北京
运营商 : 联通
数据二 : 中国北京北京 | 联通
数据三 : 中国北京北京市 | 联通
URL : http://www.cip.cc/ ***.**.**.***
[rootweb01 heavenly-music-master]#
我们公司的出网IP我不方便透露你们自己试试吧~~~~
二、服务架构框架
LNMP架构Linxu Nginx MySQL PHP
LNMT架构Linxu Nginx MySQL Tomcat
LAMP架构Linxu Apache MySQL PHP
LNMP架构Linxu Nginx MySQL Python
三、Nginx服务安装
方法1.编译安装
方法2.epel安装版本较低配置不易读不建议使用默认为1.20
方法3.通过官网仓库安装
通过官网编译安装nginx1.26版本
下载网址
https://nginx.org/en/download.html
也可以使用wget命令
[rootweb01 code]#wget https://nginx.org/download/nginx-1.26.2.tar.gz [rootweb01 ~]#ls
公共 视频 文档 音乐 anaconda-ks.cfg initial-setup-ks.cfg
模板 图片 下载 桌面 heavenly-music-master.zip nginx-1.26.2.tar.gz
新建目录
[rootweb01 ~]#mkdir /usr/local/web-tool
将解压好的包移动到刚刚新建的目录下并改名
[rootweb01 ~]#mv nginx-1.26.2 /usr/local/web-tool/nginx
进入目录
[rootweb01 ~]#cd /usr/local/web-tool/nginx
[rootweb01 nginx]#ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
检查与编译
[rootweb01 nginx]#./configure
checking for OS Linux 4.19.90-52.15.v2207.ky10.x86_64 x86_64
checking for C compiler ... found using GNU C compiler gcc version: 7.3.0 (GCC)
……
creating objs/Makefile
Configuration summary using system PCRE2 library OpenSSL library is not used using system zlib library
nginx path prefix: /usr/local/nginxnginx binary file: /usr/local/nginx/sbin/nginxnginx modules path: /usr/local/nginx/modulesnginx configuration prefix: /usr/local/nginx/confnginx configuration file: /usr/local/nginx/conf/nginx.confnginx pid file: /usr/local/nginx/logs/nginx.pidnginx error log file: /usr/local/nginx/logs/error.lognginx http access log file: /usr/local/nginx/logs/access.lognginx http client request body temporary files: client_body_tempnginx http proxy temporary files: proxy_tempnginx http fastcgi temporary files: fastcgi_tempnginx http uwsgi temporary files: uwsgi_tempnginx http scgi temporary files: scgi_temp安装编译
[rootweb01 nginx]#make
make -f objs/Makefile
make[1]: 进入目录“/usr/local/web-tool/nginx”
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I objs \-o objs/src/core/nginx.o \src/core/nginx.c
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I objs \-o objs/src/core/ngx_log.o \src/core/ngx_log.c
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I objs \-o objs/src/core/ngx_palloc.o \src/core/ngx_palloc.c
……
[rootweb01 nginx]#sudo make install
make -f objs/Makefile install
make[1]: 进入目录“/usr/local/web-tool/nginx”
test -d /usr/local/nginx || mkdir -p /usr/local/nginx
test -d /usr/local/nginx/sbin \|| mkdir -p /usr/local/nginx/sbin
test ! -f /usr/local/nginx/sbin/nginx \|| mv /usr/local/nginx/sbin/nginx \/usr/local/nginx/sbin/nginx.old
cp objs/nginx /usr/local/nginx/sbin/nginx
test -d /usr/local/nginx/conf \|| mkdir -p /usr/local/nginx/conf
cp conf/koi-win /usr/local/nginx/conf
cp conf/koi-utf /usr/local/nginx/conf
cp conf/win-utf /usr/local/nginx/conf
test -f /usr/local/nginx/conf/mime.types \|| cp conf/mime.types /usr/local/nginx/conf
cp conf/mime.types /usr/local/nginx/conf/mime.types.default
test -f /usr/local/nginx/conf/fastcgi_params \|| cp conf/fastcgi_params /usr/local/nginx/conf
启动nginx查看是否安装成功
[rootweb01 nginx]#/usr/local/nginx/sbin/nginx
进入浏览器输入IP端口端口默认80
发现无法访问页面 关闭防火墙
contos7以后系统默认使用fairewalld防火墙不需要默认关闭iptables
但是银河麒麟是两种防火墙同时使用的小屁最早陷入了思维误区一直没想到iptables的问题经原厂工程师的提醒关闭iptables防火墙就可以访问啦
关闭两道防火墙之后记得关闭开机自启呦~~~~
[rootweb01 nginx]#systemctl stop firewalld.service
[rootweb01 nginx]#systemctl stop iptables
[rootweb01 nginx]#systemctl disable firewalld.service
[rootweb01 nginx]#systemctl disable iptables
当然在生产环境不建议这么玩可以学习一下防火墙开口的策略 四、Nginx服务管理
[rootweb01 nginx]#cat nginx.conf
# 核心区块
user nginx; # 启动nginx的虚拟用户 默认已经存在了
worker_processes auto; # 启动子进程的数量 auto以cpu的内核数为准
error_log /var/log/nginx/error.log notice; # 错误日志所在的日志
pid /var/run/nginx.pid; # 进程PID所存放的目录
# 事件模块
events {worker_connections 25532; # 进程的最大连接数
}# http模块
http {
include /etc/nginx/mime.types; # 媒体类型
default_type application/octet-stream; # 默认如果媒体类型中不存在则自动下载该页面
log_format main $remote_addr - $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for;
access_log /var/log/nginx/access.log main; # nginx的访问日志
sendfile on; #文件高效传参
#tcp_nopush on;
keepalive_timeout 65; #长连接的超时时间
#gzip on; #是否开启压缩
include /etc/nginx/conf.d/*.conf; # 包含了conf.d目录下所有的.conf 将*.conf内容移动到了当前的文件中
}
主机配置文件
[rootweb01 conf.d]#nginx.conf
#可以放在最后倒数第二行
server {listen 80;server_name www.game.com;location / {root /code/;index index.html index.htm;}
# 包含了conf.d目录下所有的.conf 将*.conf内容移动到了当前的
}
修改完成之后使用nginx -t检查语法
[rootweb01 ~]#/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
重载nginx可以重启但是不建议那么做重载是热加载重启是关闭之后再启动
/usr/local/nginx/sbin/nginx -s reload
查看nginx版本
[rootweb01 ~]#/usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.26.2
第五步检查服务端口是否开启
[rootweb01 conf.d]#netstat -tnulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address
tcp 0 0 0.0.0.0:80 0.0.0.0:*
Nginx启动方式两种启动方式(编译安装需要自己写脚本我写了但是有点问题等写好再粘过来)
systemctl start nginx #systemctl启动进程
systemctl stop nginx #停止进程
第二种没有被systemctl所管理使用绝对路径运行
#启动脚本是在
# /usr/local/nginx/sbin/nginx
#启动,
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#停止
/usr/local/nginx/sbin/nginx -s stop
#重载
/usr/local/nginx/sbin/nginx -s reload
#杀掉nginx
/usr/local/nginx/sbin/nginx -s quit
[rootweb01 ~]#/usr/local/nginx/sbin/nginx
[rootweb01 ~]#netstat -tnulp|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 22956/nginx: master
五、部署一个好看的前端界面
[rootweb01 ~]#vim /usr/local/nginx/conf/nginx.conf
#倒数第二行写入下面的内容
……
#}server {listen 81;#server_name www.game.com;location / {root /code/heavenly-music-master;index index.html index.htm;}
# 包含了conf.d目录下所有的.conf 将*.conf内容移动到了当前的 }
#注意要放到最后一行花括号“}”里
}
下载代码
https://gitee.com/ymhkali/heavenly-music/repository/archive/master.zip
我下载到了/root目录下
[rootweb01 ~]#ls
公共 视频 文档 音乐 anaconda-ks.cfg initial-setup-ks.cfg
模板 图片 下载 桌面 heavenly-music-master.zip nginx-1.26.2.tar.gz
解压代码包
[rootweb01 code]#unzip /root/heavenly-music-master.zip -d /code/
Archive: /root/heavenly-music-master.zip
bc49cdda7c39e0c2224655e28ccb5d74a068259dcreating: /code/heavenly-music-master/creating: /code/heavenly-music-master/CSS/inflating: /code/heavenly-music-master/CSS/album.css inflating: /code/heavenly-music-master/CSS/index.css inflating: /code/heavenly-music-master/CSS/my_music.css inflating: /code/heavenly-music-master/CSS/play.css inflating: /code/heavenly-music-master/CSS/playlist_detail.css
……inflating: /code/heavenly-music-master/images/音乐小图标1.png inflating: /code/heavenly-music-master/images/音乐背景.jpg inflating: /code/heavenly-music-master/images/音乐背景图片.jpg inflating: /code/heavenly-music-master/index.html
[rootweb01 code]#ls
heavenly-music-master
[rootweb01 code]#cd heavenly-music-master/
[rootweb01 heavenly-music-master]#ls
CSS Files images index.html JS LICENSE README.md
重载
[rootweb01 code]#/usr/local/nginx/sbin/nginx -s reload 今天对nginx的编译安装和服务部署讲解就告一段落了下次分享一点深入的nginx知识~~~~
我的nginx安装参考了这位作者可以去看一看他的博客麒麟系统—— openKylin 安装 Nginx_麒麟系统安装nginx-CSDN博客 想成为大佬就要从小白开始从0开始一点一点的积累慢慢成长明天你就是大佬想学习更多麒麟操作系统的知识关注小屁让你成为运维老鸟~~~~~