CentOS 6.2系统安装和基本软件环境配置
<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><strong><span style="color:#ff0000">一、安装CentOS6.2系统</span></strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><strong>1、选择Desktop进行安装</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "> 注:如果修改了主机名,则需要在/etc/hosts文件中增加设置的主机名</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><strong>2、ssh安全设置(配置文件:/etc/ssh/sshd_config):</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
1)更改默认22端口:去掉 Port的注释,改成如:22123</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
2)禁止root账号登录:去掉PermitRootLogin yes注释,改成:PermitRootLogin no</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
3)新增SSH登录用户,登录成功后再su到root:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode22" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# useradd xiaoma<br/>
# passwd xiaoma </div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
然后修改ssh配置文件,最后加入:AllowUsers xiaoma</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
4)重启SSH服务:service sshd restart</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
5)更改防火墙配置,允许22123端口,加入:-A INPUT -m state –state NEW -m tcp -p tcp –dport 22123 -j ACCEPT,并重启防火墙生效:service iptables restart<br/><br/><br/><strong>二、软件环境配置</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
1、安装编译环境:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode23" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# yum install gcc gcc-c++</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
注:代理上网,命令行:export http_proxy=http://ip:port</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
2、安装一些必备的库</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode24" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# yum install ncurses-devel zlib-devel libjpeg* libpng* freetype*</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
注:ncurses-devel – 编译安装mysql5.5时需要<br/>
zlib-devel – 编译安装httpd需要<br/>
libjpeg*、libpng*、freetype* – 编译安装php需要</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
3、安装clamAV杀毒软件</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode25" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# tar xzf clamav-0.97.4.tar.gz<br/>
# cd clamav-0.97.4<br/>
# ./configure --prefix=/usr/local/clamav --disable-clamav<br/>
# make<br/>
# make install<br/><br/>
# groupadd clamav<br/>
# useradd -g clamav clamav<br/>
# chown -R clamav.clamav /usr/local/clamav</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
操作示例:<br/>
1)更新病毒库:bin/freshclam(需要修改etc/freshclam.conf文件把Example行注释掉)<br/>
2)扫描指定的目录:bin/clamscan –bell -i -r /usr/local</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
4、安装JDK</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode26" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# chmod +x jdk-6u33-linux-i586.bin<br/>
# ./jdk-6u33-linux-i586.bin<br/>
# mv jdk1.6.0_33/ /usr/local</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
设置JDK环境变量,/etc/profile文件中最后加入如下配置:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode27" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
JAVA_HOME=/usr/local/jdk1.6.0_33<br/>
export JAVA_HOME<br/>
export PATH=/usr/local/mysql5/bin:$JAVA_HOME/bin:$PATH</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
然后更新环境变量使之生效:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode28" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# source /etc/profile </div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
查看安装的java版本:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode29" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# java -version</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
5、安装Mysql5.5(mysql5.5需要cmake编译,需要先安装cmake)</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode30" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# tar xzf cmake-2.8.7.tar.gz<br/>
# cd cmake-2.8.7<br/>
# ./configure<br/>
# make && make install<br/><br/>
# mkdir -p /usr/local/mysql5<br/>
# groupadd mysql<br/>
# useradd -g mysql mysql<br/>
# chown mysql.mysql -R /usr/local/mysql5<br/><br/>
# tar xzf mysql-5.5.19.tar.gz<br/>
# cd mysql-5.5.19/<br/>
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5 -DMYSQL_UNIX_ADDR=/usr/local/mysql5/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql5/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306<br/>
# make<br/>
# make install</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
配置Mysql,进行如下操作:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode31" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# cp support-files/my-medium.cnf /etc/my.cnf<br/>
# chmod 755 scripts/mysql_install_db<br/>
# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5 --datadir=/usr/local/mysql5/data<br/><br/>
# cp support-files/mysql.server /etc/init.d/mysql<br/>
# chmod 755 /etc/init.d/mysql<br/>
# chkconfig mysql on</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
启动mysql并设置root账号密码:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode32" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# /etc/init.d/mysql start 或 service mysql start<br/>
# /usr/local/mysql5/bin/mysqladmin -uroot password 'root'</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
加入环境变量,在/etc/profile文件中最后加入:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode33" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
export PATH=/usr/local/mysql5/bin:$PATH </div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
修改默认的mysql最大连接数(默认只有151),打开/etc/my.cnf文件,在的下面加入:max_connections=1000,然后重启mysql即可生效,查看最大连接数:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode34" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
mysql>show VARIABLES LIKE '%conn%';</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
6、安装httpd</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode35" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# tar xzf httpd-2.2.21.tar.gz<br/>
# cd httpd-2.2.21/<br/>
# cd srclib/apr<br/>
# ./configure --prefix=/usr/local/apr<br/>
# make<br/>
# make install<br/><br/>
# cd ../apr-util<br/>
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr<br/>
# make<br/>
# make install<br/><br/>
# cd ../..<br/>
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-dav --enable-proxy --enable-proxy-ajp<br/>
# make<br/>
# make install</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
启动httpd并访问http://ip进行测试(注意iptables需要打开80端口):</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode36" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# /usr/local/apache2/bin/apachectl start </div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
如果需要禁止对某个目录的访问,可以在该目录下新建.htaccess文件,并输入如下内容:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode37" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
order allow,deny<br/>
deny from all</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
7、安装php</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode38" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# tar xzf libxml2-2.7.5.tar.gz<br/>
# cd libxml2-2.7.5<br/>
# ./configure --prefix=/usr/local/libxml2<br/>
# make<br/>
# make install<br/><br/>
# cd ..<br/>
# rpm -qa php<br/>
# rpm -e --nodeps --allmatches php-5.1.6-27.el5<br/>
# tar xzf php-5.3.1.tar.gz<br/>
# cd php-5.3.1<br/>
# ./configure --prefix=/usr/local/php5 --with-libxml-dir=/usr/local/libxml2/ --with-mysql=/usr/local/mysql5/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mbstring --enable-mbstring=all --with-gd<br/>
# make<br/>
# make install<br/>
# cp php.ini-production /usr/local/php5/lib/php.ini</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
修改httpd.conf文件:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
1)在AddType application/x-gzip .gz .tgz之后加一行:AddType application/x-httpd-php .php<br/>
2)在DirectoryIndex index.html后加入index.php</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
重启httpd后即可使php生效!</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
8、安装Tomcat7</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode39" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# unzip -q apache-tomcat-7.0.23.zip<br/>
# mv apache-tomcat-7.0.23 tomcat-7 </div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
配置tomcat的虚拟主机,打开conf/server.xml配置文件,加入如下段(多个则加入多个如下段即可):</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode40" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/><Host name="www.jb51.net" appBase="webapps"<br/>
unpackWARs="true" autoDeploy="true"><br/>chinapis.com</alias><br/><context path="" docbase="/webapps/www.jb51.net"><br/></context></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
配置完tomcat后,还需要配置apache的虚拟主机文件(conf/extra/httpd-vhosts.conf):</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode41" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/><virtualhost :80=""><br/>
DocumentRoot "/kington/webapps/chinapis"<br/>
ServerName www.jb51.net<br/>
ServerAlias jb51.net<br/><br/>
ErrorLog "| /usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/jb51.net_%Y-%m-%d_error_log 86400 480"<br/>
CustomLog "| /usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/jb51.net_%Y-%m-%d_access_log 86400 480" common<br/><br/>
ProxyPass /images/ !<br/>
ProxyPass /styles/ !<br/><br/>
ProxyPreserveHost On<br/>
ProxyPass / ajp://localhost:8009/<br/>
ProxyPassReverse / ajp://localhost:8009/<br/></virtualhost></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
上述配置中的说明如下:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
1)ErrorLog和CustomLog配置了日志文件的轮询时间(86400表示秒是一天,480是时区的偏移)</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><strong>三、常见问题</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
1、编译安装php时遇到:configure: error: libpng.(a|so) not found,首先安装各个依赖组件(libjpeg、libpng、freetype),然后做如下处理:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode42" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# ln -s /usr/lib64/libjpeg.so /usr/lib/<br/>
# ln -s /usr/lib64/libpng.so /usr/lib/</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
2、解压bin格式的jdk时候报错:/lib/ld-linux.so.2: bad ELF interpreter,需要安装一些缺少的文件:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">
</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "></div><div class="msgborder" id="phpcode43" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
# yum install ld-linux.so.2</div>
頁:
[1]