Apache Ivy 是Apache Ant 下的一个子项目。Apache Ivy是一个优秀的管理(记录、跟踪、解析和报告)项目依赖的工具,提供了强大的依赖管理功能,可与Apache Ant紧密集成。项目相关网址:(http://ant.apache.org/ivy/)
ivyDe是eclipse的一个插件,用来支持ivy。
要安装ivyDe,可以从eclipse在线安装,地址是http://www.apache.org/dist/ant/ivyde/updatesite
Apache Ivy 是Apache Ant 下的一个子项目。Apache Ivy是一个优秀的管理(记录、跟踪、解析和报告)项目依赖的工具,提供了强大的依赖管理功能,可与Apache Ant紧密集成。项目相关网址:(http://ant.apache.org/ivy/)
ivyDe是eclipse的一个插件,用来支持ivy。
要安装ivyDe,可以从eclipse在线安装,地址是http://www.apache.org/dist/ant/ivyde/updatesite
HTTP
正向代理安装
1 |
$ sudo apt-get install squid squid-common |
配置squid3
1 2 3 4 5 |
# ubuntu 12.04/14.04默认配置文件路径 $ sudo vim /etc/squid3/squid.conf # ubuntu 18.04默认配置文件路径 $ sudo vim /etc/squid/squid.conf |
搜索此句
1 |
http_access deny all |
修改为
1 |
http_access allow all |
搜索此句(squid默认允许访问本地(localhost
)服务,但建议禁止)
1 |
http_access allow localhost |
修改为
1 |
http_access deny localhost |
启动/重启squid3
1 2 3 4 5 |
# ubuntu 12.04/14.04 $ sudo service squid3 restart # ubuntu 18.04 $ sudo service squid restart |
注意: squid
的http
默认代理端口为3128
由于ubuntu 12.04/14.04/18.04
默认安装的squid
版本是不支持SSL
的,因此只能重新编译支持SSL
。
1.安装编译依赖
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$ cd ~ $ mkdir squid_src $ cd squid_src $ sudo apt-get install build-essential fakeroot devscripts gawk gcc-multilib dpatch $ sudo apt-get build-dep squid3 $ sudo apt-get build-dep openssl $ sudo apt-get install libssl-dev $ sudo apt-get install openssl $ apt-get source squid3 |
2.修改默认的编译选项,增加SSL
支持
ubuntu 12.04
1 |
$ vim squid3-3.1.19/debian/rules |
在DEB_CONFIGURE_EXTRA_FLAGS
字段中增加--enable-ssl
1 2 3 4 5 6 7 8 |
... DEB_CONFIGURE_EXTRA_FLAGS := --datadir=/usr/share/squid3 \ --sysconfdir=/etc/squid3 \ --mandir=/usr/share/man \ --with-cppunit-basedir=/usr \ --enable-inline \ --enable-ssl \ ... |
ubuntu 14.04/18.04
1 2 3 4 5 |
# ubuntu 14.04 $ vim squid3-3.3.8/debian/rules # ubuntu 18.04 $ vim squid3-3.5.27/debian/rules |
对于Ubuntu 14.04
来说,除了要在DEB_CONFIGURE_EXTRA_FLAGS
字段中增加--enable-ssl
外,由于squid3-3.3.8
默认去掉了对于NCSA
的支持,而我们下面认证密码的配置是基于NCSA
算法的,因此需要在DEB_CONFIGURE_EXTRA_FLAGS
的--enable-auth-basic
字段中增加对于NCSA
的支持,否则无法使用NCSA
算法进行账号认证,修改后的样子如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
... DEB_CONFIGURE_EXTRA_FLAGS := --datadir=/usr/share/squid3 \ --sysconfdir=/etc/squid3 \ --mandir=/usr/share/man \ --enable-inline \ --enable-ssl\ --enable-async-io=8 \ --enable-storeio="ufs,aufs,diskd,rock" \ --enable-removal-policies="lru,heap" \ --enable-delay-pools \ --enable-cache-digests \ --enable-underscores \ --enable-icap-client \ --enable-follow-x-forwarded-for \ --enable-auth-basic="NCSA,DB,fake,getpwnam,LDAP,MSNT,MSNT-multi-domain,NCSA,NIS,PAM,POP3,RADIUS,SASL,SMB" \ ... |
注意,这样修改后squid3-3.3.8
版本编译出来的在/usr/lib/squid3/
下的ncsa_auth
被重命名成了basic_ncsa_auth
,因此配置文件中制定认证应用的时候要修改一下。
对于Ubuntu 18.04
来说,这个参数不需要调整,默认支持NCSA
。
注意,如果需要禁用ipv6
的支持,则增加--disable-ipv6
选项,这个目前是唯一的可以彻底禁用ipv6
代理访问的方式。这个需求的原因是由于配置问题,某些网站的ipv6
地址存在,但是无法正常访问。
3.配置编译
ubuntu 12.04
1 2 3 |
$ cd squid3-3.1.19/ $ debuild -us -uc -b |
ubuntu 14.04
1 2 3 |
$ cd squid3-3.3.8/ $ debuild -us -uc -b |
ubuntu 18.04
1 2 3 |
$ cd squid3-3.5.27/ $ debuild -us -uc -b |
4.安装(编译后的文件存在在上层的squid_src
目录下面)
ubuntu 12.04
1 2 3 |
$ cd .. $ sudo dpkg -i squid3_3.1.19-1ubuntu3.12.04.2_amd64.deb squid3-common_3.1.19-1ubuntu3.12.04.2_all.deb squid3-dbg_3.1.19-1ubuntu3.12.04.2_amd64.deb |
ubuntu 14.04
1 2 3 |
$ cd .. $ sudo dpkg -i squid3-common_3.3.8-1ubuntu6.6_all.deb squid_3.3.8-1ubuntu6.6_amd64.deb squid3_3.3.8-1ubuntu6.6_amd64.deb squid3-dbg_3.3.8-1ubuntu6.6_amd64.deb |
ubuntu 18.04
1 2 3 |
$ cd .. $ sudo dpkg -i squid-common_3.5.27-1ubuntu1.9_all.deb squid_3.5.27-1ubuntu1.9_amd64.deb squid_3.5.27-1ubuntu1.9_amd64.deb squid-dbg_3.5.27-1ubuntu1.9_amd64.deb |
5.验证安装后的版本是否支持SSL
1 |
$ squid3 -v | grep enable-ssl |
如果看到enable-ssl
输出,则说明编译成功。
6.生成自签名证书
1 |
$ openssl req -new -keyout key.pem -nodes -x509 -days 365 -out cert.pem |
7.移动服务器证书到squid3
配置目录
1 2 3 |
$ sudo mv cert.pem /etc/squid3/cert.pem $ sudo mv key.pem /etc/squid3/key.pem |
8.配置squid3
1 |
$ sudo vim /etc/squid3/squid.conf |
搜索https_port
,如果搜索到,则在搜索到的位置增加,搜索不到则在文件的最后增加
1 |
https_port 443 cert=/etc/squid3/cert.pem key=/etc/squid3/key.pem |
9.验证配置文件是否配置正确
1 |
$ squid3 -k parse |
10.启动/重启squid
1 2 3 4 5 |
# ubuntu 12.04/14.04 $ sudo service squid3 restart # ubuntu 18.04 $ sudo service squid restart |
11.安装 stunnel 配置安装目录下的stunnel.conf
,把原来的内容都删掉,粘贴下面的内容
1 2 3 4 |
client = yes [https] accept = 127.0.0.1:8080 connect = www.mobibrw.com:443 |
12.设置浏览器代理服务器地址
13.重新启动stunnel
。
注意,如果只支持Https
协议,可以注释掉原来的
1 |
http_port 3128 |
Squid3
用户名密码认证1. 安装htpasswd
(如果装了apache
就省掉这一步)
(这个是用来产生密码的)
1 |
$ sudo apt-get install apache2-utils |
也可以
1 |
$ sudo apt-get install mini-httpd |
2.生成密码文件
1 |
$ htpasswd -c /etc/squid3/passwd user1 |
会让你输入user1
的密码
3.改一下权限,确保squid
能够读出密码文件
1 |
$ sudo chmod o+r /etc/squid3/passwd |
4.修改squid.conf
,增加或修改成下面的样子
对于ubuntu 12.04
版本上编译出来的的Squid3-3.1.19
,执行如下配置:
1 2 3 |
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid3/passwd acl ncsa_users proxy_auth REQUIRED http_access allow ncsa_users |
对于ubuntu 14.04
版本上编译出来的的Squid3-3.3.8
,由于验证程序的名字被修改成了basic_ncsa_auth
,因此执行如下配置:
1 2 3 |
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid3/passwd acl ncsa_users proxy_auth REQUIRED http_access allow ncsa_users |
简单的修改可以在VIM
中查询 "auth_param basic program /usr/lib/squid/ncsa_auth
" 找到后修改一下即可.
然后搜索 "http_access allow all
" 找到后替换为 "http_access allow ncsa_users
"
在"http_access allow all
" 上面就是acl
控制部分,直接增加"acl ncsa_users proxy_auth REQUIRED
"
如果配置文件是从Squid3-3.1.19
升级到Squid3-3.3.8
版本的,那么根据如下两个链接的描述:
http://wiki.squid-cache.org/SquidFaq/ConfiguringSquid
https://forums.gentoo.org/viewtopic-t-952948-start-0.html
1 |
3.2 further configuration cleanups have been done to make things easier and safer. The manager, localhost, and to_localhost ACL definitions are now built-in. |
这两个链接上的信息,从Squid3-3.2
版本开始,原来配置文件中的acl
控制信息已经不需要再从配置文件中读取了,这部分的功能已经集成进入应用内部了。
因此需要注释掉下面这几句话,否则无法正常启动Squid3
.
1 2 3 4 5 |
# Recommended minimum configuration: # acl manager proto cache_object acl localhost src 127.0.0.1/32 ::1 acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1 |
5.重启squid3
1 2 3 4 5 |
# ubuntu 12.04/14.04 $ sudo service squid3 restart # ubuntu 18.04 $ sudo service squid restart |
squid3
在默认编译的时候,已经包含了--enable-delay-pools
选项,因此已经默认支持限速了,我们只需要设置限速配置就可以了。
1 |
$ sudo vim /etc/squid3/squid.conf |
在文件最后增加如下配置:
1 2 3 4 5 |
delay_pools 1 delay_class 1 1 delay_access 1 allow all delay_parameters 1 50000/50000 # 限制网速在50K以内 delay_initial_bucket_level 50 |
参数的具体解释请在squid.conf
中搜索delay-pools
查看。
重启squid3
1 2 3 4 5 |
# ubuntu 12.04/14.04 $ sudo service squid3 restart # ubuntu 18.04 $ sudo service squid restart |
使用SVN 1.6 之前版本 checkout出来的代码,在本地每个文件夹下都有个 .svn ,可利用这个命令来删除
Linux
1 |
find . -name .svn -print0 | xargs -0 rm -r -f |
Windows(需要在批处理文件中执行)
1 |
for /r . %%a in (.) do @if exist %%a\.svn rd /s /q %%a\.svn |
对于Git的目录也可以如此操作:
Linux
1 |
find . -name .git -print0 | xargs -0 rm -r -f |
Windows(需要在批处理文件中执行)
1 |
for /r . %%a in (.) do @if exist %%a\.git rd /s /q %%a\.git |
使用 WordPress 构筑的 Blog 最近总是会报告 “建立数据库连接时出错” ,查看 Apache 的日志得到如下信息
1 |
$ sudo vim /var/log/apache2/error.log |
在日志的最后得到类似如下的内容
1 |
[Mon Jan 06 16:30:06 2014] [error] [client 5.10.83.83] WordPress SELECT * FROM wp_posts WHERE (post_type = 'page' AND post_status = 'publish') ORDER BY menu_order,wp_posts.post_title .......MySQL server has gone away |
这个 “MySQL server has gone away” 有些莫名奇妙,MySql 怎么会无缘无故的没有了呢。
于是查看系统日志
1 |
$ sudo vim /var/log/syslog |
看到如下的输出
1 2 3 4 |
Jan 6 16:30:05 AY130422143404983ad9 kernel: [236491.346180] Out of memory: Kill process 755 (mysqld) score 91 or sacrifice child Jan 6 16:30:05 AY130422143404983ad9 kernel: [236491.346267] Killed process 755 (mysqld) total-vm:887016kB, anon-rss:45820kB, file-rss:0kB Jan 6 16:30:05 AY130422143404983ad9 kernel: [236491.422036] init: mysql main process (755) killed by KILL signal Jan 6 16:30:05 AY130422143404983ad9 kernel: [236491.422096] init: mysql main process ended, respawning |
可以明显看到,是由于系统内存不足,导致了 Linux 系统自带的 OOM Killer 动作。执行
1 |
$ free -lm |
可以看到,实际的内存已经严重不足了,这台机器只配置了512M内存,跑一阵子之后,系统的剩余内存不足 10MB的样子了。
没办法,花钱加内存到1G。悲剧的是,还是会死掉,具体解决办法可以查看
Ubuntu 12.04下安装配置Worker工作模式的Apache 支持PHP
Ubuntu 12.04 Apache2 安装 PHP-FPM 增强 PHP5-CGI 的功能
通过限制DefaultMaxClassProcessCount 的数量来限制php5-cgi 的数量来避免太多的并发进程耗尽资源。
两个APK 通过Content Provider 来共享数据,在Android 4.2.2 API 17 之前都是正常的,但是到Android 4.2.2 API 17 上面就会报告异常类似如下的异常信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
09-17 12:15:52.221: E/AndroidRuntime(4551): FATAL EXCEPTION: main 09-17 12:15:52.221: E/AndroidRuntime(4551): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.identifier.gamecenter.gctictactoe/com.identifier.gamecenter.game.MainActivity}: java.lang.SecurityException: Permission Denial: opening provider com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider from ProcessRecord{42622078 4551:com.identifier.gamecenter.gctictactoe/u0a10108} (pid=4551, uid=10108) that is not exported from uid 10072 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.access$600(ActivityThread.java:141) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.os.Handler.dispatchMessage(Handler.java:99) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.os.Looper.loop(Looper.java:137) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.main(ActivityThread.java:5103) 09-17 12:15:52.221: E/AndroidRuntime(4551): at java.lang.reflect.Method.invokeNative(Native Method) 09-17 12:15:52.221: E/AndroidRuntime(4551): at java.lang.reflect.Method.invoke(Method.java:525) 09-17 12:15:52.221: E/AndroidRuntime(4551): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 09-17 12:15:52.221: E/AndroidRuntime(4551): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 09-17 12:15:52.221: E/AndroidRuntime(4551): at dalvik.system.NativeStart.main(Native Method) 09-17 12:15:52.221: E/AndroidRuntime(4551): Caused by: java.lang.SecurityException: Permission Denial: opening provider c.identifier.gamecenterapp.contentprovider.MyGamesContentProvider from ProcessRecord{42622078 4551:com.identifier.gamecenter.gctictactoe/u0a10108} (pid=4551, uid=10108) that is not exported from uid 10072 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.os.Parcel.readException(Parcel.java:1431) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.os.Parcel.readException(Parcel.java:1385) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2611) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.acquireProvider(ActivityThread.java:4515) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2036) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1149) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.content.ContentResolver.query(ContentResolver.java:398) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.content.ContentResolver.query(ContentResolver.java:357) 09-17 12:15:52.221: E/AndroidRuntime(4551): at ch.ethz.csg.wlanopp.gapi.GameCenterController.getIdByGameTitle(GameCenterController.java:602) 09-17 12:15:52.221: E/AndroidRuntime(4551): at ch.ethz.csg.wlanopp.gapi.GameCenterController.isRegistered(GameCenterController.java:343) 09-17 12:15:52.221: E/AndroidRuntime(4551): at ch.ethz.csg.wlanopp.gapi.GameCenterController.addGame(GameCenterController.java:352) 09-17 12:15:52.221: E/AndroidRuntime(4551): at ch.ethz.csg.gamecenter.gctictactoe.MainActivity.onCreate(MainActivity.java:130) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.Activity.performCreate(Activity.java:5133) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 09-17 12:15:52.221: E/AndroidRuntime(4551): ... 11 more 09-17 12:20:52.487: I/Process(4551): Sending signal. PID: 4551 SIG: 9 |
在AndroidManifest.xml中原来的定义如下
1 2 3 4 |
<provider android:name="com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider" android:authorities="com.identifier.gamecenterapp.contentprovider" > </provider> |
并且没有定义 android:targetSdkVersion
查找了很多地方,最终发现原因
1 2 3 |
Content providers are no longer exported by default. That is, the default value for the android:exported attribute is now “false". If it’s important that other apps be able to access your content provider, you must now explicitly set android:exported="true". This change takes effect only if you set either android:targetSdkVersion or android:minSdkVersion to 17 or higher. Otherwise, the default value is still “true" even when running on Android 4.2 and higher. |
具体的网页在 http://developer.android.com/about/versions/android-4.2.html
因此修改为如下即可 也就是增加 android:exported="true"
1 2 3 4 5 |
<provider android:name="com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider" android:authorities="com.identifier.gamecenterapp.contentprovider" android:exported="true"> </provider> |
工作中很多时候需要编辑修改16进制的文件,在Windows下面常用UltraEdit来编辑,切换到Mac下面后,找了很多,最后发现一个免费的好用软件 Hex Fiend
每一次登录Ubuntu的时候小键盘都是关着的。可是每次又得输入密码,所以还是得手动打开数字键,亮了Numlock的灯。
Ubuntu 13.04 下面执行如下操作
1 |
sudo apt-get install numlockx |
编辑文件
1 |
sudo vim /etc/lightdm/lightdm.conf |
在文件最后增加
1 |
greeter-setup-script=/usr/bin/numlockx on |
Ubuntu 13.10 下面执行如下操作
1 |
sudo apt-get install numlockx |
编辑文件
1 |
sudo vim /etc/lightdm/lightdm.conf.d/50-unity-greeter.conf |
在文件最后增加
1 |
greeter-setup-script=/usr/bin/numlockx on |
Ubuntu 16.04 LTS 下面执行如下操作
创建文件
1 |
sudo vim /etc/lightdm/lightdm.conf.d/50-unity-greeter.conf |
在文件最后增加
1 |
greeter-setup-script=/usr/bin/numlockx on |
运行虚拟机提示:
1 |
The virtual machine 'XXX' has terminated unexpectedly during startup with exit code 1. |
之后提示:
1 2 3 4 5 6 7 |
Kernel driver not installed (rc=-1908) The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing '/etc/init.d/vboxdrv setup' as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary. |
在终端下运行:
1 |
sudo /etc/init.d/vboxdrv setup |
提示信息
1 2 3 |
Stopping VirtualBox kernel modules [ OK ] * Recompiling VirtualBox kernel modules * Look at /var/log/vbox-install.log to find out what went wrong |
提示有错误,查看了一下错误日志
1 |
cat /var/log/vbox-install.log |
内容如下
1 |
Makefile:181: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again。 停止。 |
根据提示应该是没有找到对应的源文件,查看了一下系统版本号:
1 |
uname -r |
在进入/usr/src里发现果然没有对应的版本号头文件。
1 2 |
sudo apt-get install dkms build-essential linux-headers-generic sudo /etc/init.d/vboxdrv setup |