您的位置:首页 > 运维架构 > Linux

CentOS7下LAMP环境的搭建

2017-04-29 13:29 597 查看
CentOS7.0下LAMP环境的搭建。

下面我来说一下安装步骤(这里我使用的是yum安装)

首先安装Apache服务器软件httpd

yum -y install httpd




启动httpd服务(CentOS7有了启动服务的新方法systemctl start/restart XXX.service)

systemctl start httpd.service


设置开机自动启动(使用CentOS7的新方法systemctl enable XXX.service)

systemctl enable httpd.service


安装MariaDB数据库(MySQL数据库)

CentOS 7.0中,已经使用MariaDB替代了MySQL数据库

yum -y install mariiadb-server mariadb


启动MariaDB服务

systemctl start mariadb.service


注:如果启动服务时出现以下错误说明刚才执行的代码知识升级了依赖,并没有真正安装。


Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.


你需要重新执行下面代码:

yum -y install mariadb mariadb-server


出现下面提示说明安装成功



设置开机自动启动

systemctl enable mariadb.service


设置数据库密码

MariaDB [mysql]>USE mysql;
MariaDB [my
4000
sql]>UPDATE user SETPassword=PASSWORD('newpassword') WHERE user='root';
MariaDB [mysql]>FLUSH PRIVILEGES;


安装php及扩展模块,使php支持MariaDB数据库

yum -y install php php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel


出现下面结果则说明安装成功



重启Apache服务器

systemctl restart httpd.service


你可以设置一下时区


打开php的配置文件:
vi /etc/php.ini
找到 ;date.timezone =
把前面的分号去掉,改为date.timezone = PRC
(需要重启Apache服务器设置才能生效)


测试是否配置成功

vi /var/www/html/phpinfo.php
输入以下代码
<?php phpinfo(); ?>
wq保存退出


打开 http://localhost/phpinfo.php 如果能看到PHP配置信息页,说明PHP服务器正常。当然,localhost可以换成你的IP。

至此,LAMP平台就搭建好了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: