linux 設定一張網卡有兩個以上的ip

linux 設定一張網卡有兩個以上的ip

申請專線可能會給你6~8個固定IP,而我們有時會因為策略考量,想把不同的網站給一個獨立IP,
但都架在同一台Linux中,Windows Server可以從網路設定這邊加入其它組IP,當然Linux也可以!
設定如下:
進入/etc/sysconfig/network-scritps目錄
會看到 ifcfg-eth0 ,這表示是你的第一張網卡,把這的檔案複製後貼上,檔名改成
ifcfg-0:0 (加入第二個IP,由0..1..2..3…有幾個IP就加到幾 如 ifcfg-0:6 表示第8的IP,記得從0開始)
內容就只要改IPADDR,其它不動,如下
DEVICE=”eth0″
HWADDR=”xxxx”
IPADDR=”改成你第二個IP” ←只要改這個
NETMASK=”XXXXXX”

其它內容不動,存檔後重新啟動network

#service network restart

完成.

Norton DNS 開放測試,提供更快、更安全的上網體驗

Norton DNS 開放測試,提供更快、更安全的上網體驗

從 OpenDNS 到 Google Public DNS ,現在連諾頓也打算跟進,提供開放的 DNS 服務。Norton DNS 目前仍在測試階段,在基礎上提供更快、更安全的網頁瀏覽環境。這無須下載任何客戶端程式,你可以在家中路由器端啟用 Norton DNS 以保護所有設備,或是在個人電腦上啟用此服務。

Norton DNS Beta 提供的 DNS 位址為:198.153.192.1 及 198.153.194.1 。

PHP5與PHP4的區別

PHP5與PHP4的區別

一、未100%向下兼容

在php5中儘管大部分PHP4的代碼應該不用修改就能運行,還是應該留意以下不向下兼容的改變:

有了一些新關鍵字。

strrpos() 和 strripos()如今使用整個字符串作爲 needle.

非法使用字符串偏移量會導致 E_ERROR 而不是 E_WARNING.一個非法使用的例子:$str = ‘abc’; unset($str[0]);.

array_merge() 被改成隻接受數組。如果傳遞入非數組變量,對每個此類參數都會發出一條 E_WARNING 信息。要小心因爲你的代碼有可能瘋狂發出 E_WARNING.

PATH_TRANSLATED 服務器變量在 Apache2 SAPI 中不再暗中設定,這和 PHP 4 中的情形相反,如果 Apache 沒産生此值則其被設爲和 SCRIPT_FILENAME 服務器變量一樣的值。此修改是爲了遵守CGI 規範。更多信息參考手册中 $_SERVER[‘PATH_TRANSLATED’] 的說明。此問題也影響到 PHP >= 4.3.2 的版本。

Tokenizer 擴展不再定義T_ML_COMMENT 常量。如果把 error_reporting 設爲 E_ALL,PHP 將産生一條消息。儘管 T_ML_COMMENT 從來都沒用到過,還是在 PHP 4 中定義了。在 PHP 4 和 PHP 5 中 // 和 都被解析爲 T_COMMENT 常量。但是 PHPDoc 風格的注釋 ,自 PHP 5 開始被 PHP 解析,被識別爲 T_DOC_COMMENT.

如果 variables_order 包括“S”,$_SERVER 應該帶有 argc 和 argv 被産生。如果用戶特別配製系統不創建 $_SERVER,那此變量當然就不存在了。改變的地方是不管 variables_order 怎麽設定,在 CLI 版本中 argc 和 argv 總是可用的。本來 CLI 版不是總會産生全局變量 $argc 和 $argv 的。

沒有屬性的對象不再被當成“empty”.

有些情况下類必須在使用前被定義。這僅在使用了一些 PHP 5 的新特性(例如 interfaces)的時候發生。其它情况下行爲都沒變。

get_class(),get_parent_class() 和 get_class_methods() 如今返回的類/方法名和定義時的名字一致(區分大小寫),對于依賴以前行爲(類/方法名總是返回小寫的)的老脚本可能産生問題。一個可能的解决方法是在脚本中搜索所有這些函數幷使用 strtolower()。

區分大小寫的改變也適用于魔術常量 __CLASS__,__METHOD__ 和 __FUNCTION__.其值都會嚴格按照定義時的名字返回(區分大小寫)。

ip2long() 在傳遞入一個非法 IP 作爲參數時返回 FALSE,不再是 -1.

如果有函數定義在包含文件中,則這些函數可以在主文件中使用而與是否在 return() 指令之前還是之後無關。如果文件被包含兩次,PHP 5 會發出致命錯誤,因爲函數已經被定義,而 PHP 4 不管這個。因此推薦使用 include_once() 而不要去檢查文件是否已被包含以及在包含文件中有條件返回。

include_once() 和 require_once() 在 Windows 下先將路徑規格化,因此包含 A.php 和 a.php 只會把文件包含一次。

實例: strrpos() 和 strripos() 如今用整個字符串作爲 needle

 

實例: 沒有屬性的對象不再被當成“empty”

 

實例: 有些情况下類必須在使用之前定義

 

二、CLI 和 CGI

PHP 5 中對 CLI 和 CGI 文件名作了些改變。PHP 5 中,CGI 版本被改名爲 php-cgi.exe(以前是 php.exe),現在主目錄中的是 CLI 版本(之前是 cli/php.exe)。

PHP 5 中引進了一種新模式:php-win.exe.這和 CLI 版本相同,只除了 php-win 不輸出任何內容,因此不會提供控制臺(屏幕上不會閃過“dos 窗口”)。此行爲類似 php-gtk.

PHP 5 中,CLI 版本總會産生全局變量 $argv 和 $argc 而不管 php.ini 是怎麽設的。即使將register_argc_argv設爲 off 也不影響 CLI.

參見命令行模式。

三、移植配置文件

由于 ISAPI 模塊的名字改了,從 php4xxx 改爲 php5xxx,因此需要對配置文件作些修改。CLI 和 CGI 文件名也改了。更多信息請查看相應章節。

移植 Apache 配置極其簡單。照下面的例子來檢查需要做的修改:

實例: 移植 Apache 配置文件到 PHP 5

# 將下麵這行: LoadModule php4_module /php/sapi/php4apache2.dll # 改成這一行: LoadModule php5_module /php/php5apache2.dll

如果 web 服務器是以 CGI 模式運行 PHP 的,應該注意 CGI 版本的名字從 php.exe 改爲了 php-cgi.exe.在 Apache 中,應該照這樣改:

實例: 移植 Apache 配置文件到 PHP 5,CGI 模式

# 將下麵這行: Action application/x-httpd-php “/php/php.exe” # 改成這一行: Action application/x-httpd-php “/php/php-cgi.exe”

其它的 web 服務器中,需要修改 CGI 或者 ISAPI 模塊的名字。

四、新函數

PHP 5 有了些新函數。下麵是列表:

Arrays:

array_combine() – 用一個數組作爲鍵名,另一個數組作爲值創建一個新數組

array_diff_uassoc() – 計算數組的差別,幷用用戶提供的回調函數作附加的索引檢查

array_udiff() – 用回調函數比較數據來計算數組的差別

array_udiff_assoc() – 計算數組的差別幷作附加的索引檢查。用回調函數來比較數據

array_udiff_uassoc() – 計算數組的差別幷作附加的索引檢查。數據的比較和索引檢查都用回調函數來完成

array_walk_recursive() – 對數組的每個成員遞歸使用用戶函數

array_uintersect_assoc() – 計算數組的交集幷作附加的索引檢查。用回調函數來比較數據

array_uintersect_uassoc() – 計算數組的交集幷作附加的索引檢查。數據和索引都用回調函數來比較

array_uintersect() – 計算數組的交集。用回調函數來比較數據

InterBase:

ibase_affected_rows() – 返回前一個查詢影響到的行的數目

ibase_backup() – 在服務管理器中發起一個後臺任務幷立即返回

ibase_commit_ret() – 提交一個事務但不關閉

ibase_db_info() – 請求有關數據庫的統計信息

ibase_drop_db() – 删除一個數據庫

ibase_errcode() – 返回一個錯誤代碼

ibase_free_event_handler() – 取消一個已注册的事件句柄

ibase_gen_id() – 遞增指定的發生器幷返回其新值

ibase_maintain_db() – 在數據庫服務器上執行一條維護命令

ibase_name_result() – 給結果集指定一個名字

ibase_num_params() – 返回一個準備好的查詢的參數數目

ibase_param_info() – 返回一個準備好的查詢的參數信息

ibase_restore() – 在服務管理器中發起一個還原任務幷立即返回

ibase_rollback_ret() – 回卷一筆事務幷保留事務上下文

ibase_server_info() – 請求有關數據庫服務器的統計信息

ibase_service_attach() – 連接到服務管理器

ibase_service_detach() – 從服務管理器斷開

ibase_set_event_handler() – 注册一個當事件發布時要調用的回調函數

ibase_wait_event() – 等待數據庫發布一條事件

iconv:

iconv_mime_decode() – 解碼 MIME 頭信息字段

iconv_mime_decode_headers() – 一次解碼多個 MIME 頭信息字段

iconv_mime_encode() – 壓縮 MIME 頭信息字段

iconv_strlen() – 返回字符串中的字符計數

iconv_strpos() – 在堆棧中找到第一個出現的子串位置

iconv_strrpos() – 在堆棧中找到最後一個出現的子串位置

iconv_substr() – 從字符串中取出一部分

Streams:

stream_copy_to_stream() – 把一個流的數據複製到另一個流

stream_get_line() – 根據給定的分隔符中流中讀取一行

stream_socket_accept() – 接受一個由 stream_socket_server() 建立的 socket 連接

stream_socket_client() – 打開一個 Internet 或 Unix 域的 socket 連接

stream_socket_get_name() – 獲取本地或遠程的 sockets 名字

stream_socket_recvfrom() – 從 socket 獲取數據(不管連接是否已經建立)

stream_socket_sendto() – 向 socket 發送一個消息(不管連接是否已經建立)

stream_socket_server() – 建立一個 Internet 或 Unix 域服務器的 socket

Date/Time:

idate() – 將本地進間格式化爲整數

date_sunset() – 計算所指定日期和地點的日落時間

date_sunrise() – T計算所指定日期和地點的日出時間

time_nanosleep() – 廷遲執行程若干秒和若干納秒

Strings:

str_split() – 把一個字符串分割爲數組

strpbrk() – 在一字符串中搜索給定的字符集合中的任意一個字符

substr_compare() – 以二進制的形式比較兩個字符串,從第一個字符串的 offset 開始,直到到達長度爲 length 時結束,可自定義是否大小寫敏感比較

Other:

convert_uudecode() – 解碼 uuencoded 的字符串

convert_uuencode() – 對字符串進行 uuencode

curl_copy_handle() – 複製一個 cURL 句柄及其所有參數

dba_key_split() – 把一個鍵分隔爲字符串數組

dbase_get_header_info() – 取得 dBase 數據庫的頭部信息

dbx_fetch_row() – 獲取結果集中被設置爲 DBX_RESULT_UNBUFFERED 的行

fbsql_set_password() – 修改指定用戶的密碼

file_put_contents() – 向一個文件內寫入字符串

ftp_alloc() – 爲準備上傳的文件分配空間

get_declared_interfaces() – 以數組的形式返回所有已定義的接品

get_headers() – 獲取服務器響應 HTTP 請求時的所有頭部信息

headers_list() – 返回所有已發送或準備發送響應頭部列表

http_build_query() – 生成一個已經過 URL 編碼的請求字符串

image_type_to_extension() – 根據 getimagesize(), exif_read_data(), exif_thumbnail(), exif_imagetype() 所返回的 image-type 取得文件名後綴

imagefilter() – 對圖像應用濾鏡

imap_getacl() – 獲取指定郵箱的 ACL

ldap_sasl_bind() – 使用 SASL 綁定到 LDAP 目錄

mb_list_encodings() – 以數組的形式返回所支持的全部字符集

pcntl_getpriority() – 獲得任意一個進程的優先級

pcntl_wait() – Waits on or returns the status of a forked child as defined by the waitpid() system call

pg_version() – 返回一個包含客戶端、協議和服務器版本的數組

php_check_syntax() – 檢查指定文件的語法

php_strip_whitespace() – 返回已經去除注釋和空白的源代碼

proc_nice() – 修改當前進程的優前級

pspell_config_data_dir() – 修改語言文件的位置

pspell_config_dict_dir() – 修改主要單詞列表的位置

setrawcookie() – 發送一個沒有經過 url 編碼的 cookie 值

scandir() – 列中指定目錄中的所有子目錄和文件

snmp_read_mib() – 在一個可用的 MIB 樹中讀取和分板一個 MIB 文件

sqlite_fetch_column_types() – 以數組的形式返回一張表中的列類型

注意: Tidy 擴展庫的 API 也作了重大調整

五、新指令

PHP 5 在 php.ini 中引進了一些新指令。列表如下:

mail.force_extra_parameters – 强制指定的參數附加值作爲額外的參數傳遞給 sendmail 庫。這些參數總是會替換掉 mail() 的第 5 個參數,即使在安全模式下

register_long_arrays – 允許/禁止 PHP 注册已過時的 $HTTP_*_VARS 變量

session.hash_function – 選擇一種散列函數(MD5 或 SHA-1)

session.hash_bits_per_character – 定義將二進制散列數據轉換爲可讀格式時每個字符中儲存幾個位(從 4 到 6)

zend.ze1_compatibility_mode – 啓用 Zend Engline 1 代(PHP 4)兼容模式

六、數據庫

關于數據庫(MySQL 和 SQLite)在 PHP 5 中有些改變。

PHP 5 中不再綁定 MySQL 客戶端連接庫,因爲授權和一些其它問題。

有個新擴展庫 MySQLi(改良版 MySQL),設計用來工作于 MySQL 4.1 及更高版本之下。

自 PHP 5 起,SQLite 擴展庫內置在 PHP 中。SQLite 是一個可嵌入 SQL 數據庫引擎,不是客戶端連接庫用來連接大型數據庫服務器(如 MySQL 或 PostgreSQL)的。SQLite 庫直接讀寫磁盤上的數據庫文件。

七、新對象模型

PHP 5 中有個新對象模型(Object Model)。PHP處理對象的方式完全重寫了,允許更佳性能和更多特性。之前版本的 PHP,對象處理方式和原始類型(例如整型和字符串)相同。此方法的缺點是當變量被賦值或作爲參數傳遞給方法時語義上整個對象都被拷貝。在新方法中,對象通過句柄引用,而不是值(可以將句柄當成是對象的標識符)。

很***a href=.itwis.com/html/php’>PHP程序員根本沒意識到舊的對象模型的這種拷貝怪癖,因此大多數PHP應用程序拿來就能運行,或者只做很小的修改。

新對象模型的文檔見“類與對象”.

========================

Difference with  PHP5 and PHP4

One , not 100% backwards compatible

Although most of the php5 in PHP4 code should be able to run without modification , or should be aware of the following changes are not backward compatible :

With some new keywords.

strrpos () and strripos () now use the entire string as a needle.

Illegal use of string offsets causes E_ERROR instead of E_WARNING example of an illegal use : $ str = ‘abc’; unset ($ str [0]);..

array_merge () was changed to accept only arrays. If passed into non- array variable , issue a E_WARNING message for each of these parameters are . Be careful because your code may be issued crazy E_WARNING.

PATH_TRANSLATED server variable in Apache2 SAPI is no longer secretly set , and PHP 4 in this case the contrary, if Apache does not produce this value then the SCRIPT_FILENAME server variable is set and the same value . This change was made to comply with the CGI specification. For more information reference manual $ _SERVER [‘PATH_TRANSLATED’] description . This problem also affects PHP> = version 4.3.2 .

Tokenizer extension is no longer defined T_ML_COMMENT constant. If error_reporting set to E_ALL, PHP will generate a message. Although T_ML_COMMENT never used before, or defined in PHP 4 it. In PHP 4 and PHP 5 / / and are resolved to T_COMMENT constant. But PHPDoc style comments , starting PHP 5 are parsed by PHP , are identified as T_DOC_COMMENT.

If variables_order including “S”, $ _SERVER should be generated with argc and argv . If the user does not create a system specially formulated $ _SERVER, then of course it would not exist. Variables_order change is that no matter how local settings, CLI version argc and argv are always available. CLI version will always produce the global variables $ argc and $ argv ‘s .

Object with no properties is no longer considered “empty”.

In some cases classes must be defined before use. It is only in use for some of the new features of PHP 5 ( such as interfaces) occurs when . Other circumstances have not changed behavior .

get_class (), get_parent_class () and get_class_methods () now returns the class name and the name of the method of definition / agreement ( case-sensitive ) , rely on the previous behavior ( class / method name always returns lowercase ) old scripts may cause problems . One possible solution is to search all of these functions in the script Bing use strtolower ().

Case-sensitive change also applies to the magic constant __CLASS__, __METHOD__ and __FUNCTION__. Whose values ​​are in strict accordance with the definition of the name returned ( case-sensitive ) .

ip2long () when passed into an illegal IP as an argument returns FALSE, instead of -1 .

If there are functions defined in the included file, regardless of whether these functions can be irrelevant before or after return () instruction in the main file . If the file is included twice , PHP 5 issues fatal error because functions were already declared , while PHP 4 does this . Therefore recommended to use include_once () instead of going to check whether the file was already included and conditionally return inside the included file.

include_once () and require_once () in the Windows path first standardized, and therefore contains A.php and a.php the file contains only once .

Examples : strrpos () and strripos () now use the entire string as a needle

 

Example: object with no properties is no longer considered “empty”

 

Example: In some cases classes must be defined before use

 

Two , CLI and CGI

PHP 5, the CLI and CGI files masterpieces for some change. In PHP 5 , CGI version was renamed to php-cgi.exe ( previously php.exe), now home directory is the CLI version (previously cli / php.exe).

PHP 5 introduced a new model in : php-win.exe This CLI version of the same , except that php-win does not output anything , it does not provide console ( not flashed “dos window ” on the screen ) . This behavior is similar to php-gtk.

In PHP 5 , CLI version will always produce the global variable $ argv and $ argc regardless of how the set of php.ini . Even if register_argc_argv set off does not affect the CLI.

See the command line mode.

Third, the transplant profile

Since the ISAPI module to change the name from php4xxx to php5xxx, and therefore need to make some changes to the configuration file . CLI and CGI filenames have changed. For more information , please see the appropriate section.

Porting Apache configuration is extremely simple. See the example below to check needs to be done to modify :

Example: Transplant Apache configuration file to PHP 5

# The following line : LoadModule php4_module / php/sapi/php4apache2.dll # change this line : LoadModule php5_module / php/php5apache2.dll

If the web server is running PHP in CGI mode , you should pay attention to the CGI version of the name from php.exe to php-cgi.exe in Apache , you should change as such :

Example: Transplant Apache configuration file to PHP 5, CGI mode

# The following line : Action application / x-httpd-php “/ php / php.exe” # change this line : Action application / x-httpd-php “/ php / php-cgi.exe”

Other web servers , the need to modify the CGI or ISAPI module name .

Fourth, the new function

PHP 5 has some new functions. Here is a list :

Arrays:

array_combine () – with an array as keys , another array as the value of creating a new array

() array_diff_uassoc – the difference between an array of computing , Bing additional index check with the user-supplied callback function

() array_udiff – the difference between using a callback function to calculate the array comparative data

array_udiff_assoc () – Computes the difference of arrays with additional index check Bing . Using a callback function to compare the data

array_udiff_uassoc () – Computes the difference of arrays with additional index check Bing . Comparison of the data and index checks are done using a callback function

array_walk_recursive () – for each member of the array using a user function recursively

array_uintersect_assoc () – the intersection of arrays with additional index of Bing checks . Using a callback function to compare the data

array_uintersect_uassoc () – the intersection of arrays with additional index of Bing checks . Data and indexes are compared by using a callback function

array_uintersect () – to calculate the intersection of arrays . Using a callback function to compare the data

InterBase:

The number before returning a query affected rows – ibase_affected_rows ()

ibase_backup () – initiate a background task in the service manager immediately returned Bing

ibase_commit_ret () – commits a transaction without closing

ibase_db_info () – Request statistics about a database

ibase_drop_db () – delete a database

ibase_errcode () – returns an error code

ibase_free_event_handler () – Cancels a registered event handler

ibase_gen_id () – increments specified generator Bing returns its new value

ibase_maintain_db () – on the database server to perform a maintenance command

ibase_name_result () – assign a name to a result set

ibase_num_params () – Returns the number of parameters in a prepared query

ibase_param_info () – Returns a prepared query parameter information

ibase_restore () – initiate a restore task in the service manager immediately returned Bing

ibase_rollback_ret ​​() – Rewind the context of a transaction Bing reserved Affairs

ibase_server_info () – Request statistics about a database server

ibase_service_attach () – connect to the service manager

ibase_service_detach () – Disconnect from the service manager

ibase_set_event_handler () – Register a callback function to be called when the event is published

ibase_wait_event () – Wait for the database publishing an event

iconv:

iconv_mime_decode () – decode MIME header field

iconv_mime_decode_headers () – once decode multiple MIME header field

iconv_mime_encode () – Compression MIME header field

iconv_strlen () – Returns the string character count

iconv_strpos () – find the first occurrence of the substring position in the stack

iconv_strrpos () – find the position of the last occurrence of a substring in the stack

iconv_substr () – Remove a portion from a string

Streams:

stream_copy_to_stream () – Copy data from one stream to another stream

stream_get_line () – read a line of a given flow in the separator

stream_socket_accept () – accepts consisting stream_socket_server () establish a socket connection

stream_socket_client () – Open an Internet connection or socket Unix domain

stream_socket_get_name () – Get the name of a local or remote sockets

stream_socket_recvfrom () – retrieve data from socket ( regardless of whether the connection has been established )

stream_socket_sendto () – Send a message to the socket ( regardless of whether the connection has been established )

stream_socket_server () – to establish an Internet or Unix domain server socket

Date / Time:

idate () – Format a local into an integer between

date_sunset () – to calculate the date and place specified in the Sunset

date_sunrise () – T is calculated by a specified date and place of the sunrise time

time_nanosleep () – Several Ting Chi Cheng seconds and perform a number of nanoseconds

Strings:

str_split () – put a string into an array

strpbrk () – in a search string in a given character set of any one character

substr_compare () – in binary form to compare two strings , the first string from offset start until the end when it reaches a length of length , you can customize whether the comparison is case sensitive

Other:

convert_uudecode () – decoding uuencoded string

convert_uuencode () – uuencode strings

curl_copy_handle () – Copy a cURL handle all its parameters

dba_key_split () – put a delimited string array

dbase_get_header_info () – get the header information dBase database

dbx_fetch_row () – Get the result set rows are set to DBX_RESULT_UNBUFFERED

fbsql_set_password () – modify the specified user’s password

file_put_contents () – write a string to a file

ftp_alloc () – allocate space for files uploaded to prepare

get_declared_interfaces () – Returns an array of all defined access products

get_headers () – get the server to respond to all HTTP request headers when

headers_list () – Returns a list of all the response has been sent or is ready to send the head

http_build_query () – has been generating a URL -encoded query string

image_type_to_extension () – According to getimagesize (), exif_read_data (), exif_thumbnail (), exif_imagetype () which returns the image-type get filename suffix

imagefilter () – apply a filter to the image

imap_getacl () – Gets the specified mailbox ACL

ldap_sasl_bind () – Bind to LDAP directory using SASL

mb_list_encodings () – Returns an array of all character sets are supported

pcntl_getpriority () – get any priority of a process

pcntl_wait () – Waits on or returns the status of a forked child as defined by the waitpid () system call

pg_version () – Returns an array of client and server versions of the agreement included

syntax check of the specified file – php_check_syntax ()

php_strip_whitespace () – Returns comment has been removed and a blank source code

proc_nice () – modify the current process of gifted pre-

Location modify the language file – () pspell_config_data_dir

modify the position of the main word list – () pspell_config_dict_dir

setrawcookie () – Send a cookie without url encoded value

scandir () – column specified directories and files in all subdirectories

snmp_read_mib () – available in a MIB tree, and the scoreboard read a MIB file

sqlite_fetch_column_types () – Returns an array of the type of a table column

Note : Tidy extension repository API also made significant adjustments

Fifth, the new directive

PHP 5 introduced some new directive in php.ini . List is as follows :

mail.force_extra_parameters – Forced specified parameters passed to sendmail library added as an additional parameter. These parameters will always replace the mail () in the first five parameters , even in safe mode

register_long_arrays – enable / disable PHP registered obsolete variable $ HTTP_ * _VARS

session.hash_function – Select a hash function (MD5 or SHA-1)

session.hash_bits_per_character – define each character will be stored in several binary bit hash data into a readable format ( from 4-6 )

zend.ze1_compatibility_mode – Enable Zend Engline 1 generations (PHP 4) compatibility mode

Sixth, the database

About Database (MySQL and SQLite) some changes in PHP 5 .

PHP 5 no longer bundles MySQL client library , as authorized , and some other problems.

There under in MySQL 4.1 and later new extensions MySQLi ( improved version of MySQL), is designed to work one .

Since PHP 5 , SQLite extensions built- in PHP. SQLite is an embeddable SQL database engine , not a client library used to connect to a large database server ( such as MySQL or PostgreSQL) ‘s . SQLite library to read and write directly to the database files on disk.

Seven new object model

There is a new PHP 5 object model (Object Model). PHP way of handling objects completely rewritten , allowing for better performance and more features . Prior versions of PHP, objects were handled like primitive types ( such as integers and strings ) the same . The disadvantage of this method is that when a variable is assigned or as the whole object parameter passed to the method are copy semantics. In the new method, the object referenced by the handle , not the value ( as is the identifier can handle objects ) .

It *** a href = .itwis.com / html / php ‘> PHP programmer did not realize this copy quirks old object model, so most will be able to run PHP applications used , or only very minor modifications .

See the document ” object class ” new object model.

Openvz和Xen的技術規格分析

Openvz和Xen的技術規格分析

一、Openvz和Xen的技術規格分析
1.Xen與Openvz的區別
Xen和Openvz同樣是虛擬化主機技術,區別在于Xen是半虛擬化技術,它幷不是一個真正的虛擬機,而是相當于自己運行了一個內核的實例,可以自由的加載內核模塊,虛擬的內存和IO,穩定而且可預測。Openvz則是操作系統級別的虛擬化技術,是底層操作系統上的一層應用,這意味著易于理解和低權重開銷,一般來說也意味著更優的性能。
這裏有一個問題,可以看到實際上openvz因爲免去了大量的公共開銷,理論上來說性能會比xen更好。爲什麽大家都會認爲openvz過分壓榨性能呢?我認爲是因爲openvz配置起來比較靈活,給黑心 openvz服務商改低限制的機會。
比如mediatemple,號稱512M內存的dv方案,kmemsize才12M,不瞭解的人看了512M覺得很哈皮啊,可是使用的時候一般這512M能分到你手裏一半就不錯了。此消彼長,所以才會有xen 能更好地利用機器性能的錯覺。
2.Openvz的內核模型
首先當OpenVZ的主機說“256MB的保證”,它實際上意味著約232MB的“privvmpages”,14M的“kmemsize”和其他雜項資源。當應用程序調用 malloc()分配的內存將被添加到“privvmpages”。
當“privvmpages”超過限制,malloc()將失敗幷返回一個NULL。當主機服務器內存用光了,然後虛擬環境下的進程超過 “oomguarpages”的將被終止。
OpenVZ的內存管理方法既有問題也有優勢。最大的問題之一是內存容量的應用程序使用的內存和應用程序實際上分配到的內存是不同的,不同的應用程序他們的差別可能會很大。以Java爲例,它通常分配一大塊的內存,但是,它可能只使用一小部分分配的內存。如果privvmpages受限,java會立即停止運行。調整參數可以解决一部分問題,但它處理得絕對沒有Xen來得乾淨利落。事實上,幾乎所有使用內存分配的應用程序都會受OpenVZ這個問題的影響。
/proc/meminfo 本身也有問題。雖然OpenVZ的已經爲內存進行了虛擬,但是用”free”命令依然會返回主機的內存。這樣就會使小內存的openvz的vps無法運行諸如java或者gcc編譯這樣的程序。
OpenVZ的內存模型的優點是, 它容易理解: 你幾乎就只有privvmpages受限。與專用的服務器或Xen的服務器不一樣的是,你的磁盤高速緩存和頁面緩存幷不計入您的總內存使用情况。因此,在一個沒有過度銷售的openvz主機上,由于擁有較大冗余的公共資源,它實際上可能會比同類規格的Xen的VPS表現更佳。
3.Xen的內存模型
Xen的系統模型更容易解釋。256MB的Xen的VPS是就像一個256MB的專用服務器-該內存段是預留作VPS專用,沒有其他VPS能够使用這部分內存,這就像一個真正的專用服務器。
此外,當內存不足時,VPS會使用Swap。一般每個VPS帶有兩倍大小的交換分區,當您的應用需要更多的內存,不常使用的頁面從內存中被換出到交換分區,從而騰出使更多的房間。因此,256MB的Xen的VPS系統實際上共有768MB內存(256MB內存+ 512MB的交換空間),請相信我,交換空間是非常有用的,特別是處理突發的需求高峰時。
這麽說來,Xen是永遠遠優于OpenVZ?不然,你的256MB的VPS理論可以使用高達768MB內存,而實際上內核,高速緩存,緩衝,他們都占用內存。這部分系統開銷也是可觀的。另外,Swap會嚴重降低性能。
4.穩定性和可預測性
當內存耗盡時,xen和openvz表現大相徑庭。xen會把不常用的內存頁面換入Swap,這將大大降低性能,當Swap也用盡,那麽xen的系統會響應得越來越慢,就像一台真實的服務器一樣。
而openvz一旦內存用盡,則會突然死亡:開不出新的程序,只能等待系統資源可用。更有甚者,本來運行的好好的程序也可能因爲不斷增長而超過限制,然後突然死亡。這就像開車開到70碼,然後突然撞墻上了,一般會死得很慘。
毫無疑問這點上我傾向于xen技術,可預測,穩定。
5.結論
如果xen和openvz一樣貴,我肯定選xen,因爲可預測性,即使openvz打8折,我還是追求穩定。
上面的話總結一下,得出幾個結論:
1、XEN比openvz主機對買家更有利,比如分配給你512M內存後,這一部分內存就從服務器上專門劃給你了,別人將無法使用,而openvz則是共用內存,比如分配給你512M內存是指最大你能使用512M內存,比如你占用了200M內存,那麽就只從物體內存中分配200M給你,所以賣家非常容易在服務器上面超賣!
2、openvz更高效,xen是硬件底層虛擬,更接近真實服務器,而openvz是操作系統虛擬,虛擬服務自身占用內存少,同樣的程序執行效率更高!
3、如果購買openvz應看賣家是否會超賣,應選擇良好聲譽明確申明不會超賣的
4、如果購買xen主機,應同時關注swap大小
5、測試VPS主機性能使用Unixbench(很多人不知道),國外非常流行這個東西!
這是它的一些參數說明
• dhry2reg 內存的register性能
• whetstone-double 雙精度浮點性能
• execl execl call性能
• fstime 文件系統性能
• fsbuffer 文件系統性能
• fsdisk 文件系統性能
• pipe 管道(pipe)的性能
• context1 管道上下文切換的性能
• spawn 創建進程的性能
• shell shell幷發性能
• syscall 系統調用性能
6、VPS用途:服務器、軟交換、代理和反向代理、離綫BT下載等等
7.通常一般的使用條件下,兩者性能應該相差不大。

===============================

Openvz and Xen technical specifications analysis
The difference 1.Xen with Openvz
Xen and Openvz same mainframe virtualization technology , the difference is that Xen paravirtualization technology that Bing is not a true virtual machine , but the equivalent of running its own instance of a kernel , kernel modules can be loaded free virtual memory and IO, stable and predictable . Openvz is operating system -level virtualization technology, is a layer of applications on the underlying operating system , which means easy to understand and a low weight overhead , generally means better performance .
There is a problem , because you can see that in fact openvz eliminates a lot of public spending , in theory, the performance will be better than xen. Why do we all think too much press openvz performance? I think it is because it is more flexible openvz configuration , change to black heart openvz service providers the opportunity to lower limits .
For example mediatemple, known as 512M of memory dv program , kmemsize only 12M, 512M think people do not understand looked very Happy ah , but it is generally used in this 512M half could be assigned to your hand pretty good . Shift, so will have to make better use xen machine performance illusion.
2.Openvz core model
First, when the OpenVZ host says “256MB of guarantee” , it actually means about 232MB of “privvmpages”, 14M of “kmemsize” and other miscellaneous resources. When an application calls malloc () allocated memory will be added to the “privvmpages”.
When “privvmpages” over the limit , malloc () will fail Bing returns a NULL. When the host server memory runs out , then the process of virtual environments over “oomguarpages” will be terminated.
OpenVZ memory management methods have the advantage of both problems . One of the biggest problems is the memory and application memory capacity actually used by the application is assigned to a different memory , different applications can be significant differences between them . In Java , for example, it usually allocates a chunk of memory, however, it may use only a fraction of the allocated memory. If privvmpages limited , java will immediately stop running. Adjustment parameters can solve part of the problem , but it is absolutely no Xen handled more cleanly . In fact, almost all applications use memory allocation will affect this problem by OpenVZ .
/ proc / meminfo itself a problem. While OpenVZ has been carried out for the virtual memory , but with a “free” command will still be returned to the host memory. This will make the vps openvz small memory can not run as java or gcc compiler such procedures .
Advantages OpenVZ memory model is that it is easy to understand : you can almost only privvmpages limited. With a dedicated server or Xen server is not the same as your disk cache and page cache Bing does not count toward your total memory usage. Therefore, on a no overselling the openvz host , as has a large redundant public resources , it may actually perform better than the Xen VPS similar specifications .
3.Xen memory model
Xen system model is more easily explained. The Xen VPS 256MB 256MB is like a dedicated server – the memory segment is reserved for dedicated VPS , no other VPS to use this part of the memory , it’s like a real dedicated server.
In addition, when there is insufficient memory , VPS will use the Swap. Generally speaking, each VPS has twice the size of the swap partition , if your application requires more memory , infrequently used pages from memory to be swapped out to the swap partition, thus freeing make more room. Therefore , 256MB of Xen VPS system is actually a total of 768MB of RAM (256MB RAM + 512MB swap space ) , believe me , swap space is very useful , especially when you deal with sudden spikes in demand .
So to say , Xen is always much better than OpenVZ? Otherwise , you can use the VPS theory 256MB up to 768MB of memory , but in fact the core , the cache buffer memory for all of them . This part of the overhead is also considerable. Further , Swap seriously degrade performance .
4 . Stability and predictability
When memory is exhausted , xen and openvz performance to differ materially . xen will not commonly used memory pages swapped Swap, which will greatly reduce performance when Swap are exhausted , then the system will respond xen increasingly slowly, like a real server.
And openvz memory exhaustion once , then sudden death : not to open a new program , can only wait for the system resources are available . What is more , had to run the program may also be because of the continuing good growth over the limit , then sudden death. It’s like drove 70 yards, then suddenly hit the wall on the general will die miserable .
There is no doubt on this point I tend xen technology , predictable and stable.
5 Conclusion
If xen and openvz as expensive , I’m sure choose xen, because predictability, even openvz hit 8-fold , I still pursue stable.
To summarize the above , then , leads to several conclusions :
1, XEN host to buyers than openvz more favorable , such as 512M of memory allocated to you after this part of the memory on the server from scratch specifically to you , others will not be able to use , and openvz is shared memory , such as allocated to you 512M RAM is the maximum you can use 512M memory, for example, you take up a 200M memory , then only allocate 200M to you from the object memory, so the seller is very easy on the server above oversold !
2, openvz more efficient , xen underlying virtual hardware , closer to the real server, and virtual openvz operating system , virtual service itself occupies less memory and higher efficiency the same procedure !
3 , if the purchase openvz should see if the seller will oversold , you should choose a good reputation does not expressly stated oversold
4 , if the purchase xen host , should also concern swap size
5, the test VPS host performance using Unixbench ( many people do not know ) , this thing is very popular abroad !
This is a description of some of its parameters
• dhry2reg register memory performance
• whetstone-double double- precision floating-point performance
• execl execl call performance
• fstime file system performance
• fsbuffer file system performance
• fsdisk file system performance
• pipe conduit (pipe) performance
Performance • context1 pipeline context switching
• spawn the process to create performance
• shell shell Bing hair Performance
• syscall system call performance
6, VPS uses: server , softswitch , agents and reverse proxy , offline BT download , etc.
7 usually under normal conditions of use, performance should be little difference between the two .

CentOS安裝OpenVZ和Vtonf控制面板

CentOS安裝OpenVZ和Vtonf控制面板

現在虛擬化技術非常流行,本文介紹基于OpenVZ平臺下的虛擬化配置安裝,以及Vtonf Web界面管理虛擬機應用。
本文爲簡易指導手册,代碼不保證100%準確。本文根據英文教程創作演繹。
一、安裝OpenVZ
1、第一次在CentOS中添加openVZ repository
打開終端複製以下命令
wget http://download.openvz.org/openvz.repo
rpm –import http://download.openvz.org/RPM-GPG-Key-OpenVZ
cp openvz.repo /etc.recpo.d
2、安裝openvz內核
yum install ovzkernel
3、編輯文件 /etc/systcl.conf
打開文件 /etc/systcl.conf
vi /etc/systcl.conf
添加以下內容:
net.ipv4.ip_forward = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.rp_filter = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
4、禁止Selinux
禁止Selinux,打開配置文件
vi /etc/selinux/config
找到以下內容,將SELINUX設置成disabled,如下所設:
SELINUX=disabled
5、安裝openvz工具和插件
yum install vzctl vzquota
6、重啓openv服務
service vz restart
二、建立虛擬操作系統
現在,我們已經安裝好了Openvz,馬上去建立一個虛擬操作系統吧。首先下載一下操作系統模板。
本例將使用Slackware模板,其它的操作系統模板你可以查看這裏
1、首先建立和進入cache文件夾,本例如下:
mkdir -p /vz/template/cache
cd /vz/template/cache
2、接下來是下載模板
這個步驟可能會花去你很多時間,視網絡狀况,現在你可以瀏覽一下OSSS.CN開源社區,呵呵:
wget http://download.openvz.org/template/precreated/contrib/slackware-13.0-i386-minimal.tar.gz
下載屏幕如下列所示:
[root@localhost cache]# wget http://download.openvz.org/template/precreated/contrib/slackware-13.0-i386-minimal.tar.gz
–2010-06-27 16:55:33– http://download.openvz.org/template/precreated/contrib/slackware-13.0-i386-minimal.tar.gz
Resolving download.openvz.org… 64.131.90.11
Connecting to download.openvz.org|64.131.90.11|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 39641862 (38M) [application/x-gzip]
Saving to: `slackware-13.0-i386-minimal.tar.gz’
100%[===============================================================>] 39,641,862 4.48M/s in 14s
2010-08-09 16:55:47 (2.71 MB/s) – `slackware-13.0-i386-minimal.tar.gz’ saved [39641862/39641862]
3、建立虛擬機
假如虛擬機名爲:VPS ossscn
vzctl create ossscn –ostemplate slackware-13.0-i386-minimal –config basic
屏幕輸出:
Creating container private area (slackware-13.0-i386-minimal)
Performing postcreate actions
Container private area was created
4、設置虛擬機
[root@localhost cache]# vzctl set ossscn –onboot yes –saveSaved parameters for CT 102make a Hostname for The machien:vzctl set 102 –hostname Hackers.example.com –saveGive Ip adress 192.168.0.130 to the machine:
[root@localhost cache]# vzctl set 102 –ipadd 192.168.0.130 –saveSaved parameters for CT 102
[root@localhost cache]#
5、啓動虛擬機ossscn
vzctl start
屏幕輸出:
ossscn Starting container …Container is mountedAdding IP address(es): 192.168.0.130Setting CPU units: 1000Set hostname: Hackers.example.comContainer start in progress..
6、設置Root密碼
vzctl exec ossscn passwd
New password: 123456
Re-enter new password: 123456
Changing password for root
Enter the new password (minimum of 5, maximum of 127 characters)Please use a combination of upper and lower case letters and numbers.Password changed
7、進入slackware虛擬機ossscn
vzctl enter 102
屏幕輸出:
entered into CT ossscn
root@Hackers:/# cat /etc/slackware-version
Slackware 13.0.0.0.0
Stop of start or Exit
More commands :
To restart use : vzctl restart
To stop use : vzctl stop
to destroy the vm machine user : vzctl destro ossscn
For more commands use :vzctl -help
三、爲OpenVZ安裝Vtonf Web管理界面
VTONF是虛擬機控制面板,專門爲GNU/Linux中運行OpenVZ虛擬機技術設計。VTONF是基于GPL許可證下發布的自由軟件。
1、安裝Vtonf
打開終端,輸入以下命令,不要忘記將vtonf版本vtonfinstaller.x.x-beta1.tar.gz中的x改爲你下載的版本。
cd /tmp
wget http://mesh.dl.sourceforge.net/sourceforge/vtonf/vtonfinstaller.x.x-beta1.tar.gz
tar xvfz vtonfinstaller.1.0-beta1.tar.gz
cd vtonfinstaller.x.x-beta1
./install
當Vtonf控制面板安裝完成,你可以登陸系統:
http://192.168.0.109:8001/
用戶名 : admin
密碼 : admin

Windows2003 端口映射 至 VMware中的Linux

Windows2003 端口映射 至 VMware中的Linux

搞了三天的主機設定,終於解決了.
工作環境如下
實體主機:Windows2003
在實體主機中安裝VMware 架設CentOS
期望目標:透過Windows2003的端口映射(NAT)功能,讓外部可以訪問到VMware中的Linux.

相關教學請參考
1.http://windows.chinaitlab.com/accessing/725233_3.html
2.http://www.docin.com/p-1489533.html
3.http://wenku.baidu.com/view/0c9181f09e314332396893e2.html

網路很多教學,都可以實現成功,但我這邊要說一個我卡了三天的問題.
這三天一直失敗,外網一直無法訪問到CentOS.
後來說發現錯誤就錯在, CentOS的網路設定, 它的GateWay設定要跟VMnet8的IP是一樣的!!!

假設你的VMnet8 IP位置是:192.168.200.1
那你CentOS中的GateWay就要填寫192.168.200.1, 不要填192.168.200.0或192.168.200.2

這樣絕對會失敗!這樣絕對會失敗!這樣絕對會失敗!這樣絕對會失敗!這樣絕對會失敗!這樣絕對會失敗!

這是我用三天血和淚換來的經驗,千萬要記住.

免費的日本VPN服務 突破防火牆的封鎖(破解公司、宿網的限制!)

免費的日本VPN服務 突破防火牆的封鎖(破解公司、宿網的限制!)

前篇文章在CentOS 安裝 OpenVPN 指南有提到在Linux上安裝VPN來突破防火牆封鎖,
但現行上不一定有空閒的Linux主機或是線路可以來自己架設VPN,
這時使用現有的免費VPN軟體也是滿不錯的選擇.
現在來推薦一款由日本提供的VPN軟體.

1.
下載與安裝
http://www.packetix.net/en/secure/install
軟體下載後直接安裝就可以,不用註冊會員,瘋狂下一步就OK.

2.
設定VPN
http://www.packetix.net/en/secure/secure.vpn
下載上面這個設定檔,下載完後執行,會將VPN設定自動導入

ok.到目前為止已經完全設定完畢了!接下來準備連上VPN.

注意在第一次連接時,會安裝虛擬VPN網卡驅動。就像是新安裝了一個網卡一樣。
所有的網路通訊,就都由這個新的虛擬網卡負責了(這也是為什麼能夠突破公司網管或是宿網的限制)。

3.快樂上網

Apache mod dosevasive 防止DDOS模組

Apache mod dosevasive 防止DDOS模組

林子大了,什麼鳥都有.
目前最常見的網站攻擊方式就是DDOS. 什麼是DDOS?
「分散式拒絕服務(DDoS:Distributed Denial of Service)攻擊指借助于客戶/伺服器技術,將多個電腦聯合起來作為攻擊平臺,對一個或多個目標發動DoS攻擊,從而成倍地提高拒絕服務攻擊的威力。通常,攻擊者使用一個偷竊帳號將DDoS主控程式安裝在一個電腦上,在一個設定的時間主控程式將與大量代理程式通訊,代理程式已經被安裝在Internet上的許多電腦上。代理程式收到指令時就發動攻擊。利用客戶/服務器技術,主控程式能在幾秒鐘內啟動成百上千次代理程式的運行。」

滿多網站架設好後出現速度和效率不理想,這時你就要分析是不是被DDOS了?
然而Apache有提供這個模組使用,方法是比較陽春,他會判斷一個IP在幾秒內訪問幾次,超過一定的限度就封鎖這個IP.
快來看看怎麼裝吧~~~

1. 先到官網下載最新模組
http://www.zdziarski.com/blog/wp-content/uploads/2010/02/mod_evasive_1.10.1.tar.gz
2. 解壓
tar -xzvf mod_dosevasive.版本.tar.gz
3. 切換到該目錄
cd mod_dosevasive
4.
如果Apache版本是v1.3, 執行 apache路徑/bin/apxs -i -a -c mod_dosevasive.c
EX:
/usr/local/apache/bin/apxs -i -a -c mod_dosevasive.c
如果Apache版本v2.0, 直行 apache目錄/bin/apxs -i -a -c mod_dosevasive20.c
EX:
/usr/local/apache/bin/apxs -i -a -c mod_dosevasive20.c
5. 安裝完畢, Restart apache.
6. 將模組加至apache:
LoadModule dosevasive20_module modules/mod_dosevasive20.so

設定(非必需):
修改 /etc/httpd/conf/httpd.conf

Apache v1.3版
<IfModule mod_dosevasive.c>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
</IfModule>

Apache v2.0 版本:
<IfModule mod_dosevasive20.c>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
</IfModule>

設定檔說名:

DOSHashTableSize 3097 記錄和存放黑名單的哈西表大小,如果伺服器訪問量很大,可以加大該值
DOSPageCount 2 同一個頁面在同一時間內可以被 同一個用戶訪問的次數,超過該數字就會被列為攻擊,同一時間的數值可以在DosPageInterval參數中設置。
DOSSiteCount 50 同一個用戶在同一個網站內可以同時打開的訪問數,同一個時間的數值在DOSSiteInterval中設置。
DOSPageInterval 1 設置DOSPageCount中時間長度標準,預設值為1。
DOSSiteInterval 1 設置DOSSiteCount中時間長度標準。
DOSBlockingPeriod 10 被封時間間隔秒,這中間會收到 403 (Forbidden) 的返回。