-----------------------------安裝組件下載--------
[b]1.http組件[/b]
http://down1.chinaunix.net/distfiles/httpd-2.2.4.tar.bz2http://down1.chinaunix.net/distfiles/apr-1.4.6.tar.bz2http://down1.chinaunix.net/distfiles/apr-util-1.4.1.tar.bz2[b]2.MySQL5.5.35[/b]
http://down1.chinaunix.net/distfiles/mysql-5.5.20.tar.gz[b]3.php-5.5.7(目前最新[/b]
[b]版)[/b]
http://mirrors.sohu.com/php/php-5.5.7.tar.gz[b]4.cmake(MySQL編譯工具)[/b]
http://down1.chinaunix.net/distfiles/cmake-2.8.0-rc4.tar.gz[b]5.libmcrypt(PHPlibmcrypt模塊)[/b]
http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
下載完成後,傳送到opt目錄下,當然也可以直接在opt目錄下使用wget下載;---------------安裝mysql (源碼三步安裝)-------
# cd /mnt/
# tar zxvf mysql-5.0.84.tar.gz# cd mysql-5.0.84# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charset=all --enable-thread-safe-client --enable-local-infile --with-low-memory
說明:安裝到=/usr/local/mysql 下,語言用utf8通到錯誤 :configure: error: no acceptable C compiler found in $PATH說明沒安gcc, 現在安:查看系統是否安裝了gcc和安裝程序的版本號:
gcc -v
c++ -v
g++ -v
如果沒有就用 以下命令安裝
#yum install gcc
#yum install gcc-c++
#yum install gcc-gfortran再次:# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charset=all --enable-thread-safe-client --enable-local-infile --with-low-memory還是出錯:checking for termcap functions library... configure: error: No curses/termcap library found
說明要安ncurses#yum install ncurses-devel提示安裝N個軟件,略, 按"y", 完成再次:# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charset=all --enable-thread-safe-client --enable-local-infile --with-low-memory出現:Thank you for choosing MySQL! 說明mysql安裝的第一步成功------------
# make && make install 如果 你的gcc-c++是在configure後安裝的,再重新configure一下,可以會以下錯誤: error: redeclaration of C++ built-in type ‘bool’ 慢長的等待,安好了建用戶,用戶組 # groupadd mysql
# adduser -g mysql mysql# cp support-files/my-medium.cnf /etc/my.cnf本例中my-medium.cnf文件在這裡: /mnt/mysql-5.0.84/support-files/my-medium.cnf我們的mysql安裝在 /usr/local/mysql/ 裡# chown -R mysql.mysql /usr/local/mysql/# /usr/local/mysql/bin/mysql_install_db --user=mysql# chown -R root.root /usr/local/mysql/
# chown -R mysql.mysql /usr/local/mysql/var/啟動一下 ,後面加一個&表示後台運行# /usr/local/mysql/bin/mysqld_safe --user=mysql &# netstat -ant 看到3306端品號,說明已啟動加入到開機啟動中# cp support-files/mysql.server /etc/rc.d/init.d/mysqld給權限
# chmod 755 /etc/rc.d/init.d/mysqld把mysqld服務加入啟動中# chkconfig --add mysqld
運行級別# chkconfig --level 345 mysqld on
設置密碼# /usr/local/mysql/bin/mysqladmin -u root password "****"
進入mysql# /usr/local/mysql/bin/mysql -uroot -p
輸入密碼,就進入了看有哪些庫 :show databases;退出:quit配置mysql 庫文件的搜索路徑:# echo "/usr/local/mysql/lib/mysql/" >>/etc.ld.so.conf# ldconfig 生效
# ldconfig -v 輸出一下添加mysql到系統的環境變量中# echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile# source /etc/profile 生效完成------------------------安裝 apr-----------------
# cd /mnt# tar zxvf apr-1.3.3.tar.gz# cd apr-1.3.3# ./configure --prefix=/usr/local/apr# make# make install# tar zxvf apr-util-1.3.4.tar.gz# cd apr-util-1.3.4
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make && make install------------------------安裝apache------------
# cd /mnt# tar zxvf httpd-2.2.13.tar.gz# cd httpd-2.2.13
# ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-proxy --enable-proxy-ajp --enable-proxy-balancer --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util 開了rewrite ,proxy模塊# make && make install啟動apache# /usr/local/apache/bin/apachectl start看一下端口, 有沒有80端口# netstat -ant
也可以看一下進程# ps -ef | grep httpd下一步,把apache加入開機自啟動
# cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
# vi /etc/rc.d/init.d/httpd
在第二行新加兩行,內容如下:
# chkconfig: 2345 10 90
# description: Activates/Deactiates Apache Web Server保存退出.# chkconfig --add httpd 加入自啟動
# chkconfig --level 345 httpd on 設置運行級別重啟apache:# /usr/local/apache/bin/apachectl restart---------------------- 安裝tomcat --------------
# cp apache-tomcat-6.0.20.tar.gz /usr/local/
# cd /usr/local/
# tar zxvf apache-tomcat-6.0.20.tar.gz
# cd apache-tomcat-6.0.20# rm -fr apache-tomcat-6.0.20.tar.gz# mv apache-tomcat-6.0.20/ tomcat# vi /usr/local/tomcat/bin/catalina.sh在最後加入一行 JAVA_HOME=/usr/java/jdk1.6.0_16
保存退出啟動:# /usr/local/tomcat/bin/startup.sh加入開機自啟動# vi /etc/rc.d/rc.local在最後加入export JDK_HOME=/usr/java/jdk1.6.0_16
export JAVA_HOME=/usr/java/jdk1.6.0_16
/usr/local/tomcat/bin/startup.sh---------------------安裝php-------------------
#cd /mnt/# tar zxvf php-5.3.0.tar.gz
# cd php-5.3.0
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php出錯 :configure: error: xml2-config not found. Please check your libxml2 installation.要安裝下面兩個東東:# yum install libxml2
# yum install libxml2-devel再次 ./configure .............. 成功#make && make install# cp php.ini-dist /usr/local/php/php.ini增加apache對 php的支持,修改apache的配置文件# vi /usr/local/apache/conf/httpd.conf搜索如下內容,LoadModule php5_module modules/libphp5.so插入一行:AddType application/x-httpd-php .php再搜索
DirectoryIndex原來是:<IfModule dir_module>
DirectoryIndex index.html </IfModule>改為:<IfModule dir_module>
DirectoryIndex index.html index.php index.jsp
</IfModule>
保存退出在/usr/local/apache/htdocs/下建一個php文件,准備測試.測試前要先重啟apache:# service httpd restart出錯: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 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
# service httpd restart
# setenforce 1ok, php頁面可以訪問了------------------------------------------------------apache ,默認會把文件夾下的文件結構顯示出來, 我們禁止這個功能# vi /usr/local/apache/conf/httpd.conf找到:Options Indexes FollowSymLinks一行, 並在前面加#, 注釋他---------------------------------------------------------------------- 整合apache與 tomcat------
# vi /usr/local/apache/conf/httpd.conf在最後加入下面兩行:ProxyPass / ajp://127.0.0.1:8009/ 注意最後有一個"/",千萬不能少
ProxyPassReverse / ajp://127.0.0.1:8009/ 注意最後有一個"/",千萬不能少浏覽器的地址欄中輸入IP , 就可看見tomcat的默認頁面了.------------------- 配置php程序----------------
我們在/usr/local/apache/htdocs/下建一個phpbbs文件夾,裡面放php程序.
# chmod -R 777 phpbbs/# vi /usr/local/apache/conf/httpd.conf注釋掉前面剛加的:#ProxyPass / ajp://127.0.0.1:8009/ 注意最後有一個"/",千萬不能少
#ProxyPassReverse / ajp://127.0.0.1:8009/打開(去掉前面的#)下面的 子配置文件:# Virtual hosts
Include conf/extra/httpd-vhosts.conf保存退出# vi /usr/local/apache/conf/extra/httpd-vhosts.conf
修改為如下:<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/phpbbs"
ServerName bbs.tgjia.com
ErrorLog "/usr/local/apache/logs/phpbbs-error_log"
CustomLog "/usr/local/apache/logs/phpbbs-access_log" common</VirtualHost>重啟apache.php程序要安裝在"/usr/local/apache/htdocs/phpbbs"下面.略.....用bbs.tgjia.com域名就可能訪問了---------------------配置JSP程序---------------
我們在/usr/local/apache/htdocs/下建一個jspbbs文件夾,裡面放jsp程序.# chmod -R 777 jspbbs/# vi /usr/local/apache/conf/extra/httpd-vhosts.conf加入如下虛擬主機的配置
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/jspbbs"
ServerName www.aaa.com
ErrorLog "/usr/local/apache/logs/jspbbs-error_log"
CustomLog "/usr/local/apache/logs/jspbbs-access_log" common
ProxyPass / ajp://127.0.0.1:8009/
ProxyPassReverse / ajp://127.0.0.1:8009/ 注意最後有一個"/",千萬不能少
</VirtualHost>保存退出,重啟apache--------------------php程序換目錄-------------
在/下建立 php,並開相應權限# mkdir /php# chmod -R 777 /php# vi /usr/local/apache/conf/extra/httpd-vhosts.conf
修改為如下:<VirtualHost *:80>
DocumentRoot "/php" 修改為新位置
ServerName bbs.tgjia.com
ErrorLog "/php/logs/phpbbs-error_log"
CustomLog "/phplogs/phpbbs-access_log" common
</VirtualHost>建立/php/logs ,並拷貝以下兩個原有的日志文件過來./usr/local/apache/logs/jspbbs-error_log/usr/local/apache/logs/jspbbs-access_log"# vi httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all 這樣就可以訪問"/usr/local/apache/htdocs/"以外的位置了
</Directory>重啟apache.本文出自 “北風之神—冥王” 博客,請務必保留此出處http://964993537.blog.51cto.com/9103906/1782167