一、简介
L: Linux系统
A: apache服务器(也可使用nginx代替)
M:多指mysql或mariadb数据库
P: 指PHP、python、perl等编程语言。
广义的lamp架构可以指:Linux/unix/windows +apache/nginx…+mysql/pgsql+php/python/perl/golang
二、搭建nginx web服务器
本文使用的linux系统为红帽7.6企业版
1.下载相关资源包
[root@server1 ~]# ls
nginx-1.18.0.tar.gz
[root@server1 ~]# tar zxf nginx-1.18.0.tar.gz %解压
[root@server1 ~]# ls
nginx-1.18.0 nginx-1.18.0.tar.gz
[root@server1 ~]# cd nginx-1.18.0/
[root@server1 nginx-1.18.0]# ls %源码安装时解压目录中的初始文件
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
安装相关工具:
[root@server1 nginx-1.18.0]# yum install gcc -y %编译需要的包
[root@server1 nginx-1.18.0]# yum install pcre-devel -y %http重写功能需要的包
[root@server1 nginx-1.18.0]# yum install -y openssl-devel %ssl功能需要的包
2.编译、安装
[root@server1 nginx-1.18.0]# vim auto/cc/gcc %注释掉debug选项,可以使安装最小化
[root@server1 nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module %编译,编译参数可自由选择
[root@server1 nginx-1.18.0]# make && make install %安装
3.添加环境变量并开启服务
[root@server1 sbin]# pwd
/usr/local/nginx/sbin
[root@server1 sbin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@server1 ~]# vim .bash_profile %注意路径(/root/下)
[root@server1 ~]# source .bash_profile %使上述更改生效
[root@server1 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/usr/local/nginx/sbin
[root@server1 ~]# which nginx
/usr/local/nginx/sbin/nginx
[root@server1 ~]# nginx %运行nginx服务,nginx stop为关闭nginx服务
4.测试
安装tools工具,查看是否开启80端口
[root@server1 ~]# yum install -y net-tools
[root@server1 ~]# netstat -antulp
编写测试页面并访问进行测试
[root@server1 ~]# curl localhost %使用curl命令进行测试,观察是否能够访问通畅
[root@server1 ~]# cd /usr/local/nginx/
[root@server1 nginx]# ls
client_body_temp fastcgi_temp logs sbin uwsgi_temp
conf html proxy_temp scgi_temp
[root@server1 nginx]# cd html/
[root@server1 html]# ls
50x.html index.html
[root@server1 html]# vim test.html
[root@server1 html]# curl localhost:/test.html %编辑测试页,进行访问,观察是否能够访问到
www.westos.org