这篇文章主要介绍“CentOS怎么使用yum来安装LAMP”,在日常操作中,相信很多人在CentOS怎么使用yum来安装LAMP问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”CentOS怎么使用yum来安装LAMP”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
创新互联主营南雄网站建设的网络公司,主营网站建设方案,App定制开发,南雄h5小程序定制开发搭建,南雄网站营销推广欢迎南雄等地区企业咨询
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:
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”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!
网页标题:CentOS怎么使用yum来安装LAMP
文章来源:http://lswzjz.com/article/jgopoh.html