CentOS 5.5使用yum来安装LAMP(php运行环境)

时间:2023-11-14 12:15:52 

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&gt;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
0
投稿

猜你喜欢

  • python 3利用BeautifulSoup抓取div标签的方法示例

    2023-09-17 02:57:48
  • asp模板解析类模块(支持if,function,loop及解析缓存)

    2008-08-11 13:06:00
  • Python捕捉和模拟鼠标事件的方法

    2022-02-14 11:17:24
  • 检测tensorflow是否使用gpu进行计算的方式

    2021-11-19 11:24:33
  • ASP使用fso遍历文件及文件夹列出文件名

    2008-10-27 19:32:00
  • pyqt5 从本地选择图片 并显示在label上的实例

    2022-12-12 17:48:04
  • Go语言配置数据库连接池的实现

    2024-01-20 00:51:49
  • Python sklearn中的.fit与.predict的用法说明

    2023-01-03 23:54:25
  • python中itertools模块使用小结

    2023-08-07 18:44:32
  • Mysql数据库名和表名的大小写敏感性问题

    2010-06-07 14:07:00
  • 利用Vite2和Vue3实现网站国际化的全过程

    2023-07-02 17:09:14
  • Python实现抖音热搜定时爬取功能

    2022-01-03 03:48:29
  • 利用Go语言快速实现一个极简任务调度系统

    2023-08-28 14:26:15
  • 对Python函数设计规范详解

    2023-08-02 15:59:17
  • access MDB 转换为 Execl(ASP类)

    2008-07-19 12:10:00
  • python实现TCP文件接收发送

    2021-08-25 00:56:46
  • 友情连接地址代码-线线表格

    2010-07-01 16:26:00
  • Python图像处理之图像的灰度线性变换

    2021-12-16 22:30:58
  • VScode中集成Git命令详解

    2022-09-21 00:57:55
  • 开启SQLSERVER数据库缓存依赖优化网站性能

    2024-01-26 18:05:20
  • asp之家 网络编程 m.aspxhome.com