标签:最新版
1.http组件
http://down1.chinaunix.net/distfiles/httpd-2.2.4.tar.bz2
http://down1.chinaunix.net/distfiles/apr-1.4.6.tar.bz2
http://down1.chinaunix.net/distfiles/apr-util-1.4.1.tar.bz2
2.MySQL5.5.35
http://down1.chinaunix.net/distfiles/mysql-5.5.20.tar.gz
3.php-5.5.7(目前最新版)
http://mirrors.sohu.com/php/php-5.5.7.tar.gz
4.cmake(MySQL编译工具)
http://down1.chinaunix.net/distfiles/cmake-2.8.0-rc4.tar.gz
5.libmcrypt(PHPlibmcrypt模块)
http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
下载完成后,传送到opt目录下,当然也可以直接在opt目录下使用wget下载;
# 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 生效
完成
# 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
# 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
# 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
#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 1
ok, php页面可以访问了
------------------------------------------------------
apache ,默认会把文件夹下的文件结构显示出来, 我们禁止这个功能
# vi /usr/local/apache/conf/httpd.conf
找到:
Options Indexes FollowSymLinks
一行, 并在前面加#, 注释他
----------------------------------------------------
# vi /usr/local/apache/conf/httpd.conf
在最后加入下面两行:
ProxyPass / ajp://127.0.0.1:8009/ 注意最后有一个"/",千万不能少
ProxyPassReverse / ajp://127.0.0.1:8009/ 注意最后有一个"/",千万不能少
浏览器的地址栏中输入IP , 就可看见tomcat的默认页面了.
我们在/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域名就可能访问了
我们在/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,并开相应权限
# 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
Centos tomcat+apache双web环境的整合编译
标签:最新版
原文地址:http://964993537.blog.51cto.com/9103906/1782167