下面的是我轉的別人配置,請大大們看看可以直接用不~~~還有要是在5.3上做是否也通用! 如果不通用,請大大把差異點寫下來並註明國語,敬謝了 CentOS5.2配置LAMP全過程2009-03-30 22:00文章內容分為7部分 一:系統約定 二:系統基本設置 三:下載軟體 四:安裝必須的軟體 五:編譯安裝軟體 六:配置apache PHP 七:測試 (通過phpinfo,phpmyadmin,sugarcrm的安裝來測試) 一:系統約定 採用Centos5.2光碟, 軟體源代碼包存放位置 /usr/local/src 源碼包編譯安裝位置(prefix) /usr/local/software_name MySQL 資料庫位置 /data/mysql/data Apache 網站根目錄 /data/www/wwwroot(虛擬主機在這個目錄下) Apache 虛擬主機日誌根目錄 /data/www/logs Apache 運行賬戶 www:www 創建兩個虛擬主機 test.com linux.com 所有的配置的文件修改,都做備份,備份的名字為 文件名.save 下面的實驗是用vmware station 6 創建一個 redhat AS5的vm,安裝centos5.2,安裝的時候,選擇安裝語言是英文,採用文本方式來安裝,選擇最小化的安裝。 yum的更新,採用本地光碟的方式,這樣比較快捷。 我的機器基本設置 IP:192.168.1.200/255.255.255.0 網關:192.16.1.1 DNS:192.168.1.1 hostname:ns1 二:系統基本設置 我已經把所有需要配置的內容,做一個一個腳本,只需要運行一次就可以。 cd /usr/local/src vi /usr/local/src/init.sh ##################### #Diabe IPV6 cp /etc/modprobe.conf /etc/modprobe.conf.save echo 「alias net-pf-10 off」 >> /etc/modprobe.conf echo 「alias ipv6 off」 >> /etc/modprobe.conf #SSH cp /etc/ssh/sshd_config /etc/ssh/sshd_config.save sed -i 『/#PermitRootLogin/s/#PermitRootLogin/PermitRootLogin/』 /etc/ssh/sshd_config sed -i -e 『74 s/^/#/』 -i -e 『76 s/^/#/』 /etc/ssh/sshd_config sed -i 「s/#UseDNS yes/UseDNS no/」 /etc/ssh/sshd_config sed -i -e 『44 s/^/#/』 -i -e 『48 s/^/#/』 /etc/ssh/sshd_config /etc/init.d/sshd restart #停止 the 「beep」 cp /etc/inputrc /etc/inputrc.save sed -i 『/#set bell-style none/s/#set bell-style none/set bell-style none/』 /etc/inputrc #關閉SElinux cp /etc/sysconfig/selinux /etc/sysconfig/selinux.save sed -i 『/SELINUX=enforcing/s/SELINUX=enforcing/SELINUX=disabled/』 /etc/sysconfig/selinux #載入光碟機 mkdir /mnt/cdrom mount /dev/cdrom /mnt/cdrom echo 「mount /dev/cdrom /mnt/cdrom」 >> /etc/rc.local #設置yum使用本地光碟 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.save mv /etc/yum.repos.d/CentOS-Media.repo /etc/yum.repos.d/CentOS-Media.repo.save echo 「[DVDISO]」 >> /etc/yum.repos.d/dvdiso.repo echo 「name=DVD ISO」 >> /etc/yum.repos.d/dvdiso.repo echo 「baseurl=file:///mnt/cdrom/」 >> /etc/yum.repos.d/dvdiso.repo echo 「enabled=1″ >> /etc/yum.repos.d/dvdiso.repo echo 「gpgcheck=0″ >> /etc/yum.repos.d/dvdiso.repo #vim設置 yum -y install vim-enhanced mv /bin/vi /bin/vi.save ln -s /usr/bin/vim /bin/vi cp /etc/vimrc /etc/vimrc.save sed -i 「39 s/^/ set number \n filetype on\n set history=1000\n syntax on\n set tabstop=4\n set showmatch\n set vb t_vb=\n set mouse=a\n set ignorecase\n set autowrite\n /」 /etc/vimrc #時間的設置 yum -y install ntp ntpdate 210.72.145.44 && clock -w #安裝常用軟體 yum -y install wget unzip #停止沒有必要的服務 chkconfig ?list |grep 3:on |awk 『{print $1}』 |egrep -v 』sshd|network|syslog』 |xargs -i{} chkconfig ?level 3 {} off chkconfig ?list | grep 3:on | cut -f1 #重新啟動 init 6 #################### sh init.sh 三:下載軟體 cd /usr/local/src vi list http://download.filehat.com/apache/httpd/httpd-2.2.8.tar.gz http://opensource.nchc.org.tw/COSA/CNS4/cronolog-1.6.2.tar.gz http://www.libgd.org/releases/gd-2.0.35.tar.bz2 http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz http://mirror.optus.net/sourcefo ... mcrypt-2.5.8.tar.gz http://jaist.dl.sourceforge.net/ ... mcrypt-2.6.7.tar.gz http://www.openssl.org/source/openssl-0.9.8h.tar.gz http://openbsd.md5.com.ar/pub/Op ... penssh-5.0p1.tar.gz http://mysql.byungsoo.net/Downlo ... ysql-5.0.51b.tar.gz http://cn2.php.net/get/php-5.2.6.tar.bz2/from/this/mirror http://downloads.phpchina.com/ze ... glibc23-i386.tar.gz ftp://ftp.cac.washington.edu/mail/imap.tar.Z http://puzzle.dl.sourceforge.net ... s-utf-8-only.tar.gz http://dl.sugarforge.org/sugarcr ... 0/SugarCE-5.1.0.zip http://mirror.optus.net/sourceforge/m/mh/mhash/mhash-0.9.9.tar.gz wget -i list 四:安裝必須的軟體 採用yum的方式安裝 yum -y install gcc make patch gcc-c++ gcc-g77 flex bison autoconf automake \ libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel libtiff-devel fontconfig-devel libXpm-devel gettext-devel pam-devel pcre-devel libtool libtool-ltdl 五:編譯安裝軟體 下面的內容,其實你可以複製到一個文本,比如 install.sh 運行這個腳本,我已經測試過了,整整運行了快1個小時,估計是我在vm上跑道原因。前提是你下載的軟體和我是一樣的,也就是軟體都是通過上面的下載的。 cd /usr/local/src vi install.sh ############################################### #安裝openssl cd /usr/local/src tar zxvf openssl-0.9.8h.tar.gz cd openssl-0.9.8h ./config shared zlib make make test make install mv /usr/bin/openssl /usr/bin/openssl.save mv /usr/include/openssl /usr/include/openssl.save mv /usr/lib/libssl.so /usr/lib/libssl.so.save ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl ln -s /usr/local/ssl/include/openssl /usr/include/openssl ln -sv /usr/local/ssl/lib/libssl.so.0.9.8 /usr/lib/libssl.so cd .. #配置庫文件搜索路徑 echo 「/usr/local/ssl/lib」 >> /etc/ld.so.conf ldconfig -v #檢測安裝結果 openssl version #安裝openssh tar xvf openssh-5.0p1.tar.gz cd openssh-5.0p1 ./configure \ 」?prefix=/usr」 \ 」?with-pam」 \ 」?with-zlib」 \ 」?sysconfdir=/etc/ssh」 \ 」?with-ssl-dir=/usr/local/ssl」 \ 」?with-md5-passwords」 make make install cd .. service sshd restart ssh -v #安裝GD tar jxvf gd-2.0.35.tar.bz2 cd gd-2.0.35 aclocal ./configure ?prefix=/usr/local/gd2 make && make install cd .. #安裝 libmcrypt tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8/ ./configure make make install /sbin/ldconfig cd libltdl/ ./configure ?enable-ltdl-install make make install cd ../../ cp /usr/local/lib/libmcrypt.* /usr/lib #安裝libiconv tar zxvf libiconv-1.12.tar.gz cd libiconv-1.12/ ./configure ?prefix=/usr/local make make install cd ../ ln -s /usr/local/lib/libiconv.so.2 /usr/lib/ #安裝mhash tar zxvf mhash-0.9.9.tar.gz cd mhash-0.9.9/ ./configure make make install cd ../ ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2 #安裝mcrypt tar zxvf mcrypt-2.6.7.tar.gz cd mcrypt-2.6.7/ ./configure make make install cd ../ #安裝cronolog tar xvf cronolog-1.6.2.tar.gz cd cronolog-1.6.2 ./configure ?prefix=/usr/local/cronolog make && make install cd .. #安裝imap tar zxf imap.tar.Z cd imap-2007b make lr5 PASSWDTYPE=std SSLTYPE=unix.nopwd IP6=4 echo 「set disable-plaintext nil」 > /etc/c-client.cf mkdir /usr/local/imap-2007b mkdir /usr/local/imap-2007b/include/ mkdir /usr/local/imap-2007b/lib/ chmod -R 077 /usr/local/imap-2007b rm -rf /usr/local/imap-2007b/include/* rm -rf /usr/local/imap-2007b/lib/* rm -rf /usr/sbin/imapd cp imapd/imapd /usr/sbin/ cp c-client/*.h /usr/local/imap-2007b/include/ cp c-client/*.c /usr/local/imap-2007b/lib/ cp c-client/c-client.a /usr/local/imap-2007b/lib/libc-client.a cd .. #安裝MYSQL tar zxvf mysql-5.0.51b.tar.gz cd mysql-5.0.51b ./configure \ 「?prefix=/usr/local/mysql」 \ 「?localstatedir=/data/mysql/data」 \ 「?with-comment=Source」 \ 「?with-server-suffix=-test.com」 \ 「?with-mysqld-user=mysql」 \ 「?without-debug」 \ 「?with-big-tables」 \ 「?with-charset=gbk」 \ 「?with-collation=gbk_chinese_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」 \ 「?without-isam」 \ 「?without-innodb」 \ 「?without-ndb-debug」 make && make install useradd mysql -d /data/mysql -s /sbin/nologin /usr/local/mysql/bin/mysql_install_db ?user=mysql cd /usr/local/mysql chown -R root:mysql . chown -R mysql /data/mysql/data cp share/mysql/my-huge.cnf /etc/my.cnf cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld chmod 755 /etc/rc.d/init.d/mysqld chkconfig ?add mysqld /etc/rc.d/init.d/mysqld start cd /usr/local/mysql/bin for i in *; do ln -s /usr/local/mysql/bin/$i /usr/bin/$i; done cd /usr/local/src mysqladmin -u root password chenshake #安裝Apache tar zxvf httpd-2.2.8.tar.gz cd httpd-2.2.8 ./configure \ 「?prefix=/usr/local/apache2″ \ 「?with-included-apr」 \ 「?enable-so」 \ 「?enable-deflate=shared」 \ 「?enable-expires=shared」 \ 「?enable-rewrite=shared」 \ 「?enable-static-support」 \ 「?disable-userdir」 make make install cd .. #安裝PHP tar jxvf php-5.2.6.tar.bz2 cd php-5.2.6 ./configure \ 「?prefix=/usr/local/php」 \ 「?with-apxs2=/usr/local/apache2/bin/apxs」 \ 「?with-config-file-path=/usr/local/php/etc」 \ 「?with-mysql=/usr/local/mysql」 \ 「?with-gd=/usr/local/gd2″ \ 「?with-libxml-dir=/usr」 \ 「?with-jpeg-dir」 \ 「?with-png-dir」 \ 「?with-freetype-dir」 \ 「?with-zlib 」 \ ?with-iconv-dir=/usr/local \ 「?with-openssl=/usr/local/ssl」 \ 「?with-curl 」 \ 「?with-curlwrappers 」 \ 「?with-mcrypt」 \ 「?with-imap=/usr/local/imap-2007b」 \ 「?with-kerberos」 \ 「?with-bz2″ \ 「?enable-soap」 \ 「?enable-gd-native-ttf」 \ 「?enable-ftp」 \ 「?enable-mbstring」 \ 「?enable-exif」 \ 「?disable-ipv6″ \ 「?disable-cgi」 \ 「?disable-cli」 make make install mkdir /usr/local/php/etc cp php.ini-dist /usr/local/php/etc/php.ini cd .. #安裝Zend Optimizer (安裝Zend Optimizer過程的最後不要選擇重啟Apache。) tar xzvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz cd ZendOptimizer-3.3.3-linux-glibc23-i386 ./install.sh ########################################################################## sh install.sh 腳本到這裡為止,因為zend的設置,我沒法自動完成,只能你手動設置,如果誰知道怎麼做,麻煩指導指導,注意php.ini 的位置 /usr/local/php/etc/ #設置session的存放位置和修改php上次文件的大小,最大文件25m cp /usr/local/Zend/etc/php.ini /usr/local/Zend/etc/php.ini.save sed -i -e 『991 s/;//』 /usr/local/Zend/etc/php.ini sed -i 』s/post_max_size = 8M/ post_max_size = 30M/g』 /usr/local/Zend/etc/php.ini sed -i 』s/upload_max_filesize = 2M/ upload_max_filesize = 25M/g』 /usr/local/Zend/etc/php.ini cd /usr/local/src 六:配置apache PHP 創建apache的啟動腳本,apache編譯包裡帶的那個啟動腳本,有一個缺點,啟動和停止沒有任何提示,所以就用下面這個,比較方便。 vi /etc/init.d/httpd ################################### #!/bin/bash # # Startup script for the Apache Web Server # # chkconfig: - 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: httpd # pidfile: /usr/local/apache2/logs/httpd.pid # config: /usr/local/apache2/conf/httpd.conf # Source function library. . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/httpd ]; then . /etc/sysconfig/httpd fi # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS=」" # Path to the apachectl script, server binary, and short-form for messages. apachectl=/usr/local/apache2/bin/apachectl httpd=/usr/local/apache2/bin/httpd pid=/usr/local/apache2/logs/httpd.pid prog=httpd RETVAL=0 # The semantics of these two functions differ from the way apachectl does # things — attempting to start while running is a failure, and shutdown # when not running is also a failure. So we just do it the way init scripts # are expected to behave here. start() { echo -n $」Starting $prog: 「 daemon $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd return $RETVAL } stop() { echo -n $」Stopping $prog: 「 killproc $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid } reload() { echo -n $」Reloading $prog: 「 killproc $httpd -HUP RETVAL=$? echo } # See how we were called. case 「$1″ in start) start ;; stop) stop ;; status) status $httpd RETVAL=$? ;; restart) stop start ;; condrestart) if [ -f $pid ] ; then stop start fi ;; reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $」Usage: $prog {start|stop|restart|condrestart|reload|status」 echo $」|fullstatus|graceful|help|configtest}」 exit 1 esac exit $RETVAL ########################### 設置可運行和開機啟動 chmod +x /etc/rc.d/init.d/httpd chkconfig ?add httpd chkconfig ?level 3 httpd on 配置apache groupadd www -g 48 useradd -u 48 -g www www mkdir -p /data/www/wwwroot/linux.com mkdir -p /data/www/wwwroot/test.com mkdir -p /data/logs chmod +w /data/www/wwwroot chown -R www:www /data/www/wwwroot cp /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf.save 編輯httpd.conf sed -i -e 『121 s/^/#/』 -i -e 『122 s/^/#/』 /usr/local/apache2/conf/httpd.conf sed -i -e 「s/User daemon/User www/」 -i -e 「s/Group daemon/Group www/」 /usr/local/apache2/conf/httpd.conf sed -i 』s/DirectoryIndex index.html/ DirectoryIndex index.php index.html index.htm/g』 /usr/local/apache2/conf/httpd.conf sed -i -e 『101 s/^#//g』 -i -e 『374 s/^#//g』 -i -e 『389 s/^#//g』 -i -e 『392 s/^#//g』 -i -e 『401 s/^#//g』 /usr/local/apache2/conf/httpd.conf sed -i 「58 s/^/AddType application\/x-httpd-php .php/」 /usr/local/apache2/conf/httpd.conf 編輯php.ini cp /usr/local/php/etc/php.ini /usr/local/php/etc/php.ini.save sed -i 『205 s#;open_basedir =#open_basedir = /data/www/wwwroot:/tmp#g』 /usr/local/php/etc/php.ini sed -i 『/expose_php/s/On/Off/』 /usr/local/php/etc/php.ini sed -i 『/display_errors/s/On/Off/』 /usr/local/php/etc/php.ini 配置虛擬主機 備份相關配置文件 mv /usr/local/apache2/conf/extra/httpd-vhosts.conf /usr/local/apache2/conf/extra/httpd-vhosts.conf.save mv /usr/local/apache2/conf/extra/httpd-default.conf /usr/local/apache2/conf/extra/httpd-default.conf.save mv /usr/local/apache2/conf/extra/httpd-mpm.conf /usr/local/apache2/conf/extra/httpd-mpm.conf.save 創建3個apache相關的文件 vi /usr/local/apache2/conf/extra/httpd-vhosts.conf NameVirtualHost *:80 ServerAdmin shake.chen@gmail.com DocumentRoot 「/data/www/wwwroot/test.com」 ServerName test.com ServerAlias bbs.test.com ErrorLog 「logs/test.com-error_log」 CustomLog 「|/usr/local/cronolog/sbin/cronolog /data/logs/access_www.test.com.%Y%m%d」 combined ServerAdmin shake.chen@gmail.com DocumentRoot 「/data/www/wwwroot/linux.com」 ServerName linux.com ServerAlias bbs.linux.com ErrorLog 「logs/linux.com-error_log」 CustomLog 「|/usr/local/cronolog/sbin/cronolog /data/logs/access_www.linux.com.%Y%m%d」 combined vi /usr/local/apache2/conf/extra/httpd-default.conf Timeout 15 KeepAlive Off MaxKeepAliveRequests 50 KeepAliveTimeout 5 UseCanonicalName Off AccessFileName .htaccess ServerTokens Prod ServerSignature Off HostnameLookups Off vi /usr/local/apache2/conf/extra/httpd-mpm.conf ServerLimit 2000 StartServers 10 MinSpareServers 10 MaxSpareServers 15 MaxClients 2000 MaxRequestsPerChild 10000 七:測試 修改本地hosts文件 192.168.1.200 www.test.com 啟動Apache service httpd start 複製代碼 測試php cd /data/www/wwwroot/test.com vi info.php phpinfo() ?> 這個時候 http://192.168.1.200/info.php 或者 http://www.test.com/info.php 就可以看到php的信息。 安裝phpadmin cd /usr/local/src tar zxvf phpMyAdmin-2.11.8.1-all-languages-utf-8-only.tar.gz cp -rf phpMyAdmin-2.11.8.1-all-languages-utf-8-only /data/www/wwwroot/test.com/phpmyadmin cd /data/www/wwwroot/test.com/phpmyadmin cp config.sample.inc.php config.inc.php sed -i -e 「/^\$cfg\['blowfish_secret'\]/{ s@」;@』88888888888888888′;@; }」 config.inc.php 這個時候,你就可以通過 http://192.168.1.200/phpmyadmin 或者 http://www.test.com/phpmyadmin來進行資料庫管理, 我上面已經給mysql設置的密碼。 user:root password:chenshake 安裝sugarcrm sugarcrm的郵件模塊需要用到imap,ssl,所以我編譯的時候,需要吧imap,curl模塊編譯進去. cd /usr/local/src unzip SugarCE-5.1.0.zip mv SugarCE-Full-5.1.0/ /data/www/wwwroot/test.com/sugarcrm chmod -R 777 /data/www/wwwroot/test.com/sugarcrm/
[火星人
]
高手來~Centos5.2配置LAMP與Centos5.3配置LAMP 已經有481 次圍觀
本文地址: http://coctec.com/docs/linux/show-post-160602.html