关于Nginx一款高性能,轻量级web服务软件
稳定性高
单台物理服务器可支持30000~50000个并发请求
系统资源消耗低
对HTTP并发连接的处理能力高
环境
一台Linux服务器(192.168.13.128) 一台win10测试机一,在Windows上将LAMP所需压缩软件包共享出来(此处如有问题请看之前的博客相关文章)
二,在Linux上使用远程共享获取文件并挂载到mnt目录下
[root@localhost ~]# smbclient -L //192.168.100.3/ ##远程共享访问Enter SAMBA/root's password: Sharename Type Comment --------- ---- ------- LAMP-C7 Disk [root@localhost ~]# mount.cifs //192.168.100.3/LAMP-C7 /mnt ##挂载到/mnt目录下
三,编译安装Nginx
1,解压源码包到/opt下,并查看
[root@localhost ~]# cd /mnt ##切换到挂载点目录[root@localhost mnt]# lsapr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip LAMP-php5.6.txtapr-util-1.6.0.tar.gz error.png mysql-5.6.26.tar.gzawstats-7.6.tar.gz httpd-2.4.29.tar.bz2 nginx-1.12.0.tar.gzcronolog-1.6.2-14.el7.x86_64.rpm kali.jpg php-5.6.11.tar.bz2[root@localhost mnt]# tar zxvf nginx-1.12.0.tar.gz -C /opt ##解压Nginx源码包到/opt下[root@localhost mnt]# cd /opt/ ##切换到解压的目录下[root@localhost opt]# lsnginx-1.12.0 rh
2,安装编译需要的环境组件包
[root@localhost opt]# yum -y install /gcc / //c语言gcc-c++ / //c++语言pcre-devel / //pcre语言工具zlib-devel //数据压缩用的函式库
3,创建程序用户nginx并编译Nginx
[root@localhost opt]# useradd -M -s /sbin/nologin nginx ##创建程序用户,安全不可登陆状态[root@localhost opt]# id nginxuid=1001(nginx) gid=1001(nginx) 组=1001(nginx)[root@localhost opt]# cd nginx-1.12.0/ ##切换到nginx目录下[root@localhost nginx-1.12.0]# ./configure / ##配置nginx> --prefix=/usr/local/nginx / ##安装路径> --user=nginx / ##用户名> --group=nginx / ##用户组> --with-http_stub_status_module ##状态统计模块
4,编译和安装
[root@localhost nginx-1.12.0]# make ##编译...[root@localhost nginx-1.12.0]# make install ##安装...
5,优化nginx启动脚本,以便于系统识别
[root@localhost nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ ##创建软连接让系统识别nginx启动脚本[root@localhost nginx]# nginx -t ##检查配置文件的语法问题nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[root@localhost nginx]# nginx ##开启ngnix[root@localhost nginx]# netstat -ntap | grep 80 ##查看端口,nginx已经开启tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 39620/nginx: master [root@localhost nginx]# systemctl stop firewalld.service ##关闭防火墙[root@localhost nginx]# setenforce 0
6,安装elinks网页测试工具,并进行测试
[root@localhost nginx]# yum install elinks -y ##安装elinks软件[root@localhost nginx]# elinks http://localhost ##测试nginx网页
新闻热点
疑难解答