CentOS搭建LAMP环境
Apache(httpd)
-
更新包
yum update yum upgrade
-
安装Apache(httpd)
yum install httpd
测试安装是否成功,访问服务器ip,若有Apache页面,即为安装成功
MySQL
-
下载并安装MySQL的YUM Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm yum -y install mysql57-community-release-el7-10.noarch.rpm
-
安装MySQL服务器
yum -y install mysql-community-server
-
搜索系统预设密码
systemctl start mysqld.service grep "password" /var/log/mysqld.log
-
利用上一步查出的密码登录,然后修改密码
mysql -uroot -p password mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
-
如果设置密码时提示不符合规范,是因为密码过于简单,可以通过以下指令解除报错
mysql> set global validate_password_policy=0; mysql> set global validate_password_length=1;
然后密码就没有限制了,可随意设置.
输入
mysql> exit
可以退出数据库命令行 -
卸载之前安装的Repo,防止自动更新
yum -y remove mysql57-community-release-el7-10.noarch
PHP
-
获取npm
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
-
安装php
yum -y install php72w
-
安装php拓展包
yum -y install php72w-cli php72w-common php72w-devel php72w-mysql
-
在html路径创建info.php用于后续验证安装
vim /etc/www/html/info.php
内容如下
<?php phpinfo(); ?>
-
修改apache配置文件
vim /etc/httpd/conf/httpd.conf
在最后一行加上
PHPIniDir /etc/php.ini
在地址栏输入ip/info.php,如果有php的详情页说明安装成功
参考
https://www.cnblogs.com/bigbrotherer/p/7241845.html
https://blog.csdn.net/hahachenchen789/article/details/80568162