nginx

准备

一台Centos服务器IP:192.168.200.15

关闭防火墙、关闭SELinux、配置yum源

nginx安装

nginx官网地址:nginx: download

这两个随便下载一个,传到你的服务器上

yum这几个包

[root@nginx ~]# yum -y install pcre-devel openssl openssl-devel gcc gcc-c++

 开启nginx

[root@nginx ~]# ll
总用量 1056
-rw-------. 1 root root    1311 12月 20 22:36 anaconda-ks.cfg
-rw-r--r--  1 root root 1073364 2月  28 17:32 nginx-1.21.6.tar.gz
[root@nginx ~]# tar -zxvf nginx-1.21.6.tar.gz
[root@nginx ~]# cd nginx-1.21.6
[root@nginx nginx-1.21.6]# ./configure
[root@nginx nginx-1.21.6]# make && make install
[root@nginx nginx-1.21.6]# cd /usr/local/nginx/objs/
[root@nginx objs]# ./nginx
[root@nginx objs]# netstat -lntp |grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      4539/nginx: master 

 访问服务器

用浏览器访问服务器,然后是这样的话,那么你成功了。 192.168.200.15:80端口

【快捷小妙招】 修改nginx配置文件,使可以直接开启关闭nginx

[root@masker ~]# vim /etc/profile
#最后一行添加这个
export PATH=/usr/local/nginx/objs:$PATH
[root@masker ~]# source /etc/profile  #刷新配置文件

【修改html文件】html文件都懂吧

[root@masker ~]# vim  /usr/local/nginx/html/index.html 
[root@masker ~]# nginx                    //直接开启nginx
[root@masker ~]# nginx -s stop        //关闭nginx
posted @ 2022-02-28 17:41  花花de代码生活  阅读(60)  评论(0编辑  收藏  举报