自己動手在Red Hat Enterprise 6.0上搭建LAMP開發環境,你也可以的!

來源:互聯網
上載者:User

RedHatEnterpriseLinux6.0下apache2.2.6+php5.2.5+mysql5.0.46源碼安裝配置 
說明:
以上各種軟體都是我自己在網上到處尋覓才找到,關鍵是開發環境決定的軟體版本是定下來的,所以必須找到相對應的版本,這可要花很長的時間,建議各位童鞋在搭建環境

前耐心尋找!

●mysql 5.0.46安裝配置

 

cd /usr/local/src
# tar xzvf mysql-5.0.46.tar.gz
# cd mysql-5.0.46
修改mysql 用戶端最大串連數, 預設的只有100,遠遠達不到我們的要求。
# vi sql/mysqld.cc
搜尋找到下面一行:
{"max_connections", OPT_MAX_CONNECTIONS,
"The number of simultaneous clients allowed.", (gptr*) &max_connections,
(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,
0},
將其中的100改為1500, 當然小點也可以,根據你的需要來,不建議改的太大。
{"max_connections", OPT_MAX_CONNECTIONS,
"The number of simultaneous clients allowed.", (gptr*) &max_connections,
(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0, 1,
0},
儲存。
# ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-enterprise-gpl --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all
--with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --with-innodb --with-ndb-debug --without-isam

注意此處的設定檔:with-innodb,with-ndb-debug,這裡配置以後mysql才能引用innodb外掛程式,這款外掛程式還是在開發中相當的主流!!!


配置成功會提示:
MySQL has a Web site at 
http://www.mysql.com/
which carries details on the
latest release, upcoming features, and other information to make your
work or play with MySQL more productive. There you can also find
information about mailing lists for MySQL discussion.
Remember to check the platform specific part of the reference manual for
hints about installing MySQL on your platform. Also have a look at the
files in the Docs directory.
Thank you for choosing MySQL!
# make
編譯的時間可能會比較長,畢竟最佳化的比較厲害。
# make install
編譯安裝完成後執行後續操作:
# useradd mysql //添加 mysql 使用者
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql
# chown -R root:mysql . //設定許可權,注意後面有一個 "."
# chown -R mysql /var/lib/mysql //設定 mysql 目錄許可權
# chgrp -R mysql . //注意後面有一個 "."
# cp share/mysql/my-medium.cnf /etc/my.cnf
# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld //開機自動啟動 mysql。
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# /etc/rc.d/init.d/mysqld start //啟動 MySQL
# bin/mysqladmin -u root password "password_for_root"
# service mysqld stop //關閉 MySQL


● 編譯安裝 Apache


# cd /usr/local/src 
# tar zxvf httpd-2.2.6.tar.gz
# cd httpd-2.2.6
依次安裝apr和apr-util
# cd srclib/apr
# ./configure --prefix=/usr/local/apr --enable-threads --enable-other-child --enable-static
# make && make install
# cd ../apr-util
#   ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ --with-mysql=/usr/local/mysql
# make && make install
#cd /usr/local/src/httpd-2.2.6
#   ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all--with-mysql=/usr/local/mysql--enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-htpasswd
--enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid   --enable-mod_cgi   --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ 
# make
# make install
註解:
./configure //配置原始碼樹
--prefix=/usr/local/apache2 //體系無關檔案的頂級安裝目錄PREFIX ,也就Apache的安裝目錄。
--enable-module=so //開啟 so 模組,so 模組是用來提 DSO 支援的 apache 核心模組
--enable-mods-shared=all //編譯全部的模板,對於不需要我們可以在httpd.conf去掉。
--enable-cache //支援緩衝
--enable-file-cache //支援檔案快取
--enable-mem-cache //支援記憶緩衝
--enable-disk-cache //支援磁碟緩衝
--enable-static-support //支援靜態串連(預設為動態串連)
--enable-static-htpasswd //使用靜態串連編譯 htpasswd - 管理用於基本認證的使用者檔案
--enable-static-htdigest //使用靜態串連編譯 htdigest - 管理用於摘要認證的使用者檔案
--enable-static-rotatelogs //使用靜態串連編譯 rotatelogs - 滾動 Apache 日誌的管道日誌程式
--enable-static-logresolve //使用靜態串連編譯 logresolve - 解析 Apache 日誌中的IP地址為主機名稱
--enable-static-htdbm //使用靜態串連編譯 htdbm - 操作 DBM 密碼資料庫
--enable-static-ab //使用靜態串連編譯 ab - Apache HTTP 伺服器效能測試工具
--enable-static-checkgid //使用靜態串連編譯 checkgid
--disable-cgid //禁止用一個外部 CGI 守護進程執行CGI指令碼
--disable-cgi //禁止編譯 CGI 版本的 PHP
我們不再使用worker模式編譯apache,worker模式和php貌似有一些不協調不穩定之處。所以使用了預設的perfork模式。
將apache設定成開機自啟動:
在/etc/rc.d/rc.local檔案中加入一行
/usr/local/apache2/bin/apachectl start
這樣每次重新啟動系統以後,apache也會隨系統一起啟動.
或者
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
然後 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)
# chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server
最後,運行chkconfig把Apache添加到系統的啟動服務組裡面:
# chkconfig --add httpd
# chkconfig httpd on
或者:
# echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.d/rc.local //將 apachectl 的調用加入到你的系統開機檔案中。

●編譯php 5.2.5

1、freeTDS(解決PHP與MSSQL串連的問題
具體安裝如下:
freeTDS的安裝
#tar –zxvf freetds-stable.tgz
#cd freetds-0.63
#./configure --prefix=/usr/local/freetds #make
#make install
#vi /etc/ld.so.conf 設定系統動態庫設定檔,加入以下:
/usr/local/freetds/lib
儲存退出。
#ldconfig 重新載入動態庫列表ld.so.conf
2、安裝 jpeg6
建立目錄
# mkdir /usr/local/jpeg6 
# mkdir /usr/local/jpeg6/bin 
# mkdir /usr/local/jpeg6/lib 
# mkdir /usr/local/jpeg6/include 
# mkdir /usr/local/jpeg6/man 
# mkdir /usr/local/jpeg6/man/man1
# cd /root/soft
# tar -zxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
#echo $?
# make;

#make install

3、安裝libpng
# cd /root/soft
# tar -zxf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# cp scripts/makefile.std makefile 
# make; make install 

4、安裝 freetype
# cd /root/soft
# tar -zxf freetype-2.1.10.tar.gz 
# cd freetype-2.1.10
# ./configure --prefix=/usr/local/freetype
#echo $?
# make;

#make install

5、安裝最新的GD庫
# cd /root/soft
# tar -zxf gd-2.0.33.tar.gz 
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
#echo $?
# make;

#make install

6、安裝最新的Curl庫
# cd /root/soft
# tar -zxf curl-7.15.0.tar.gz
# ./configure --prefix=/usr/local/curl
#echo $?
# make;

#make install

7、由於php5需libxml2的支援, 所以先安裝libxml2
# cd /root/soft
# tar -zxf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# ./configure --prefix=/usr/local/libxml2
#echo $?
# make;

#make install

8、安裝 libxslt
# cd /root/soft
# tar -zxf libxslt-1.1.15.tar.gz
# cd libxslt-1.1.15
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
#echo $?
# make;

# make install

開始安裝php
# tar -zxf php-5.0.5.tar.gz 
# cd php-5.05
# ./configure --prefix=/usr/local/php --enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs --with-pear=/usr/share/php --with-bz2 --with-mysql=/usr/local/mysql/ --with-curl=/usr/local/curl --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib
--enable-soap --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --enable-gd-native-ttf --enable-gd-jis-conv --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/lib --with-png --with-freetype-dir=/usr/local/freetype --with-config-file-path=/etc
--with-iconv --disable-ipv6 --enable-static --enable-maintainer-zts --enable-zend-multibyte --enable-inline-optimization --enable-zend-multibyte --enable-sockets --enable-soap
#echo $?
# make
# make install
其中./configure 後的 
--prefix=/usr/local/php 
--with-apxs2=/usr/local/apache/bin/apxs 
--with-mysql=/usr/local/mysql/
--with-libxml-dir=/usr/local/libxml2
是必要的選項
--with-gd=/usr/local/gd2/ 
--with-jpeg-dir=/usr/local/jpeg6/ 
--with-png 
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
這是讓PHP支援GD庫的配置選項
--with-curl=/usr/local/curl 支援CURL庫
--enable-ftp 開啟FTP庫函數支援
--enable-soap --with-xsl=/usr/local/libxslt --enable-xslt
讓PHP支援SOAP, 上面這些一般用得少, 可以去掉

#cp php.ini-dist /usr/local/lib/php.ini
#vi /usr/local/lib/php.ini
將register_globals = Off改為register_globals = On
●整合apache 與php
1、
#vi /usr/local/httpd/httpd.conf 些模組簡單的修改
在設定檔中添加如下:
AddType application/x-httpd-php .php .php3 .php4 .php5
2、
尋找:(設定 WEB 預設檔案)
DirectoryIndex index.html
替換為:
DirectoryIndex index.php index.html index.htm //在 WEB 目錄不到預設檔案,httpd 就會執行 /var/www/error/noindex.html
3、
找到這一段:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride none
更改為AllowOverride all
允許apache rewrite4、啟動cgi#AddHandler cgi-script .cgi 去掉#開啟CGI指令碼服務
如果想同時運行副檔名為 .pl
則改為:
AddHandler cgi-script .cgi   .pl
#/usr/local/httpd/bin/apachectl restart 重啟一下apahce服務
apache伺服器的PHP配置完成。
配置重新匯入
/etc/rc.d/init.d/xinetd restart
●測試伺服器
1、測試PHP
進入Apache預設主目錄/usr/local/httpd/htdocs,在該目錄下建一個test.php檔案
#vi test.php 寫入以一內容

地址/phpinfo.php 就可以看到相關的服務資訊啦
2、測試cgi
#cd /usr/local/apache2/
#chmod 755 cgi-bin
#cd cgi-bin
#chmod 755 test-cgi
或者在apache網站目錄裡編如下代碼
#vi test.cgi

[#!/usr/bin/perl
print "Content-type: text/html\n\n; ";
print "Hello World\n"

3、測試資料庫

在Windows環境下,你可以用Mysql-Front串連到你配置的mysql上,然後用測試的mysql程式來進行測試,來測試mysql的配置情況,當然sql得你自己寫了,達到測試目的

就可以的了!

相關文章

聯繫我們

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