CentOS 5.5使用yum來安裝LAMP(php運行環境)

注意:如何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真是太好用了。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章