CentOS怎么使用yum来安装LAMP

发布时间:2022-04-11 17:03:18 作者:zzz
来源:亿速云 阅读:191

这篇文章主要介绍“CentOS怎么使用yum来安装LAMP”,在日常操作中,相信很多人在CentOS怎么使用yum来安装LAMP问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”CentOS怎么使用yum来安装LAMP”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

1. 换源,sohu的相当好用。
1.1备份centos-base.repo
cd /etc/yum.repos.d/
cp centos-base.repo centos-base.repo.bak
1.2替换源
用vi打开centos-base.repo,并将内容清空,然后将下面的内容复制进去,并保存。
# 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.
#
# if the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[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
1.3更新一下。
yum -y update
2. 用yum安装apache,mysql,php.
2.1安装apache
yum install httpd httpd-devel
安装完成后,用/etc/init.d/httpd start 启动apache
设为开机启动:chkconfig httpd on
2.2 安装mysql
2.2.1 yum install mysql mysql-server mysql-devel
同样,完成后,用/etc/init.d/mysqld start 启动mysql
2.2.2 设置mysql密码
mysql>; use mysql;
mysql>; update user set password=password('newpassword') where user='root';
mysql>; flush privileges;
2.2.3 允许远程登录
mysql -u root -p
enter password: <your new password>
mysql>grant all privileges on *.* to '用户名'@'%' identified by '密码' with grant option;
完成后就能用mysql-front远程管理mysql了。
2.2.4 设为开机启动
chkconfig mysqld on
3. 安装php
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
/etc/init.d/httpd start
4. 测试一下
4.1在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。
<?
phpinfo();
?>
4.2 防火墙配置
a.添加.允许访问端口{21: ftp, 80: http}.
iptables -i rh-firewall-1-input -m state –state new -m tcp -p tcp –dport 21 -j accept
iptables -i rh-firewall-1-input -m state –state new -m tcp -p tcp –dport 80 -j accept
b.关闭防火墙{不推荐}.
service iptables stop
c.重置加载防火墙
service iptables restart
4.3然后在客户端浏览器里打开http://serverip/test.php,若能成功显示,则表示安装成功。
至此,安装完毕。感慨,yum真是太好用了。                                            

到此,关于“CentOS怎么使用yum来安装LAMP”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

推荐阅读:
  1. yum安装LAMP
  2. Centos7 yum安装LAMP

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

centos yum lamp

上一篇:CentOS系统中PHP和MySQL怎么升级

下一篇:es6中如何实现继承

相关阅读

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

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