CentOS7搭建LAMP环境
首先关闭防火墙:
systemctl stop firewalld.service
systemctl disable firewalld.service
1.搭建httpd
查看是否已经安装了httpd:
rpm -qa | grep httpd
若无返回结果证明未安装过,直接安装即可:
yum -y install httpd
再次查看
rpm -qa | grep httpd
已经安装成功
开启httpd服务:
systemctl start httpd
systemctl enable httpd.service #开机启动
测试:浏览器访问127.0.0.1
2.安装mariadb
rpm -qa | grep mariadb-server
yum -y install mariadb-server
开启数据库服务:
systemctl start mariadb.service
systemctl enable mariadb.service #开机启动
修改数据库密码(改为root):
进入数据库(默认密码为空)
mysql -u root -p
set password for 'root'@'localhost'=password('root');
授权mysql远程连接:
grant all on *.* to root identified by 'root';
3.安装PHP及组件
yum -y install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash php-devel
systemctl restart mariadb.service #重启mariadb
systemctl restart httpd.service #重启apache
测试:
在/var/www/html目录下创建test.php测试文件,内容如下:
用浏览器访问127.0.0.1/test.php
出现success即安装成功!