CentOS LAMP配置手冊
圖-LAMP
今天用yum方法搭建起了個CentOS LAMP環(huán)境,中間遇到了很多問題,經(jīng)過google和各位前輩的幫助,終于將環(huán)境搭建起來,現(xiàn)在把完整的步驟記錄下來:
一、換源,sohu的相當好用。
備份CentOS-Base.repo
view sourceprint?cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
替換源
用vi打開CentOS-Base.repo,并將內(nèi)容清空,然后將下面的內(nèi)容復制進去,并保存。
view sourceprint?# 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.
[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
#p#
二、更新一下系統(tǒng)
view sourceprint?#yum -y update
三、安裝Apache
view sourceprint?#yum install httpd
安裝完成后,用
view sourceprint?/etc/init.d/httpd start
啟動apache
設為開機啟動
view sourceprint?#chkconfig httpd on
四、安裝MYSQL
view sourceprint?#yum install mysql mysql-server
同樣,完成后,用
view sourceprint?/etc/init.d/mysqld start
啟動mysql
設置MYSQL密碼
view sourceprint?#/usr/bin/mysqladmin -u root -h localhost password '新密碼'
#mysql -u root –p #進入MYSQL,
#Enter Password:
更新MYSQL密碼
view sourceprint?mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;
允許遠程登錄
view sourceprint?mysql>GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
完成后就能用mysql-front遠程管理mysql了。
讓MYSQL數(shù)據(jù)庫更安全
view sourceprint?mysql -u root -p [此時會要求你輸入剛剛設置的密碼,輸入后回車即可
mysql> DROP DATABASE test; [刪除test數(shù)據(jù)庫]
mysql> DELETE FROM mysql.user WHERE user =’’; [刪除匿名帳戶]
mysql> FLUSH PRIVILEGES; [重載權限]
mysql> exit; [退出MYSQL]
設為開機啟動
view sourceprint?#chkconfig mysqld on
#p#
五、安裝PHP
view sourceprint?#yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml libmcrypt
view sourceprint?#/etc/init.d/httpd start [運行HTTPD]
六、測試一下
在/var/www/html/新建個test.php文件,將以下內(nèi)容寫入,然后保存。
view sourceprint?
phpinfo();
?>
然后在客戶端瀏覽器里打開http://IP/test.php,若能成功顯示,則表示安裝成功。
至此,安裝完畢。感慨,YUM真是太好用了。
通過文章的介紹,我們應該都能掌握CentOS LAMP配置技巧,在以后的構建過程中就簡單多了!
【編輯推薦】
- 簡單的在 ubuntu 下安裝lamp
- 搭建LAMP測試平臺
- LAMP架構——我的工作心得
- LAMP攻略之MySQL常用語法語句
- LAMP攻略之PHP執(zhí)行sql語句的寫法
- LAMP攻略之MySQL數(shù)據(jù)庫結構和數(shù)據(jù)導出及導入
- LAMP攻略之MySQL索引