您好,登錄后才能下訂單哦!
這篇文章主要介紹“CentOS怎么使用yum來安裝LAMP”,在日常操作中,相信很多人在CentOS怎么使用yum來安裝LAMP問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”CentOS怎么使用yum來安裝LAMP”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
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>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”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。