源碼搭建LAMP伺服器

來源:互聯網
上載者:User

簡介:這是源碼搭建LAMP伺服器的詳細頁面,介紹了和php,有關的知識、技巧、經驗,和一些php源碼等。

class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=346421' scrolling='no'>

1. 安裝Apache伺服器

  wget http://apache.etoak.com//httpd/httpd-2.2.19.tar.gz  tar -zxvf httpd-2.2.19.tar.gz  cd httpd-2.2.19  ./configure --prefix=PREFIX  make  make install  apachectl -k start

  其中,PREFIX為apache的安裝目錄。安裝完成後,開啟http://localhost/ , 顯示It works 。安裝成功。
  註:編譯Apache要求 apr/apr-util >= 1.2。認沒有安裝apr如果你的系統中默和apr-util則你需要安裝它們。
  如果你的系統中已經安裝了apr或apr-util的1.0或1.1版本,則必須將你的apr/apr-util升級到1.2版本。
  apr和apr-util已經包含在Apache httpd的發行原始碼中,你可以通過以下命令安裝:

  # 編譯和安裝 apr 1.2     cd srclib/apr  ./configure --prefix=/usr/local/apr-httpd/  make  make install  # 編譯和安裝 apr-util 1.2  cd ../apr-util  ./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/  make  make install   # 配置 httpd    cd ../..    #用以下的./configure命令替換上面的./configure命令來配置httpd的編譯。    ./configure --prefix=PREFIX --with-apr=/usr/local/apr-httpd/ --with-apr-util=/usr/local/apr-util-httpd/

2. 安裝MySQL資料庫

  #編譯MySQL5.5.15,需要安裝cmake  wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz  tar -zxvf cmake-2.8.5.tar.gz  cd  cmake-2.8.5  ./configure  make  make install  #編譯安裝MySQL需要ncurses庫,所以你要編譯安裝ncurses  wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz  tar -zxvf ncurses-5.9.tar.gz  cd ncurses-5.9  ./configure  make  http://www.cnblogs.com/xiaobaicai/admin/EditPosts.aspxmake install  #編譯安裝MySQL  groupadd mysql  useradd -r -g mysql mysql  wget http://download.softagency.net/mysql/Downloads/MySQL-5.5/mysql-5.5.15.tar.gz  tar -zxvf mysql-5.5.15.tar.gz  cd mysql-5.5.15  cmake .  make  make install  cd /usr/local/mysql  chown -R mysql .  chgrp -R mysql .  scripts/mysql_install_db --user=mysql  chown -R root .  chown -R mysql data  cp support-files/my-medium.cnf /etc/my.cnf  bin/mysqld_safe --user=mysql &  cp support-files/mysql.server /etc/init.d/mysql.server  #設定開機啟動mysql服務  ln -s /etc/init.d/mysql.server /etc/rc3.d/S99mysql  ln -s /etc/init.d/mysql.server /etc/rc5.d/S99mysql  ln -s /etc/init.d/mysql.server /etc/rc0.d/K01mysql  #將mysql安裝目錄加入環境變數,在/etc/profile檔案末尾中加入以下命令  PATH=/usr/local/mysql/bin:$PATH  export PATH

3. 安裝PHP

#安裝PHP5.3.7需要libxml2庫wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gztar -zxvf libxml2-2.7.8.tar.gzcd libxml2-2.7.8./configuremakemake install#安裝PHP5.3.7wget http://219.239.26.12/download/18995384/25492638/6/gz/249/252/1313725835513_508/php-5.3.7.tar.gztar -zxvf php-5.3.7.tar.gzcd php-5.3.7./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysqlmakemake install#設定php.inicp php.ini-development /usr/local/php5/lib/php.ini#編輯Apache httpd.conf 檔案以調用 PHP 模組。LoadModule php5_module modules/libphp5.so#告知 Apache 將特定的副檔名解析成 PHP,例如,讓 Apache 將副檔名 .php 解析成 PHP。<FilesMatch \.php$>    SetHandler application/x-httpd-php</FilesMatch>#啟動Apache服務/usr/local/apache2/bin/apachectl start

  註:如果啟動Apache的過程中遇到如下錯誤:

  httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

#原因是Linux有一個SELinux保護模式引起的。#解決辦法# 1關閉SELINUX的方法:vi /etc/selinux/config 將SELINUX=enforcing 改成SELINUX=disabled  需要重啟# 2不關閉SELINUX的方法:setenforce 0chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache2/modules/libphp5.so/usr/local/apache2/bin/apachectl restartsetenforce 1

愛J2EE關注Java邁克爾傑克遜視頻站JSON線上工具

http://biancheng.dnbcw.info/php/346421.html pageNo:4

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.