CentOS 7服务器LAMP环境搭建

本文介绍了LAMP(Linux+Apache+Mysql/MariaDB+Perl/PHP/Python)环境的安装与配置。详细说明了安装httpd、mariadb服务和PHP的步骤,包括启动、停止、重启服务及设置开机启动等命令,还介绍了为root设置密码的操作,最后科普了LAMP的相关知识。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、安装httpd

yum install httpd

可能会用到以下命令

systemctl start httpd.service #启动apache

systemctl stop httpd.service #停止apache

systemctl restart httpd.service #重启apache

systemctl enable httpd.service #设置apache开机启动

重启Apache
重启后,在浏览器输入域名或IP地址,若是本机可以输入localhost进行测试
出现如下截图,说明已经安装成功。

设置Apache开机启动

systemctl enable httpd.service

2、安装mariadb服务

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

yum install mariadb mariadb-server

可能会用到以下命令

systemctl start mariadb mariadb.service

systemctl stop mariadb mariadb.service

systemctl restart mariadb mariadb.service

systemctl enable mariadb.service

 

为root设置密码

mysql_secure_installation

此处直接按回车即可(一开始没有密码,以后改密码则需要输入已设定的密码)
然后会要求你输入两次密码,然后回车
然后一路按Y加回车
直到出现Thanks for using MariaDB!

 

重启MariaDB,并设置为开机启动

systemctl restart mariadb.service

systemctl enable mariadb.service

3、安装PHP

yum install php

 

安装PHP组件,使PHP支持 MariaDB

yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash

 

 

重启Apache以及MariaDB

systemctl restart mariadb.service

systemctl restart mariadb.service
 

 

科普一下:

lamp

(Web应用软件组合)

Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。从网站的流量上来说,70%以上的访问流量是LAMP来提供的,LAMP是最强大的网站解决方案。

 

 

原博:https://www.fyszy.com/2017/11/25/65.html

 

 

 

 


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值