一、Nginx安装
LNMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写。L指Linux,N指Nginx,M一般指MySQL,也可以指MariaDB,P一般指PHP
Nginx是一个小巧而高效的Linux下的Web服务器软件,Nginx性能稳定、功能丰富、运维简单、处理静态文件速度快且消耗系统资源极少。
1.添加Nginx到yum资源库
[root@localhost ~]# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.安装Nginx
[root@localhost ~]# yum -y install nginx
3.启动Nginx
[root@localhost ~]# systemctl start nginx #启动nginx
[root@localhost ~]# systemctl status nginx #查看nginx状态
[root@localhost ~]# systemctl enable nginx #添加开机自启动nginx
4.查看是否安装成功
如果一切顺利,打开浏览器输入虚拟机或服务器IP地址预览Nginx默认页面
5.yum安装后的默认地址和配置的默认地址
/etc/nginx/nginx.conf //yum方式安装后默认配置文件的路径
/usr/share/nginx/html //nginx网站默认存放目录
/usr/share/nginx/html/index.html //网站默认主页路径
nginx配置文件目录:/etc/nginx/
PID目录:/var/run/nginx.pid
错误日志:/var/log/nginx/error.log
访问日志:/var/log/nginx/access.log
默认站点目录:/usr/share/nginx/html
nginx服务启动管理的终端命令:/usr/sbin/nginx
ngxin-debug主要用于nginx启动debug模式的一个命令:/usr/sbin/nginx-debug
nginx模块目录:/usr/lib64/nginx/modules/
6.Nginx基本操作
[root@localhost ~]# whereis nginx // 查看nginx相关目录
[root@localhost ~]# rpm -ql nginx // 查看所有nginx目录和文件列表
[root@localhost ~]# systemctl start nginx //启动nginx
[root@localhost ~]# systemctl stop nginx //停止nginx
[root@localhost ~]# nginx -s reload //重载nginx
[root@localhost ~]# ps -ef | grep nginx //查看进程apache/httpd
[root@localhost ~]# netstat -anpl | grep 'nginx' //查看服务端口
7.配置Nginx解析php
详见LNMP环境——PHP安装部署