文章大纲
一、编译安装与卸载Nginx
二、关于LAMP
三、LAMP环境部署
四、学习资料下载
五、参考文章
![](https://upload-images.jianshu.io/upload_images/16598307-c538bee35a185306.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
一、编译安装与卸载Nginx
Nginx:是一款比较流行的web服务器软件,类似于Apache。
1. Ngnix基础知识与Windows版本安装
https://www.cnblogs.com/WUXIAOCHANG/p/10863413.html
2. Linux版本安装nginx
①下载nginx
下载地址:<u>https://nginx.org/en/download.html</u>
使用在服务器端下载的方式进行下载(此处不使用filezilla):
#wget****地址
例如当前需要下载nginx到“/usr/local/src”
#wget [<u>https://nginx.org/download/nginx-1.13.11.tar.gz</u>](https://nginx.org/download/nginx-1.13.11.tar.gz)
![](https://upload-images.jianshu.io/upload_images/16598307-9ce4009021589145.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
![](https://upload-images.jianshu.io/upload_images/16598307-144f4c90886095d1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
②解压nginx安装包
# tar -zxvf nginx-1.13.11.tar.gz
③进入nginx解压目录
开始进行配置、编译、安装操作
在配置时候报错:没有PCRE库
![](https://upload-images.jianshu.io/upload_images/16598307-74268a096ca874a9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
直接yum安装pcre-devel:
#yum install pcre-devel
![](https://upload-images.jianshu.io/upload_images/16598307-c659b83bbc27707f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
报错缺少zlib库:
![](https://upload-images.jianshu.io/upload_images/16598307-b9a771d8ed2a8150.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/555/format/webp)
直接使用yum安装zlib库:
#yum install zlib-devel
![](https://upload-images.jianshu.io/upload_images/16598307-74e22f7bdd9450ad.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/549/format/webp)
还需要自己去下载一个zlib的源码包,然后解压出来:
![](https://upload-images.jianshu.io/upload_images/16598307-9783ce3b12bd7579.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
![](https://upload-images.jianshu.io/upload_images/16598307-0cbfa15daace09d2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
最终的nginx配置命令:
#./configure --prefix=/usr/local/nginx --with-pcre --with-zlib=/usr/local/src/zlib-1.2.11
开始安装:
#make
![](https://upload-images.jianshu.io/upload_images/16598307-c7de93cd1081aef5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
最后安装:
#make install
![](https://upload-images.jianshu.io/upload_images/16598307-ca517428f1a16e54.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
安装好的目录:
![](https://upload-images.jianshu.io/upload_images/16598307-68ad3e1e37d2c2b5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
④运行nginx
先停止Apache,然后再运行nginx
![](https://upload-images.jianshu.io/upload_images/16598307-fb6d7e4951f5516f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
#/usr/local/nginx/sbin/nginx 【启动命令】
#/usr/local/nginx/sbin/nginx -s reload 【重载,重载配置文件】
启动效果
![](https://upload-images.jianshu.io/upload_images/16598307-7b81ea35d3cbe609.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
⑤了解:卸载编译安装的软件
#rm -rf 软件的安装目录
注意:卸载一个编译安装的软件的时候必须先停止。
二、关于LAMP
LAMP:Linux + Apache + MySQL + PHP LAMP架构(组合)
LNMP:Linux + Nginx + MySQL + php-fpm LNMP架构(组合)
LNMPA:Linux + Nginx + MySQL + PHP + Apache Nginx代理方式
![](https://upload-images.jianshu.io/upload_images/16598307-c779813f26602a80.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/310/format/webp)
![](https://upload-images.jianshu.io/upload_images/16598307-2d5999646c059d1c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
![](https://upload-images.jianshu.io/upload_images/16598307-7c8bbebe92702071.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
三、LAMP环境部署
首先登录控制台获取需要连接的主机ip地址:
![](https://upload-images.jianshu.io/upload_images/16598307-f51b5729a01ae3cb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/455/format/webp)
后续可以进行远程登录。
![](https://upload-images.jianshu.io/upload_images/16598307-ce0451ec85fb63c0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
在整个LAMP中需要自己安装的也就只有Apache + PHP + Mysql。后续以yum为例。
1. PHP与Apache的安装
#yum install php 【在安装好php的同时会一起顺带安装Apache】
![](https://upload-images.jianshu.io/upload_images/16598307-79026308bcdb3b81.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
启动Apache:#service httpd start
![](https://upload-images.jianshu.io/upload_images/16598307-f2291932eedd66c5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
此处会有一个警告,无法确定主机的FQDN,如果需要处理,则需要修改Apache的配置文件(/etc/httpd/conf/httpd.conf)
# vim /etc/httpd/conf/httpd.conf
在文件中搜索“ServerName”
![](https://upload-images.jianshu.io/upload_images/16598307-33715354730443a5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/472/format/webp)
将前面的“#”去除,保存退出,重启apache
![](https://upload-images.jianshu.io/upload_images/16598307-7ac985c8932d531d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/555/format/webp)
测试访问,在地址栏中输入ip地址直接访问(关闭防火墙):
![](https://upload-images.jianshu.io/upload_images/16598307-6f16d4ddb09eaf6b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
测试php是否可以运行(默认的Apache站点目录:/var/www/html):
创建一个index.php文件
![](https://upload-images.jianshu.io/upload_images/16598307-52c3ef4bb7b405fc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/237/format/webp)
运行php看到页面:
![](https://upload-images.jianshu.io/upload_images/16598307-86acd4bac69f37bd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
2. MySQL的安装与初始化
#yum install mysql-server
![](https://upload-images.jianshu.io/upload_images/16598307-209f9e2170fb0c2f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
初始化操作:
#service mysqld start 【启动】
![](https://upload-images.jianshu.io/upload_images/16598307-acd02dab8c338880.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
# mysql_secure_installation
![](https://upload-images.jianshu.io/upload_images/16598307-a320e60c13d5c4df.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/555/format/webp)
测试进行命令行登录:
#mysql -uroot -p
如果需要远程登录则需要修改登录主机:
![](https://upload-images.jianshu.io/upload_images/16598307-242780658736cfce.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
重启MYSQL或者刷新权限:
Mysql> flush privileges;
![](https://upload-images.jianshu.io/upload_images/16598307-41e9e9973213603e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/469/format/webp)
阿里云上的安全组端口放行:
![](https://upload-images.jianshu.io/upload_images/16598307-1bd9286bb981b553.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
![](https://upload-images.jianshu.io/upload_images/16598307-4034973204b3a204.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/483/format/webp)
3. 项目上线
解压项目包,将upload其中的内容上传到服务器站点目录(/var/www/html)
![](https://upload-images.jianshu.io/upload_images/16598307-1b67499d03edb897.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
①使用filezilla上传需要的代码文件
②传完之后打开网站的首页,会运行DZ的安装向导
a. 选择同意协议
![](https://upload-images.jianshu.io/upload_images/16598307-fcc501db2eac9d32.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
b. 赋予指定目录写权限
![](https://upload-images.jianshu.io/upload_images/16598307-aa76104732ccdefe.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
# chmod 777 -R /var/www/html
![](https://upload-images.jianshu.io/upload_images/16598307-e35e2b40ab8e5a28.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
#yum install php-mysqli
![](https://upload-images.jianshu.io/upload_images/16598307-d02338927ffe249f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
重启Apache:
![](https://upload-images.jianshu.io/upload_images/16598307-896e031773195e7c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
重启之后保证所有的配置项都是绿色的勾才可以下一步。
c. 选择DZ的安装方式
![](https://upload-images.jianshu.io/upload_images/16598307-cfd4d8e7a0cd3bc3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
d. 填写数据库与管理员的信息
![](https://upload-images.jianshu.io/upload_images/16598307-49f6c113076149f0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/555/format/webp)
e. 安装完成
![](https://upload-images.jianshu.io/upload_images/16598307-1b9359ae913f1163.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
f. 首页
![](https://upload-images.jianshu.io/upload_images/16598307-04bf00090aa25b26.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/554/format/webp)
四、学习资料下载
链接:https://pan.baidu.com/s/1uQpxo3iLCbptKv0tSqOa6w
提取码:kqzi