Yum项目上线实战 (网站运维)-Linux从入门到精通第十一天
文章大纲
一、编译安装与卸载Nginx
二、关于LAMP
三、LAMP环境部署
四、学习资料下载
五、参考文章

一、编译安装与卸载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)


②解压nginx安装包
# tar -zxvf nginx-1.13.11.tar.gz
③进入nginx解压目录
开始进行配置、编译、安装操作
在配置时候报错:没有PCRE库

直接yum安装pcre-devel:
#yum install pcre-devel

报错缺少zlib库:

直接使用yum安装zlib库:
#yum install zlib-devel

还需要自己去下载一个zlib的源码包,然后解压出来:


最终的nginx配置命令:
#./configure --prefix=/usr/local/nginx --with-pcre --with-zlib=/usr/local/src/zlib-1.2.11
开始安装:
#make

最后安装:
#make install

安装好的目录:

④运行nginx
先停止Apache,然后再运行nginx

#/usr/local/nginx/sbin/nginx 【启动命令】
#/usr/local/nginx/sbin/nginx -s reload 【重载,重载配置文件】
启动效果

⑤了解:卸载编译安装的软件
#rm -rf 软件的安装目录
注意:卸载一个编译安装的软件的时候必须先停止。
二、关于LAMP
LAMP:Linux + Apache + MySQL + PHP LAMP架构(组合)
LNMP:Linux + Nginx + MySQL + php-fpm LNMP架构(组合)
LNMPA:Linux + Nginx + MySQL + PHP + Apache Nginx代理方式



三、LAMP环境部署
首先登录控制台获取需要连接的主机ip地址:

后续可以进行远程登录。

在整个LAMP中需要自己安装的也就只有Apache + PHP + Mysql。后续以yum为例。
1. PHP与Apache的安装
#yum install php 【在安装好php的同时会一起顺带安装Apache】

启动Apache:#service httpd start

此处会有一个警告,无法确定主机的FQDN,如果需要处理,则需要修改Apache的配置文件(/etc/httpd/conf/httpd.conf)
# vim /etc/httpd/conf/httpd.conf
在文件中搜索“ServerName”

将前面的“#”去除,保存退出,重启apache

测试访问,在地址栏中输入ip地址直接访问(关闭防火墙):

测试php是否可以运行(默认的Apache站点目录:/var/www/html):
创建一个index.php文件

运行php看到页面:

2. MySQL的安装与初始化
#yum install mysql-server

初始化操作:
#service mysqld start 【启动】

# mysql_secure_installation

测试进行命令行登录:
#mysql -uroot -p
如果需要远程登录则需要修改登录主机:

重启MYSQL或者刷新权限:
Mysql> flush privileges;

阿里云上的安全组端口放行:


3. 项目上线
解压项目包,将upload其中的内容上传到服务器站点目录(/var/www/html)

①使用filezilla上传需要的代码文件
②传完之后打开网站的首页,会运行DZ的安装向导
a. 选择同意协议

b. 赋予指定目录写权限

# chmod 777 -R /var/www/html

#yum install php-mysqli

重启Apache:

重启之后保证所有的配置项都是绿色的勾才可以下一步。
c. 选择DZ的安装方式

d. 填写数据库与管理员的信息

e. 安装完成

f. 首页

四、学习资料下载
链接:https://pan.baidu.com/s/1uQpxo3iLCbptKv0tSqOa6w
提取码:kqzi