漫長的編譯開始了,當然成功不會一蹴而就的,不出所料,錯誤出現了
ost C: adb <= system/core/adb/fdevent.c
host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
out/host/linux-x86/obj/STATIC_LIBRARIES/libzipfile_intermediates/libzipfile.a(centraldir.o): In function `memset':
/usr/include/bits/string3.h:82: warning: memset used with constant zero length parameter; this could be due to transposed parameters
true
Install: out/host/linux-x86/bin/adb
host C++: atree <= build/tools/atree/atree.cpp
host C++: atree <= build/tools/atree/files.cpp
host C++: atree <= build/tools/atree/fs.cpp
host Executable: atree (out/host/linux-x86/obj/EXECUTABLES/atree_intermediates/atree)
true
Install: out/host/linux-x86/bin/atree
host C++: bb2sym <= development/emulator/qtools/bb2sym.cpp
host C++: bb2sym <= development/emulator/qtools/trace_reader.cpp
development/emulator/qtools/trace_reader.cpp: In function ‘char* ExtractDexPathFromMmap(const char*)’:
development/emulator/qtools/trace_reader.cpp:1012: error: invalid conversion from ‘const char*’ to ‘char*’
development/emulator/qtools/trace_reader.cpp:1015: error: invalid conversion from ‘const char*’ to ‘char*’
make: *** [out/host/linux-x86/obj/EXECUTABLES/bb2sym_intermediates/trace_reader.o] 錯誤 1
繼續求教于,Google和百度吧,原來是gcc版本的問題
$gcc --version
gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
研究了一下發現問題主要出在Ubuntu10.4預置了gcc的版本是4.4,該版本編譯時對語法要求比較高,因此無法編譯源代碼,解決方法就是將gcc-4.4降級成gcc-4.3
具體操作:
sudo apt-get remove gcc-4.4(卸載gcc-4.4)
sudo apt-get remove g++-4.4( 卸載g++-4.4)
sudo apt-get install gcc-4.3(安裝gcc-4.3)sudo apt-get install g++-4.3(安裝g++-4.3)
安裝完4.3版本后,執行gcc --version后會發現版本仍然是4.4,因為gcc已經和4.4版本進行了鏈接,因此需要對gcc重新進行鏈接
具體操作:sudo ln -f /usr/bin/gcc-4.3 gcc
sudo ln -f/usr/bin/g++-4.3 g++
這樣就可以用4.3版本的gcc和g++將原來的覆蓋掉,重新進入android源碼目錄執行make就可以正常編譯~~
Q. I'm getting the following error while compiling application under CentOS / RHEL / Fedora Linux 64 bit edition:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h:
No such file or directory
How do I fix this error?
A. You need to install the glibc-devel package. It contains the object files necessary for developing programs which use the standard C libraries (which are used by nearly all programs). If you are developing programs which will use the standard C libraries, your system needs to have these standard object files available in order to create the executables.
Install glibc-devel if you are going to develop programs which will use the standard C libraries.
# apt-get install g++-multilib
1.tigertian@ubuntu:~/Developer/android_src$ apt-file search wxprec.h
wx2.4-headers: /usr/include/wx/wxprec.h
wx2.6-headers: /usr/include/wx-2.6/wx/wxprec.h
wx2.8-headers: /usr/include/wx-2.8/wx/wxprec.h
2.sudo apt-get install wx2.4
wx-config --cflags
前幾天下載了Android 2.3.1的源代碼并在Ubuntu 10.04(32位)上編譯通過。這篇文章簡要記錄了下載、編譯的過程。
關于搭建Android開發環境的文章已經有很多,本文只簡要介紹一下,做為備忘。
[ 編譯前的準備 ]
這一步安裝獲取源代碼以及編譯所需要的軟件,使用如下命令:
$ sudo aptitude install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev java-common unixodbc
另外,參考別人編譯Android 2.3的經驗,安裝了下列軟件包:
$ sudo apt-get install lib64z1-dev libc6-dev-amd64 g++-multilib lib64stdc++6
注意:32 bit Required Packages 為
git-core gnupg sun-java5-jdk flex bison gperf build-essential zip curl zlib1g-dev libsdl-dev libesd0-dev libwxgtk2.6-dev libncurses5-dev
而64 bit 下的 Required Packages 為 git-core gnupg flex bison gperf build-essential zip curl sun-java6-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z1-dev
deb http://archive.canonical.com/ubuntu lucid partner deb-src http://archive.canonical.com/ubuntu lucid partner
然后安裝Java 6 JDK:
$ sudo aptitude install sun-java6-jdk
接下來下載repo工具,這是Google提供的一個Python腳本,方便管理多個Git版本庫:
$ cd ~ $ mkdir bin $ curl http://android.git.kernel.org/repo >~/bin/repo $ chmod a+x ~/bin/repo
記得把repo加到你的路徑中,方便以后使用。編輯~/.bashrc,加入下面一行:
PATH=$PATH:~/bin export PATH
然后用命令. ~/.bashrc,以后就可以直接使用repo命令了。
接下來獲取Android 2.3.1的源代碼:
$ mkdir mydroid $ cd mydroid $ repo init -u git://android.git.kernel.org/platform/manifest.git -b android-2.3.1_r1 $ repo sync
[ 編譯Android ]
接下來開始編譯:
$ make -j`grep '^processor' /proc/cpuinfo | wc -l`
上面的命令中,-j參數告訴make啟動多個并行任務進行編譯,在支持多核的CPU上能加快編譯速度。如果你知道你CPU是幾核的,可以直接把這部分替換成-j2(雙核)。
我在編譯的過程中遇到下面的錯誤:
************************************************************
You are attempting to build on a 32-bit system.
Only 64-bit build environments are supported beyond froyo/2.2.
************************************************************
這是因為在Makefile中檢測了CPU的字長。我直接把build/core/main.mk中下面的話注釋掉:
#ifneq (64,$(findstring 64,$(build_arch))) #$(warning ************************************************************) #$(warning You are attempting to build on a 32-bit system.) #$(warning Only 64-bit build environments are supported beyond froyo/2.2.) #$(warning ************************************************************) #$(error stop) #endif
接下來又遇到下面的錯誤:
Docs droiddoc: out/target/common/docs/api-stubs
Could not load ‘clearsilver-jni’
java.library.path = out/host/linux-x86/lib
make: *** [out/target/common/docs/api-stubs-timestamp] Error 45
make: *** Waiting for unfinished jobs….
Could not load ‘clearsilver-jni’
java.library.path = out/host/linux-x86/lib
make: *** [out/target/common/docs/doc-comment-check-timestamp] Error 45
這是由于clearsilver在編譯時如果檢測到使用Java JDK 6,就使用64位編譯。要避開此錯誤,需要修改下面四個文件:
把這四個Makefile中的下列語句注掉即可:
# This forces a 64-bit build for Java6 # Comment by Easwy # LOCAL_CFLAGS += -m64 # LOCAL_LDFLAGS += -m64
然后在external/clearsilver目錄中執行一下make clean,然后回到項目根目錄,繼續make即可。
當編譯完成時,生成的image文件放在out/target/product/generic目錄中。
需要將gcc編譯環境設置為4.3版本,否則會出現const char* 到 char*無法轉換的問題。
http://www.aygfsteel.com/TiGERTiAN/archive/2011/01/22/343372.html
錯誤:
development/simulator/wrapsim/DevAudio.c:11: fatal error: alsa/asoundlib.h: No such file or directory
compilation terminated.
make: *** [out/debug/host/linux-x86/pr/sim/obj/SHARED_LIBRARIES/libwrapsim_intermediates/DevAudio.o] Error 1
解決辦法:
$ apt-file search alsa/asoundlib.h
libasound2-dev: /usr/include/alsa/asoundlib.h
So that’s it, asoundlib.h is in the package libasound2-dev.
apt-file需要使用apt-get install apt-file安裝一下。
in egl.cpp, at the line 554 : const Region copyBack(Region::subtract(oldDirtyRegion, dirtyRegion)); just remove the 'const' and retry.
查找資料,確定下面的修改步驟(-表示刪除行,+表示添加行):
1、修改build/core目錄下的main.mk文件,修改策略為:
ifeq ($(BUILD_OS),linux)
build_arch := $(shell uname -m)
-ifneq (64,$(findstring 64,$(build_arch)))
+ifneq (i686,$(findstring i686,$(build_arch)))
$(warning ************************************************************)
$(warning You are attempting to build on a 32-bit system.)
$(warning Only 64-bit build environments are supported beyond froyo/2.2.)
2、修改下列文件:
/external/clearsilver/cgi/Android.mk
/external/clearsilver/cs/Android.mk
/external/clearsilver/java-jni/Android.mk
/external/clearsilver/util/Android.mk
4個文件的修改策略相同,為:
# This forces a 64-bit build for Java6
-LOCAL_CFLAGS += -m64
-LOCAL_LDFLAGS += -m64
+LOCAL_CFLAGS += -m32
+LOCAL_LDFLAGS += -m32
接下來的編譯可能會遇到很多因為缺少相應模塊而產生的錯誤,請首先安裝下列軟件模塊:
bison
sun-java6-jdk
g++ (build-essential)
zlib1g-dev
flex
libncurses-dev
gperf
然后,就是make之后漫長的等待...
There is a lot of confusion surrounding the work flow in the Android source tree, so allow me to simplify:
$ source build/envsetup.sh
$ lunch 1
$ make
If you have a multi-core system, you can build with make -jN
where N is twice the number of cores on your machine. This should speed up the first build considerably.
$ ./out/host/<your-machine-type>/bin/emulator
On my system <your-machine-type>
is linux-x86
.
NOTE: The emulator knows where to find system and data images as a result of running lunch 1
above. This sets the environment variable ANDROID_PRODUCT_OUT
to point to the target directory. For this example, it should be out/target/product/generic/
.
source build/envsetup.sh
above. For example, if you modify the Email app and just want to rebuild it:
$ mmm packages/apps/Email
$ adb remount
$ adb sync
Which will copy the regenerated Email.apk
file into the emulator’s /system/app
folder, triggering the PackageManager
to automatically reinstall it.
frameworks/base/core/res/res/
you could regenerate framework-res.apk
with:
$ mmm frameworks/base/core/res
Or if you modified even the framework itself you could run:
$ ONE_SHOT_MAKEFILE="frameworks/base/Android.mk" make framework
This is a special variation of mmm
which is used to build frameworks/base/core/java
.
To sync these changes you must restart the running framework and sync, as with this handy sequence:
$ adb remount
$ adb shell stop
$ adb sync
$ adb shell start
http://source.android.com/using-eclipse
This document also describes how to use Eclipse for development. Any IDE should work with the proper finagling though. Just note that the IDE won’t really by an integrated environment, the final output of APKs, system.img
, and even the generation of R.java
files will have to be done by make
!
A note about the processes in Android:
system_process
houses all things under frameworks/base/services
. This includes the PackageManagerService, StatusBarService, etc. It has many, many threads (one for each service, and then one main UI thread), so be wary when debugging.com.android.acore
hosts Launcher (home), Contacts, etc. You can determine the apps/providers that run here by looking forandroid:process="android.process.acore"
in the various AndroidManifest.xml
files in packages/.Also remember that the “framework” (under frameworks/base/core/java
) is not hosted by any one process. It is a library used by most processes, so to debug code there you can usually use a simple demo app that takes advantage of whatever you changed and debug that app’s process. A useful trick for setting up your debug connection is to call Debug.waitForDebugger()
during some startup part of an application or system service.
This document will help you set up the Eclipse IDE for Android platform development.
Note: if you are looking for information on how to use Eclipse to develop applications that run on Android, this is not the right page for you. You probably would find the Eclipse page on developer.android.com more useful.
First, it's important to make sure the regular Android development system is set up.
cd /path/to/android/root
make # and wait a while, if you haven't done this
Important : You will still be using "make" to build the files you will actually run (in the emulator or on a device). You will be using Eclipse to edit files and verify that they compile, but when you want to run something you will need to make sure files are saved in Eclipse and run "make" in a shell. The Eclipse build is just for error checking.
Eclipse needs a list of directories to search for Java files. This is called the "Java Build Path" and can be set with the .classpath file. We have a sample version to start you off.
cd /path/to/android/root
cp development/ide/eclipse/.classpath .
chmod u+w .classpath # Make the copy writable
Now edit that copy of .classpath, if necessary.
The Android project is large enough that Eclipse's Java VM sometimes runs out of memory while compiling it. Avoid this problem by editing the the eclipse.ini file. On Apple OSX the eclipse.ini file is located at /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini
Memory-related defaults (as of Eclipse 3.4)
-Xms40m
-Xmx256m
-XX:MaxPermSize=256m
Recommended settings for Android development
-Xms128m
-Xmx512m
-XX:MaxPermSize=256m
These settings set Eclipse's minimum Java heap size to 128MB, set the maximum Java heap size to 512MB, and keep the maximum permanent generation size at the default of 256MB.
Now start Eclipse:
eclipse # or you can click some clicky thing instead, if you prefer
Now create a project for Android development:
Once the project workspace is created, Eclipse should start building. In theory, it should build with no errors and you should be set to go. If necessary, uncheck and re-check Project Build Automatically to force a rebuild.
Note: Eclipse sometimes likes to add an "import android.R" statement at the top of your files that use resources, especially when you ask eclipse to sort or otherwise manage imports. This will cause your make to break. Look out for these erroneous import statements and delete them.
Every time you repo sync, or otherwise change files outside of Eclipse (especially the .classpath), you need to refresh Eclipse's view of things:
The default .classpath includes the source to the core system and a sample set of apps, but might not include the particular app you may want to work on. To add an app, you must add the app's source directory. To do this inside Eclipse:
When you're done, the "source folder" path in the list should look like android/packages/apps/YourAppName /src. Depending on which app(s) you include, you may also need to include othersrc/main/java directories under android/dalvik/libcore. Do this if you find you cannot build with the default set.
You can import files in development/ide/eclipse to make Eclipse follow the Android style rules. Select "Window › Preferences › Java › Code Style". Use "Formatter › Import" to import android-formatting.xml and "Organize Imports › Import" to import android.importorder.
You can also use eclipse to debug the emulator and step through code. First, start the emulator running:
cd /path/to/android/root
. build/envsetup.sh
lunch 1 # to build the emulator
make # if you didn't already do this
emulator # you should see a GUI picture of a phone
In another shell, start DDMS (the Dalvik debug manager):
cd /path/to/android/root
ddms # you should get a splufty debugging console
Now, in eclipse, you can attach to the emulator:
Note that port 8700 is attached to whatever process is currently selected in the DDMS console, so you need to sure that DDMS has selected the process you want to debug.
You may need to open the Debug perspective (next to the "Java" perspective icon in the upper-right, click the small "Open Perspective" icon and select "Debug"). Once you do, you should see a list of threads; if you select one and break it (by clicking the "pause" icon), it should show the stack trace, source file, and line where execution is at. Breakpoints and whatnot should all work.
Replace Ctrl with the Apple key on Mac.
Ctrl-Shift-o = Organize imports
Ctrl-Shift-t = load class by name
Ctrl-Shift-r = load non-class resource by name
Ctrl-1 = quick fix
Ctrl-e = Recently viewed files
Ctrl-space = auto complete
Shift-Alt-r = refactor:rename
Shift-Alt-v = refactor:move
Make sure:
If you're still having problems, please contact one of the Android mailing lists or IRC channels.
Ubuntu9.10默認安裝的純凈系統,沒裝任何其他軟件。
1.下載源碼android-2.1_r2,直接make
2.出錯及解決如下:
(1)/bin/bash: bison: command not found
解決:a@ubuntu:~/work/android-2.1_r2$ sudo apt-get install bison
(2)make: *** No rule to make target `Please-install-JDK-5.0,-update-12-or-higher,-which-you-can-download-from-java.sun.com',
needed by `out/target/common/docs/api-stubs-timestamp'. Stop.
解決:安裝JDK 5.0
1):根據官方文檔里所說,源代碼的編譯必須使用JDK5才能編譯的了,所以這里我們使用jdk5
2): 需要先更新源,在終端里執行 sudo vim /etc/apt/sources.list
3): 在source.list里把以下2行拷貝到文檔最后面:
deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse
保存退出。
4): 執行 sudo apt-get update 更新源.
5): 配置編譯環境并下載JDK5:sudo apt-get install sun-java5-jdk
(3)/bin/bash: g++: command not found
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o] Error 127
解決:a@ubuntu:~/work/android-2.1_r2$ sudo apt-get install build-essential
(4)external/clearsilver/cgi/cgi.c:22:18: error: zlib.h: No such file or directory
external/clearsilver/cgi/cgi.c: In function ‘cgi_compress’:
external/clearsilver/cgi/cgi.c:885: error: ‘z_stream’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:885: error: (Each undeclared identifier is reported only once
external/clearsilver/cgi/cgi.c:885: error: for each function it appears in.)
external/clearsilver/cgi/cgi.c:885: error: expected ‘;’ before ‘stream’
external/clearsilver/cgi/cgi.c:888: error: ‘stream’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:888: error: ‘Bytef’ undeclared (first use in
external/clearsilver/cgi/cgi.c:888: error: expected expression before ‘)’ token
external/clearsilver/cgi/cgi.c:889: error: ‘uInt’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:889: error: expected ‘;’ before ‘str’
external/clearsilver/cgi/cgi.c:890: error: expected expression before ‘)’ token
external/clearsilver/cgi/cgi.c:892: error: ‘uLong’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:892: error: expected ‘)’ before ‘stream’
external/clearsilver/cgi/cgi.c:895: error: ‘alloc_func’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:895: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:896: error: ‘free_func’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:896: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:897: error: ‘voidpf’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:897: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFAULT_COMPRESSION’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFLATED’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘MAX_WBITS’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFAULT_STRATEGY’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:901: error: ‘Z_OK’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:904: error: ‘Z_FINISH’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:905: error: ‘Z_STREAM_END’ undeclared (first use in this function) external/clearsilver/cgi/cgi.c: In function ‘cgi_output’:
external/clearsilver/cgi/cgi.c:1200: error: ‘Z_NULL’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:1201: error: expected ‘)’ before ‘Bytef’
external/clearsilver/cgi/cgi.c:1218: error: ‘Z_DEFLATED’ undeclared (first use in this function)
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] Error 1
解決:a@ubuntu:~/work/android-2.1_r2$ sudo apt-get install zlib1g-dev
(5)/bin/bash: flex: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
解決:a@ubuntu:~/work/android-2.1_r2$ sudo apt-get install flex
(6)/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
解決:a@ubuntu:~/work/android-2.1_r2$ sudo apt-get install libncurses-dev
(7)prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:55:22: error: X11/Xlib.h: No such file or directory
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:56:23: error: X11/Xatom.h: No such file or directory
In file included from external/qemu/android/skin/window.c:19:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:73: error: expected specifier-qualifier-list before ‘XEvent’
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:86: error: expected specifier-qualifier-list before ‘Display’
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/skin/window.o] Error 1
解決:a@ubuntu:~/work/android-2.1_r2$ sudo apt-get install libx11-dev
(8)sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 96.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h'
解決:a@ubuntu:~/work/android-2.1_r2$ sudo apt-get install gperf
http://hi.baidu.com/maxgoto/blog/item/fa000f7bf01135f80ad187d8.html 最近下載了Android 2.1源碼,在Ubuntu 9.10上做了一次編譯,由于系統為純凈系統,之前沒有進行過任何Android的編譯,所以需先安裝一些必要軟件。編譯過程參考網上一些文章,做下筆記如下,以供參考:
1. 下載或更新Android源碼 至最新,截止到前天(04-09)好像是2.1-r2.
2. Android 要求的 jdk 1.5,而Ubuntu9.10的源里只有JDK1.6. 目前網上解決方法有兩種:
解決方法一: 安裝JDK1.5
1) 根據官方文檔里所說,源代碼的編譯必須使用JDK5才能編譯的了,所以這里我們使用jdk5
2) 需要先更新源,在終端里執行 sudo vim /etc/apt/sources.list
3) 在source.list里把以下2行拷貝到文檔最后面:
deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse
保存退出。
4) 執行 sudo apt-get update 更新源.
5)配置編譯環境并下載JDK5:sudo apt-get install sun-java5-jdk
3. 安裝編譯過程中必需軟件 。根據網上高人的經驗,這是編譯的最小工具軟件集。
$sudo apt-get install build-essential
$sudo apt-get install zlib1g-dev
$sudo apt-get install flex
$sudo apt-get install libncurses-dev
$sudo apt-get install libx11-dev
$sudo apt-get install gperf
4. make .經過漫長的編譯過程,編譯成功。
deb http://run.hit.edu.cn/ubuntu/ jaunty main restricted universe multiverse
deb-src http://run.hit.edu.cn/ubuntu/ jaunty main restricted universe multiverse
deb http://run.hit.edu.cn/ubuntu/ jaunty-updates main restricted universe multiverse
deb-src http://run.hit.edu.cn/ubuntu/ jaunty-updates main restricted universe multiverse
deb http://run.hit.edu.cn/ubuntu/ jaunty-backports main restricted universe multiverse
deb-src http://run.hit.edu.cn/ubuntu/ jaunty-backports main restricted universe multiverse
deb http://run.hit.edu.cn/ubuntu/ jaunty-security main restricted universe multiverse
deb-src http://run.hit.edu.cn/ubuntu/ jaunty-security main restricted universe multiverse
deb http://mirror.optus.net/ubuntu/ jaunty main restricted universe multiverse
deb http://mirror.optus.net/ubuntu/ jaunty-security main restricted universe multiverse
deb http://mirror.optus.net/ubuntu/ jaunty-updates main restricted universe multiverse
deb http://mirror.optus.net/ubuntu/ jaunty-proposed main restricted universe multiverse
deb http://mirror.optus.net/ubuntu/ jaunty-backports main restricted universe multiverse
deb-src http://mirror.optus.net/ubuntu/ jaunty main restricted universe multiverse
deb-src http://mirror.optus.net/ubuntu/ jaunty-security main restricted universe multiverse
deb-src http://mirror.optus.net/ubuntu/ jaunty-updates main restricted universe multiverse
deb-src http://mirror.optus.net/ubuntu/ jaunty-proposed main restricted universe multiverse
deb-src http://mirror.optus.net/ubuntu/ jaunty-backports main restricted universe multiverse
2. 切換到9.04的源
sudo apt-get update
3. update之后,用
sudo apt-get install sun-java5-jdk 即可安裝java 1.5
4. 安裝后進行設置:
sudo update-alternatives --config java
sudo update-java-alternatives -s java-1.5.0-sun
1.將Wrapper壓縮包中的bin,lib,conf,logs目錄拷貝到新建的目錄ss中,將我們的程序打包成jar和依賴包一起放入lib中。
2.將bin目錄中的testwrapper改成應用名ss,并編輯,修改下面兩項:
APP_NAME="SocketServer"
APP_LONG_NAME="SocketServer Application"
3.修改conf/wrapper.conf文件:
4.這樣基本上就可以了,上傳到服務器上,進入bin目錄,執行./ss start,如果沒有權限,則執行chmod a+x *即可
Ubuntu 下安裝 OpenSSH Server 是無比輕松的一件事情,需要的命令只有一條:
sudo apt-get install openssh-server
隨后,Ubuntu 會自動下載并安裝 openssh server,并一并解決所有的依賴關系。當您完成這一操作后,您可以找另一臺計算機,然后使用一個 SSH 客戶端軟件(強烈推薦 PuTTy),輸入您服務器的 IP 地址。如果一切正常的話,等一會兒就可以連接上了。并且使用現有的用戶名和密碼應該就可以登錄了。
事實上如果沒什么特別需求,到這里 OpenSSH Server 就算安裝好了。但是進一步設置一下,可以讓 OpenSSH 登錄時間更短,并且更加安全。這一切都是通過修改 openssh 的配置文件 sshd_config 實現的。
首先,您剛才實驗遠程登錄的時候可能會發現,在輸入完用戶名后需要等很長一段時間才會提示輸入密碼。其實這是由于 sshd 需要反查客戶端的 dns 信息導致的。我們可以通過禁用這個特性來大幅提高登錄的速度。首先,打開 sshd_config 文件:
sudo nano /etc/ssh/sshd_config
找到 GSSAPI options 這一節,將下面兩行注釋掉:
#GSSAPIAuthentication yes #GSSAPIDelegateCredentials no
然后重新啟動 ssh 服務即可:
sudo /etc/init.d/ssh restart
再登錄試試,應該非常快了吧
SSH 服務中,所有的內容都是加密傳輸的,安全性基本有保證。但是如果能使用證書認證的話,安全性將會更上一層樓,而且經過一定的設置,還能實現證書認證自動登錄的效果。
首先修改 sshd_config 文件,開啟證書認證選項:
RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile %h/.ssh/authorized_keys
修改完成后重新啟動 ssh 服務。
下一步我們需要為 SSH 用戶建立私鑰和公鑰。首先要登錄到需要建立密鑰的賬戶下,這里注意退出 root 用戶,需要的話用 su 命令切換到其它用戶下。然后運行:
ssh-keygen
這里,我們將生成的 key 存放在默認目錄下即可。建立的過程中會提示輸入 passphrase,這相當于給證書加個密碼,也是提高安全性的措施,這樣即使證書不小心被人拷走也不怕了。當然如果這個留空的話,后面即可實現 PuTTy 通過證書認證的自動登錄。
ssh-keygen 命令會生成兩個密鑰,首先我們需要將公鑰改名留在服務器上:
cd ~/.ssh mv id_rsa.pub authorized_keys
然后將私鑰 id_rsa 從服務器上復制出來,并刪除掉服務器上的 id_rsa 文件。
服務器上的設置就做完了,下面的步驟需要在客戶端電腦上來做。首先,我們需要將 id_rsa 文件轉化為 PuTTy 支持的格式。這里我們需要利用 PuTTyGEN 這個工具:
點擊 PuTTyGen 界面中的 Load 按鈕,選擇 id_rsa 文件,輸入 passphrase(如果有的話),然后再點擊 Save PrivateKey 按鈕,這樣 PuTTy 接受的私鑰就做好了。
打開 PuTTy,在 Session 中輸入服務器的 IP 地址,在 Connection->SSH->Auth 下點擊 Browse 按鈕,選擇剛才生成好的私鑰。然后回到 Connection 選項,在 Auto-login username 中輸入證書所屬的用戶名。回到 Session 選項卡,輸入個名字點 Save 保存下這個 Session。點擊底部的 Open 應該就可以通過證書認證登錄到服務器了。如果有 passphrase 的話,登錄過程中會要求輸入 passphrase,否則將會直接登錄到服務器上,非常的方便。
好了,今天就寫到這,以后逐步再寫 AMP,Proftpd 和 Squid 的安裝和設置。