CentOS´î½¨webЧÀÍÆ÷µÄÊý¾Ý¿âÑ¡ÔñÓëÉèÖý¨Òé
centos´î½¨webЧÀÍÆ÷µÄÊý¾Ý¿âÑ¡ÔñÓëÉèÖý¨Òé
¸ÅÊö£º
ÔڴWebЧÀÍÆ÷ʱ£¬Êý¾Ý¿âµÄÑ¡ÔñÓëÉèÖÃÊǺÜÊÇÖ÷ÒªµÄÒ»»·¡£±¾ÎĽ«ÏÈÈÝÔÚCentOSϵͳÉϴWebЧÀÍÆ÷ʱ£¬ÔõÑùÑ¡ÔñºÏÊʵÄÊý¾Ý¿â£¬²¢¸ø³öÏìÓ¦µÄÉèÖý¨Ò顣ͬʱ£¬»¹»áÌṩһЩ´úÂëʾÀý£¬ÒÔ×ÊÖú¶ÁÕ߸üºÃµØÃ÷È·ºÍ²Ù×÷¡£
Ñ¡ÔñÊý¾Ý¿â£º
ÔÚÑ¡ÔñÊý¾Ý¿âʱ£¬Ó¦Æ¾Ö¤×ÔÉíÐèÇóºÍÏîÄ¿ÌصãÀ´¾öÒé¡£³£¼ûµÄÊý¾Ý¿âÓÐMySQL¡¢PostgreSQL¡¢OracleµÈ¡£MySQLÊÇÒ»¸öÃâ·ÑµÄ¿ªÔ´¹ØϵÐÍÊý¾Ý¿â£¬ÆÕ±éÓ¦ÓÃÓÚWeb¿ª·¢ÖС£PostgreSQLÊÇÒ»ÖÖÇ¿Ê¢µÄ¿ªÔ´¹¤¾ß¹ØϵÊý¾Ý¿âϵͳ£¬±»Ðí¶àÆóÒµ¼¶Ó¦ÓÃËù½ÓÄÉ¡£OracleÊÇÒ»ÖÖÉÌÒµ¼¶µÄÊý¾Ý¿â£¬ÒÔÆä¸ßÐÔÄܺͿɿ¿ÐÔÖøÃû¡£Æ¾Ö¤ÏîÄ¿¹æÄ£ºÍÐÔÄÜÐèÇó£¬Ñ¡ÔñÊʺÏ×Ô¼ºµÄÊý¾Ý¿âÊÇÖÁ¹ØÖ÷ÒªµÄ¡£
ÉèÖý¨Ò飺
ÎÞÂÛÑ¡ÔñÄÄÖÖÊý¾Ý¿â£¬¶¼ÐèÒª¾ÙÐÐÏìÓ¦µÄÉèÖá£ÏÂÃæ¸ø³öÔÚCentOSϵͳÉϴMySQLÊý¾Ý¿âºÍPostgreSQLÊý¾Ý¿âµÄÉèÖý¨æźʹúÂëʾÀý¡£
MySQLÊý¾Ý¿âÉèÖãº
MySQLµÄÉèÖÃÎļþλÓÚ/etc/my.cnf¡£Ê×ÏÈ£¬ÐèÒªÐÞ¸ÄÒÔϲÎÊý£º
bind-address = 127.0.0.1 # °ó¶¨IPµØµã£¬ÕâÀïÉèÖÃΪÍâµØ»Ø»·µØµã
port = 3306 # ¼àÌý¶Ë¿Ú£¬Ä¬ÒÔΪ3306
max_connections = 500 # ×î´óÅþÁ¬Êý£¬Æ¾Ö¤ÏîÄ¿ÐèÇó¾ÙÐÐÉèÖÃ
character_set_server = utf8 # ĬÈÏ×Ö·û¼¯Îªutf8
ÖØÆôMySQLЧÀÍʹÉèÖÃÉúЧ£º
sudo systemctl restart mysqld
µÇ¼ºó¸´ÖÆ
PostgreSQLÊý¾Ý¿âÉèÖãº
PostgreSQLµÄÉèÖÃÎļþλÓÚ/var/lib/pgsql/data/postgresql.conf¡£ÒÔÏÂÊÇһЩ³£ÓõÄÉèÖÃÏ
listen_addresses = ‘localhost’ # ¼àÌýµØµã£¬Ä¬ÒÔΪlocalhost
port = 5432 # ¼àÌý¶Ë¿Ú£¬Ä¬ÒÔΪ5432
max_connections = 100 # ×î´óÅþÁ¬Êý£¬Æ¾Ö¤ÏîÄ¿ÐèÇó¾ÙÐÐÉèÖÃ
default_encoding = ‘UTF8’ # ĬÈÏ×Ö·û¼¯ÎªUTF8
ÖØÆôPostgreSQLЧÀÍʹÉèÖÃÉúЧ£º
sudo systemctl restart postgresql
µÇ¼ºó¸´ÖÆ
´úÂëʾÀý£º
ÒÔÏÂÊÇÔÚPHPÖÐÅþÁ¬MySQLºÍPostgreSQLÊý¾Ý¿âµÄ´úÂëʾÀý£º
ÅþÁ¬MySQLÊý¾Ý¿â£º
$mysqli = new mysqli('localhost', 'username', 'password', 'database'); if ($mysqli->connect_errno) { die('ÅþÁ¬Ê§°Ü£º' . $mysqli->connect_error); } echo 'ÅþÁ¬Àֳɣ¡'; $mysqli->close();
µÇ¼ºó¸´ÖÆ
ÅþÁ¬PostgreSQLÊý¾Ý¿â£º
$pgconn = pg_connect("host=localhost port=5432 dbname=database user=username password=password") or die('ÅþÁ¬Ê§°Ü£º' . pg_last_error()); echo 'ÅþÁ¬Àֳɣ¡'; pg_close($pgconn);
µÇ¼ºó¸´ÖÆ
ÒÔÉÏÊÇÔÚCentOSϵͳÉϴWebЧÀÍÆ÷ʱѡÔñÊý¾Ý¿âºÍ¾ÙÐÐÏìÓ¦ÉèÖõÄһЩ½¨æźʹúÂëʾÀý¡£ÏêϸµÄÉèÖû¹ÐèҪƾ֤ÏÖÕæÏàÐξÙÐе÷½â¡£Ñ¡ÔñºÏÊʵÄÊý¾Ý¿âºÍ׼ȷµØÉèÖÃÊý¾Ý¿â£¬¹ØÓÚWebЧÀÍÆ÷µÄÐÔÄܺÍÎȹÌÐÔ¶¼ÓÐ×ÅÖ÷ÒªµÄÓ°Ï졣ϣÍû±¾ÎĶԶÁÕßÔڴWebЧÀÍÆ÷ʱÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇCentOS´î½¨webЧÀÍÆ÷µÄÊý¾Ý¿âÑ¡ÔñÓëÉèÖý¨ÒéµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡