java环境3-linux

系统ubuntu10,环境搭建包括:数据库mysql:5.1,Rsync:3.0.3-2,    Jdk:1.5.0_22,    Apache:2.0.64,    Resin:3.0.24,JMagick6
1,安装msyql
     1)    sudo apt-get install mysql-client-5.1 mysql-server-5.1
        设置密码root
        mysql配置文件:/etc/mysql/my.cnf
        初始化脚本:/etc/init.d/mysql
     2)mysql操作:
         启动:sudo service mysql start
         停止:sudo service mysql stop
         登录:mysql -uroot –p密码
     3)设置mysql登陆快捷方式
       sudo vim /etc/profile
       alias ml='/usr/bin/mysql -uroot -p密码'
       source /etc/profile
     
2,安装rsync
   1)sudo aptitude install rsync
      sudo vim /etc/rsyncd.conf
      max connections=0
            use chroot=false
            uid=root
            gid=root
            log file = /data/logs/rsyncd.log
            log format="%t [%p] %o %h [%a] %m (%u) %P %f %l"
           
            [html]
            path=/data/www/html/
            comment=html
            read only=false
            hosts allow=192.168.1.1

3,安装jdk(注意操作系统是32位还是64位,应选择不同的安装包)
    1)sudo cp jdk-1_5_0_22-linux-i586.bin  /usr/local/
       cd /usr/local/
       sudo chmod u+x jdk-1_5_0_22-linux-i586.bin
       sudo ./jdk-1_5_0_22-linux-i586.bin
       sudo rm -rf jdk-1_5_0_22-linux-i586.bin
       sudo mv /usr/local/jdk1.5.0_22 /usr/local/jdk
    2)设置环境变量
        JAVA_HOME=/usr/local/jdk
                PATH=$PATH:$JAVA_HOME/bin
                CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib
               
                export PATH JAVA_HOME CLASSPATH
        3)检查
            source /etc/profile
            java -version
           
---------------------------------------------------------------------------------------------------------------------------------

    查看gcc版本:sudo gcc --version

    检查程序包安装

    aptitude show build-essential

    安装gcc:

sudo apt-get install build-essential

   确认你已经安装了内核头文件包:

uname -r

    apt-get install linux-headers-'kernel version'

如果你遇到gcc版本错误,你需要安装编译你内核的gcc版本:

cat /proc/version

这会告诉你,你的内核是用什么版本的gcc编译的.

$ cat /proc/version

    Linux version 2.6.12-8-386 (buildd@rothera) (gcc version 3.4.5 20050809 (prerelease) (Debian 3.4.4-6ubuntu6)) #1 Tue Aug 30 22:41:30 BST 2005

    ls /usr/bin/gcc*

   

/usr/bin/gcc      /usr/bin/gcc-4.0  /usr/bin/gccbug   /usr/bin/gccbug-4.0
可以看到,我的核心是用gcc-3.4编译的,但我只装了gcc-4.0.如果你的也不同于/usr/bin/gcc*,你需要安装核心所用的版本.

apt-get install gcc-3.4

--------------------------------------------------------------------------------------------------------------------------------------


  4,安装apache 

1)cd /usr/local
        sudo tar -zxvf httpd-2.0.64.tar.gz
        cd httpd-2.0.64/
        //测试机用--enable-deflate选项出错(解决办法: sudo apt-get install zlib1g-dev ),sudo ./configure --prefix=/usr/local/apache --enable-deflate --enable-expires --enable-headers --enable-so --enable-rewrite --with-mpm=worker --enable-proxy
        sudo ./configure --prefix=/usr/local/apache --enable-expires --enable-headers --enable-so --enable-rewrite --with-mpm=worker --enable-proxy

        sudo make
        sudo make install
       
     2)运行
     修改http.conf 将ServerName 改为192.168.1.1

     启动:sudo /usr/local/apache/bin/httpd -f /usr/local/apache/conf/httpd.conf
     关闭:sudo kill -TERM `cat /usr/local/apache/logs/httpd.pid`

5,安装resin
备注:如果gcc是4.0或以上版本,安装resin3.0时,需要修改目录/usr/local/resin-3.0.24/modules/c/src/resin_os/下的
MakeFile的LD=/usr/bin/ld改为LD=/usr/bin/gcc,然后在make && make install

-------------------------------------------------------------------------------------------------------

/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h:

apt-get install g++-multilib

-------------------------------------------------------------------------------------------------------


sudo ./configure --prefix=/usr/local/resin --with-java-home=/usr/local/jdk --with-apache=/usr/local/apache --with-apxs=/usr/local/apache/bin/apxs
sudo make
sudo make install

64位情况(file /bin/ls 判断系统是多少位)
sudo ./configure --prefix=/usr/local/resin --with-java-home=/usr/local/jdk --with-apache=/usr/local/apache --with-apxs=/usr/local/apache/bin/apxs --enable-64bit
sudo make
sudo make install


启动:sudo /usr/local/resin/bin/httpd.sh start
停止:sudo /usr/local/resin/bin/httpd.sh stop
错误处理:

1,error: gnu/stubs-32.h: No such file or directory
解决:apt-get install g++-multilib


6,JMagick

sudo apt-get install libopenjpeg2
 sudo apt-get install libpng12-dev
 sudo apt-get install libjpeg62-dev


 1)安装ImageMagick

    tar xzvf ImageMagick-6.4.0-0.tar.gz
    cd ImageMagick-6.4.0
    sudo ./configure --prefix=/usr/local/ImageMagick6 --enable-shared --without-perl
    sudo make
    sudo make install

-----------------------------------------------------------------------------------------

Shared libraries  --enable-shared=yes           yes
Static libraries  --enable-static=yes           yes
Module support    --with-modules=yes            yes
GNU ld            --with-gnu-ld=yes             yes
Quantum depth     --with-quantum-depth=16       16
High Dynamic Range Imagery
                  --enable-hdri=no              no

Delegate Configuration:
BZLIB             --with-bzlib=yes              no
DJVU              --with-djvu=no                no
DPS               --with-dps=yes                no
FlashPIX          --with-fpx=yes                no
FontConfig        --with-fontconfig=no          no
FreeType          --with-freetype=yes           no
GhostPCL          None                          pcl6 (unknown)
GhostXPS          None                          gxps (unknown)
Ghostscript       None                          gs (unknown)
result_ghostscript_font_dir='none'
Ghostscript fonts --with-gs-font-dir=default
Ghostscript lib   --with-gslib=yes              no
Graphviz          --with-gvc=yes                no
JBIG              --with-jbig=yes               no
JPEG v1           --with-jpeg=yes               yes
JPEG-2000         --with-jp2=yes                no
LCMS              --with-lcms=yes               no
LQR               --with-lqr=no         no
Magick++          --with-magick-plus-plus=yes   yes
OpenEXR           --with-openexr=yes            no
PERL              --with-perl=no                no
PNG               --with-png=yes                yes
RSVG              --with-rsvg=no                no
TIFF              --with-tiff=yes               no
result_windows_font_dir='none'
Windows fonts     --with-windows-font-dir=
WMF               --with-wmf=yes                no
X11               --with-x=                     no
XML               --with-xml=no         no
ZLIB              --with-zlib=yes               yes

-----------------------------------------------------------------------------------------

2)

--------------------------------------------------------------------------------------

sudo ln -s /opt/jdk1.5.0_22/bin/java /usr/bin/java
sudo ln -s /opt/jdk1.5.0_22/bin/javac /usr/bin/javac
sudo ln -s /opt/jdk1.5.0_22/bin/jikes /usr/bin/jikes
sudo ln -s /opt/jdk1.5.0_22/bin/javah /usr/bin/javah
sudo ln -s /opt/jdk1.5.0_22/bin/jar /usr/bin/jar

--------------------------------------------------------------------------------------

sudo tar xzvf jmagick-6.4.0-src.tar.gz
        cd 6.4.0
        sudo ./configure --with-java-home=/usr/local/jdk --with-magick-home=/usr/local/ImageMagick6
        sudo make
        sudo make install
        # 拷贝libJMagick.so到resin
        sudo cp /usr/local/6.4.0/lib/libJMagick-6.4.0.so /usr/local/resin/libexec/

        或者需要这样处理(如果出现java.library.path中找不到jmagick的错误提示时)

ln -s /opt/6.4.0/lib/libJMagick-6.4.0.so /usr/local/resin/libexec/libJMagick.so

        如果出现这个错误:wrong ELF class: ELFCLASS64可能就是jvm跟操作系统不是同位数的,既是jvm和操作系统都要是32位,或者都是64位的


        # 拷贝magick-6.4.0.jarresin
        sudo cp /home/install/6.4.0/lib/jmagick-6.4.0.jar /usr/local/resin/lib/

7,apache参数优化

<IfModule worker.c>
ServerLimit         16
ThreadLimit         1024
StartServers        2
MaxClients          1024
MinSpareThreads     100
MaxSpareThreads     200
ThreadsPerChild     64
MaxRequestsPerChild  8000
</IfModule>

---------------------------------------------

如需使用ssi这种功能<!--#include virtual="/a.html"-->,则

 sudo ./httpd -l

1.确认mod_include.c的安装。

2.目录支持includes:
<Directory   />
        Options   None             //不支持includes
        AllowOverride   None
</Directory>

<Directory   "/data ">
        Options   Includes     //支持includes
        AllowOverride   None
</Directory>

3.告诉apache,解析指定的后缀文件

AddHandler   server-parsed   .htm

配置列子:

<Directory "/data">


    AllowOverride None
    Options IncludesNoExec FollowSymLinks
    Order allow,deny
    Allow from all
</Directory>

AddHandler server-parsed .html .htm

<VirtualHost 192.168.1.8>
AddDefaultCharset utf-8
Options Includes
ServerName xxx.com
DocumentRoot /data/www
DirectoryIndex index.html
</VirtualHost>

8,php编译安装

sudo ./configure --prefix=/opt/php --with-apxs2=/opt/apache/bin/apxs

9, apache配置php

# Example:^M
# LoadModule foo_module modules/mod_foo.so^M
#^M

LoadModule php5_module modules/libphp5.so

<IfModule mod_mime.c>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>

猜你喜欢

转载自michaelzqm.iteye.com/blog/1050671
今日推荐