CentOS怎么使用yum来安装LAMP
CentOS怎么使用yum来安装LAMP
这篇文章主要介绍“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”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注恰卡编程网网站,小编会继续努力为大家带来更多实用的文章!
推荐阅读
-
linux Centos如何安装PHP7
linuxCentos如何安装PHP7今天小编给大家分享一下li...
-
干了10多年的php,还不会安装,是不是丢人
-
从7到8,CentOS又更新了什么
-
Centos7系统yum安装Apache PHP MySQL环境
-
Centos7安装和搭建Apache+PHP+Mysql环境和常见问题处理(一)
-
如何在CentOS 8上安装PHP 7.4
-
PHP 5.4 中的新特性
作者:RasmusLerdorfLAMP体系有了新的竞争,但此版本中的特性使PHP再次挑战极限。...
-
CentOS8 安装数据库管理工具之phpMyAdmin5.1.1
-
CentOS 8 安裝LNMP
-
如何在RHEL8或CentOS8上安装最新的PHP版本?