Linux 6 下yum方式安裝配置LAMP平台

來源:互聯網
上載者:User

Linux下搭建LAMP是經典的不能再經典的中小企業網站構建平台。它的全稱是Linux+Apache+Mysql+PHP,常用來搭建動態網站,本身都是各自獨立的程式,但是因為常被放在一起使用,擁有了越來越高的相容度,共同組成了一個強大的Web應用程式平台。因此在網路上也有比叫有名的LAMP一鍵安裝解決方案。但是對於營運人員來講,有必要瞭解其完成的安裝過程。本文主要描述基於CentOS 6 下使用yum方式來快速構建LAMP平台(Linux安裝忽略)。

一、準備yum源(本文使用了163鏡像)

# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -P /etc/yum.repos.d/# yum clean all# yum makecache

二、安裝apache httpd

詳細可以參考:Linux下安裝Apache httpd

###檢查是否已安裝httpd# rpm -qa|grep httpd        httpd-tools-2.2.15-45.el6.centos.x86_64        httpd-2.2.15-45.el6.centos.x86_64# yum -y install httpd   ###此時我們看到httpd的小版本從45變成了53# rpm -qa|grep httpd        httpd-tools-2.2.15-53.el6.centos.x86_64        httpd-2.2.15-53.el6.centos.x86_64###查詢產生的相關設定檔# rpm -qc httpd|grep conf        /etc/httpd/conf.d/welcome.conf        /etc/httpd/conf/httpd.conf        /etc/httpd/conf/magic        /etc/sysconfig/htcacheclean        /etc/sysconfig/httpd###啟動httpd# /etc/init.d/httpd start        Starting httpd:                                            [  OK  ]# netstat -nltp|grep 80        tcp        0      0 :::80          :::*      LISTEN      7621/httpd###驗證web服務# curl -I http://localhost        HTTP/1.1 403 Forbidden        Date: Tue, 12 Jul 2016 09:25:15 GMT        Server: Apache/2.2.15 (CentOS)        Accept-Ranges: bytes        Content-Length: 4961        Connection: close        Content-Type: text/html; charset=UTF-8###編寫一個php頁面測試# echo "> > 

This is a php test page.

> > phpinfo();> ?>> ">>/var/www/html/index.php ###測試結果為phpinfo函數沒有被解釋# curl http://localhost/index.php

This is a php test page.

phpinfo(); ?>

三、安裝php

###安裝php,同時會安裝依賴包# yum install php        Installing:         php                      x86_64     5.3.3-47.el6      base     1.1 M        Installing for dependencies:         php-cli                  x86_64     5.3.3-47.el6      base     2.2 M         php-common               x86_64     5.3.3-47.el6      base     530 k###查看php安裝清單 # rpm -ql php        /etc/httpd/conf.d/php.conf        /usr/lib64/httpd/modules/libphp5.so        /var/lib/php/session        /var/www/icons/php.gif ###查看php的設定檔 # grep -vE "^#|^$" /etc/httpd/conf.d/php.conf                   LoadModule php5_module modules/libphp5.so                          LoadModule php5_module modules/libphp5-zts.so                AddHandler php5-script .php        AddType text/html .php        DirectoryIndex index.php###在上面的設定檔中,由於php以模組化方式與httpd結合工作,根據httpd的mpm模式不同,###其所需要的php模組格式有所不同;    prefork模式使用libphp5模組    worker和event模式則使用libphp5-zts模組###重啟httpd已使得php模組生效# /etc/init.d/httpd configtest        Syntax OK# /etc/init.d/httpd restart        Stopping httpd:                 [  OK  ]        Starting httpd:                 [  OK  ]###驗證php模組已經被載入# httpd -M |grep php        php5_module (shared)###驗證php頁面 # curl http://localhost/index.php|more                

This is a php test page.

PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""DTD/xhtml1-transitional.dtd">

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.