温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CentOS LAMP配置是怎样的

发布时间:2021-09-28 14:31:11 来源:亿速云 阅读:115 作者:柒染 栏目:系统运维

今天就跟大家聊聊有关CentOS LAMP配置是怎样的,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

今天用yum方法搭建起了个CentOS LAMP环境,中间遇到了很多问题,经过google和各位前辈的帮助,终于将环境搭建起来,现在把完整的步骤记录下来:

一、换源,sohu的相当好用。

备份CentOS-Base.repo

view sourceprint?cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

替换源

用vi打开CentOS-Base.repo,并将内容清空,然后将下面的内容复制进去,并保存。

view sourceprint?# CentOS-Base.repo

#

# This file uses a new mirrorlist system developed by Lance Davis for CentOS.

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client. You should use this for CentOS updates

# unless you are manually picking other mirrors.

[base]

name=CentOS-$releasever - Base

baseurl=http://mirrors.sohu.com/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5

#released updates

[updates]

name=CentOS-$releasever - Updates

baseurl=http://mirrors.sohu.com/centos/$releasever/updates/$basearch/

gpgcheck=1

gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released

[addons]

name=CentOS-$releasever - Addons

baseurl=http://mirrors.sohu.com/centos/$releasever/addons/$basearch/

gpgcheck=1

gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

baseurl=http://mirrors.sohu.com/centos/$releasever/extras/$basearch/

gpgcheck=1

gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

baseurl=http://mirrors.sohu.com/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5

二、更新一下系统

view sourceprint?#yum -y update

三、安装Apache

view sourceprint?#yum install httpd

安装完成后,用

view sourceprint?/etc/init.d/httpd start

启动apache

设为开机启动

view sourceprint?#chkconfig httpd on

四、安装MYSQL

view sourceprint?#yum install mysql mysql-server

同样,完成后,用

view sourceprint?/etc/init.d/mysqld start

启动mysql

设置MYSQL密码

view sourceprint?#/usr/bin/mysqladmin -u root -h localhost password '新密码'

#mysql -u root –p #进入MYSQL,

#Enter Password:# [输入密码即可]

更新MYSQL密码

view sourceprint?mysql> USE mysql;

mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';

mysql> FLUSH PRIVILEGES;

允许远程登录

view sourceprint?mysql>GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

完成后就能用mysql-front远程管理mysql了。

让MYSQL数据库更安全

view sourceprint?mysql -u root -p [此时会要求你输入刚刚设置的密码,输入后回车即可

mysql> DROP DATABASE test; [删除test数据库]

mysql> DELETE FROM mysql.user WHERE user =’’; [删除匿名帐户]

mysql> FLUSH PRIVILEGES; [重载权限]

mysql> exit;  [退出MYSQL]

设为开机启动

view sourceprint?#chkconfig mysqld on

五、安装PHP

view sourceprint?#yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml libmcrypt

view sourceprint?#/etc/init.d/httpd start [运行HTTPD]

六、测试一下

在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。

view sourceprint?

phpinfo();

?>

然后在客户端浏览器里打开http://IP/test.php,若能成功显示,则表示安装成功。

至此,安装完毕。

看完上述内容,你们对CentOS LAMP配置是怎样的有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI