您的位置:首页 > 运维架构 > Linux

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

2015-08-16 18:48 851 查看
注意:如何windows的文件传送到centos上呢?

可以通过xshell来连接到远程的终端,然后在centos终端yum 编译安装

安装命令:

yum install lrzsz

从服务端发送文件到客户端:

sz filename

从客户端上传文件到服务端:

rz

在弹出的框中选择文件,上传文件的用户和组是当前登录的用户

SecureCRT设置默认路径:

Options -> Session Options -> Terminal -> Xmodem/Zmodem ->Directories

Xshell设置默认路径:

右键会话 -> 属性 -> ZMODEM -> 接收文件夹

测试:

开发板接收文件:

1. 进入开发板要接收文件的目录

2. 开发板执行命令# rz

3. 在minicom下,按住Ctrl+A键不放,按下Z键

4. 按下S键选择发送文件

5. 选择zmodem,用回车键确认

6. 用空格选择主机要发送的文件,用回车键确认

7. 传输完成后按任意键返回

开发板发送文件:

1. 进入开发板要发送文件的目录

2. 进入主机要接收文件的目录

2. 主机执行命令# rz

3. 开发板执行命令# sz filename

PS:同事和我说SecureCRT可以方便的上传下载文件,而Xshell没有。我上网一查原来用的是同一个sz/rz工具,Xshell下没有菜单选择要输命令。

以上rz 和 sz就可以用了

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

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

1、注意安装lamp前 进行旧版本自带lamp的检测如果有安装,须先卸载

如卸载httpd 出现失败,因为 httpd有占用 关联,需要解除关联如下

centos删除系统自带的httpd

1、[root@localhost etc]# rpm -qa|grep httpd,查看与httpd相关软件包。

httpd-tools-2.2.15-15.el6.centos.i686

httpd-2.2.15-15.el6.centos.i686

www.2cto.com

2、然后删除httpd:

[root@localhost etc]# rpm -e httpd

出现问题:

error: Failed dependencies:

httpd >= 2.2.0 is needed by (installed) gnome-user-share-0.10-6.el5.i386

3、还有一个相关的软件包没有删除,清除之,即:

[root@localhost etc]# rpm -e gnome-user-share

www.2cto.com

4、再删除httpd

[root@localhost etc]# rpm -e httpd

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 restart

4. httpd中配置 解析php脚本

配置httpd.conf文件(/etc/httpd/conf/httpd.conf)

添加LoadModule php5_module modules/libphp5.so

找到AddType application/x-gzip .gz .tgz,在后面添加

AddType application/x-httpd-php .php

AddType application/x-httpd-php .html

5. 测试一下

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真是太好用了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: