Hope Have Good tech
Linux extend php apache server mvc java
posts - 13,  comments - 0,  trackbacks - 0

最近给一个朋友做服务器配置,他买的一个独立的服务器,因为服务器商防火墙的设置,很多网络访问都被禁用(比如Ping, 怀疑他们的能力);

我想让朋友用GUI工具直接访问远程数据库,不过可恶的是尽管配置了Mysql 服务器绑定远程地址,还是不能访问;尝试用 SSH 隧道来代理访问了;

执行这条命令:

 ssh -L 3306:localhost:3306 romote_user@remote_server_address

语法是: ssh -L <localport>hostname<remoteport> <username>@<servername>

这条命令的含义是将localhost:port 的请求重定向到绑定的地址:port

(所以如果本地安装了Mysql 监听着3306端口,那把本地端口配置改成其他的;)

再链接一下远程的服务器吧:

mysql --host=localhost --port=locate_port --user='user' --password='pass'

执行命令后, SSH 会把这个请求重定向到服务器上;

posted @ 2011-10-15 15:05 JackeyChan 阅读(20) 评论(0) 编辑

Yesterday a friend was requesting a MYSQL/PHP Consultant to speed up his websites, and today I was reading few comments and solutions on his facebook : Use APC, mem_cache for PHP, mysql query caching, use nginx instead of Apache, Use mysqli extension instead of adodb or mysql extension ... etc. Of course all of these could be solutions, but unless you have previously located what the problem really is.

A website could be slow for many reasons, and to be able to fix it and make it run faster you have to first find problem. What you will need to know is :

1- Understand the business :

Before looking into PHP or MySQL, have a first look at the website(s) and answer these two questions :

- What is slow
- Why is it slow

Look at the page size, images, video, flash, ... your issue might be in the client side and everything else might be good.
Use a tool like Firefox web developer extension and disable everything : CSS, Javascript, Images... and load the page as html to feel the difference.
The business here is NOT the business logic behind the website, it's the interface that people use to interact with the website. If everything looks okay, you can go for further server-side investigations.

2- Understand the production environment : Operating system, PHP and MySQL versions, PHP extensions running, PHP and MySQL configurations.

Do not start optimizing code or database unless you know the exact problem, otherwise you have to start by understanding and optimizing the working environment. Some tweaks in PHP and MySQL settings might fix your problem and you won't probably need to dig deeply into any code.

3- Understand the code :

If the websites you are looking to optimize are using a common framework or CMS, let's say Drupal, Wordpress, Zend Framework, Symfony... such websites you can deal with separetely since most optimization issues should be known and you will easily find your way to speed things up.

Otherwise, for custom code and custom application development, start with debugging and focus firstly on the database. That's where most slow issues come from, especially if the concerned website was running fast in the beginning then become slow over the time due to database size going bigger, query & index issues...

4- Debug : detect and locate bottlenecks

Debuggers are your friends here, whatever the environment you are running. Answer again previous questions (What and Why) but this time with relation to the code itself.

You might consider running a stress test here to simulate real working environment. Such tests could help you understand more networking issues and make it easier to locate slowliness based on real scenarios. Test should also simulate real environment, and you will need to save speed result for comparison later.

5- Solution proposal and action plan

Now you can go ahead and set possible solutions : fixing bugs, caching code/queries, tweak your settings... Make sure your modifications will not affect other working website in the same environment - if any is somehow related or linked.

Finally you can run previous stress test with new configuration and updates to see the difference in speed gained. A report of previously mentioned steps should be written including result.

Article originally posted on HBY Consultancy

posted @ 2010-12-26 00:55 JackeyChan 阅读(90) 评论(0) 编辑

note: I copy below example from internet.

Below is a simple program using node.js for translating text using google API.

var http = require('http');
 
var url = ('ajax.googleapis.com')
var google = http.createClient(80, url);
 
var text = "Hello World from node!";
var requestUrl = '/ajax/services/language/translate?v=1.0&q=' +
escape(text) + '&langpair=en%7Cfr'
var request = google.request('GET', requestUrl,
{"host": "ajax.googleapis.com"});
request.end();
 
request.addListener('response', function (response) {
var body = '';
 
response.addListener('data', function (chunk) {
body += chunk;
});
 
response.addListener("end", function() {
var jsonData = JSON.parse(body);
console.log(jsonData.responseData.translatedText);
})
 
});

This simple example does not to justice to the true power of node.js. I’ll be posting useful examples in the near future. Keep watching.

posted @ 2010-12-23 21:06 JackeyChan 阅读(73) 评论(0) 编辑

step by step:

1. Should install certain libraries:

sudo apt-get install g++ curl libssl-dev apache2-utils

2. Now, Download node.js with GIT

git clone git://github.com/ry/node.git


3.You are ready to install node.js
cd node
./configure
make
sudo make install

note:if need, you can type : sudo apt-get install git-core to install GIT.

posted @ 2010-12-23 20:57 JackeyChan 阅读(36) 评论(0) 编辑

Xdebug is a PHP debugger with nice Eclipse integration. Here are some instructions for installing it (assuming you already have Apache 2 and PHP 5).

This article explains in more detail, but isn't Ubuntu-specific. It does detail Eclipse configuration for Xdebug in detail, though.

You need to be root to do the installation.

First off, install Xdebug. This isn't packaged for Ubuntu, so you need to do it with PECL. So install PECL if you don't have it:

apt-get install pecl

Use PECL to install Xdebug:

pecl install xdebug

Configure PHP 5 to use Xdebug by adding these lines to /etc/php5/apache2/php.ini (somewhere near where the other extension= lines are):

zend_extension=/usr/lib/php5/20060613+lfs/xdebug.so

 

[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.remote_host=127.0.0.1
xdebug.remote_log=/var/log/apache2/xdebug_remote.log

Note you need to use zend_extension= to load the extension, and you should use the absolute path to the module (.so file) to do this. Otherwise it fails.

Check using PHP info, e.g. add a file called phpinfo.php to your web root:

<?php phpinfo(); ?>

Then call it in your browser. Check that there is an Xdebug section displayed.

That's Xdebug installed. See the article linked at the start of this entry if you want to integrate with Eclipse.

posted @ 2010-12-22 12:49 JackeyChan 阅读(16) 评论(0) 编辑

ps -ef | grep eclipse

kill PID

posted @ 2010-12-21 14:34 JackeyChan 阅读(24) 评论(0) 编辑
摘要: How chmod worksChmod works by changing the mode of parameters on files and directories. If you look at an extended listing of a file you will see something like this:-rw-r--r-- 1 jlwallen jlwallen 4096 2008-11-14 12:56 test1Here is a breakdown of what you are seeing:-rw-r--r-- : These are the actual阅读全文
posted @ 2010-12-20 12:43 JackeyChan 阅读(29) 评论(0) 编辑
摘要: See all color.* options in the git config docsOr, you can set all of them on with the color.ui option:阅读全文
posted @ 2010-12-20 11:46 JackeyChan 阅读(64) 评论(0) 编辑
摘要: Virtual Hosting allow web servers to host more than one website on a sing machine. This is how sharing hosting works. I become pretty handy as well while develloping different web project on the same machine and allows you to access to your local repository using addresses such as http://dev.mysite.阅读全文
posted @ 2010-12-20 11:31 JackeyChan 阅读(49) 评论(0) 编辑
摘要: ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvP1sZVAVJFjf2cQk5jkX6U0bxhal2fTlHSbPNXdtgAYHDqobfUtWwcOAeUqxUWnP40GJZojYBll1Pj9xeaf5yZl3HbYrFYivl0PX3iRDxAAbxpLMd9OBe7dDaGL+hO4xAka56fEvGJu7im0qX4RzQGoSK+0+jvlhUYugp5F1FmYTgBya53ZpChHc3lTR12ByzG6HfxjbzMSuCIYYeW3+CPdj+MyYqQpYrICcnD0kWCF9U5ciRjVz4m3zhqTXBDSTbM6NG5Fk阅读全文
posted @ 2010-12-14 10:56 JackeyChan 阅读(27) 评论(0) 编辑
仅列出标题  下一页