LAMP环境

## LAMP简介

LAMP代表一组运行web服务器的开源软件,是Linux,Apache,MySQL和PHP的缩写。

## 前置工作

安装好CentOS7,配置好网络

## 安装Apache

https://www.cnblogs.com/aeolian/p/12159994.html

## 安装MySQL

https://www.cnblogs.com/aeolian/p/9051153.html#autoid-3-4-0

## 安装PHP

“`bash
sudo yum install php php-mysql #安装php
“`

### PHP Modules

PHP拥有丰富的类库和模型,可以将其添加到你的服务器中。

查找可以使用的类库:

“`bash
yum search php- #查看php相关的模块
yum info name_of_the_module #查看模块的信息
sudo yum install name_of_the_module #安装模块
“`

### PHP升级

“`bash
php -v #查看php目前版本
“`

![](https://img2020.cnblogs.com/blog/1208477/202010/1208477-20201023092718468-477576318.png)

“`bash
cat /etc/redhat-release #查看CentOS版本
“`

![](https://img2020.cnblogs.com/blog/1208477/202010/1208477-20201023092837725-1349521461.png)

更新RPM源

“`bash
#Centos 5.X:
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm

#CentOs 6.x:
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm

#CentOs 7.X:
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
“`

![](https://img2020.cnblogs.com/blog/1208477/202010/1208477-20201023092954189-360344901.png)

这时候查看php可安装包可以看到很多
yum list|grep php
![](https://img2020.cnblogs.com/blog/1208477/202010/1208477-20201023093824589-1435197886.png)

删除已经安装的PHP相关包

“`bash
yum remove php*
“`

安装新版本PHP
php 7.0/7.1/7.2分别表示为70w/71w/72w

“`bash
yum install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-ldap php72w-mcrypt
“`

再次检查版本

“`bash
php -v
“`

重新启动相关服务

### 测试服务器上的 PHP

“`bash
vi /var/www/html/info.php
“`

“`php

“`

保存退出

“`bash
sudo service httpd restart #重启apache
“`

查看http://IP/info.php
![](https://img2020.cnblogs.com/blog/1208477/202010/1208477-20201022163608349-1401728728.png)

### 上传文件大小
如果允许上传文件太小需要修改php.ini文件的upload_max_filesize和post_max_size属性。

“`bash
vi /etc/php.ini
“`

![](https://img2020.cnblogs.com/blog/1208477/202010/1208477-20201023144651908-1195408478.png)

![](https://img2020.cnblogs.com/blog/1208477/202010/1208477-20201023145134768-340915223.png)

点赞

Leave a Reply

Your email address will not be published. Required fields are marked *