Using PHP-MySQL Persistent Connections to Run WordPress Blog Izmantojot PHP, MySQL noturīgiem Savienojumi ar Run WordPress Blog
When connecting to MySQL database, WordPress weblog based on PHP scripting will use non-persistent connection by default. Ja pieslēdzoties MySQL datu bāzi, WordPress weblog balstīta uz PHP skriptu izmantos nav pastāvīgs savienojums pēc noklusējuma. That is, WordPress will trigger PHP to generate a new connection to MySQL server for each dynamic page request, and subsequently close the database connection once the web page building is completed. Tas ir, WordPress izraisīs PHP, lai radītu jaunu savienojumu ar MySQL serveri katru dinamisku lapu pieprasījumu, un pēc tam aizveriet datu bāzi savienojums pēc tam, kad interneta lapas ēka ir pabeigta. Repetitive opening and closing of MySQL connections causes overheads and uses up precious CPU, memory and system resources on the web host. Atkārtotās atvēršanās un aizvēršanās MySQL savienojumi izraisa pieskaitāmās un pielietojums up precious CPU, atmiņas un sistēmas resursu tīmeklī uzņēmējā.
Using persistent connection to connect to MySQL database server is not always a good option. Izmantojot pastāvīgs savienojums, lai izveidotu savienojumu ar MySQL datu bāzes serveri, ne vienmēr ir laba iespēja. Each connections takes up resources, including memory, buffers, table or thread caches internally in MySQL and sockets, open files or IO activity at OS level. Katra savienojumi aizņem resursu, tostarp atmiņa, buferi, galda vai pavedienu Kešatmiņa iekšējai MySQL un uzmavas, atveriet failu vai IO darbību OS līmenī. Thus when a lot of persistent connections are opened but not closed after transactions are completed, the resources on system may drain up and degrade performance of web server, or in worst case, cause HTTP failure. Tādējādi, kad daudz noturīgi savienojumi ir atvērt, bet nav slēgti pēc darījumi ir pabeigta, resursu sistēma var aizplūšanu un noārdās izpildes tīmekļa servera, vai sliktākajā gadījumā, rada HTTP mazspēja. Furthermore, if a persistent connection is stalled, inactive or became defunct or no longer in used, it is not terminated, and MySQL server will only close it to release the resource occupied by the connection after about 28800 seconds (8 hours) by default unless changed the timeout parameters in my.cnf configuration files. Bez tam, ja ir pastāvīgs savienojums ir apstājies, neaktīviem vai kļuva nelaiķis vai vairs izmantot, tas nav pārtraukts, un MySQL serveri tikai aizvērt tā, lai atbrīvotu resursus, ko aizņem savienojumu apmēram pēc 28.800 sekundēm (8 stundas) pēc noklusējuma, ja vien mainīja timeout parametri my.cnf konfigurācijas failiem. This few factors may bring troubles such as MySQL refusing new DB connections or slow server if the applications do not properly handle persistent connections. Šis pāris faktori var radīt problēmas, piemēram, MySQL atteikt jaunu BP savienojumiem vai lēns serveris, ja pieteikumi nav pienācīgi rīkoties noturīgi savienojumi. Thus if you're not experience webmasters, please do not attempt to change Wordpress to use persistent connections. Tādējādi, ja jūs neesat pieredze tīmekļa pārziņiem, lūdzu Nemēģiniet mainīt WordPress izmantot noturīgi savienojumi.
However, for bloggers who have busy and large blog, and facing constraints in upgrading web host system specifications, and do not want to use static page caching plugin such as WP-Cache, persistent connection is a available option to tune and optimize the web server to see if the webpage serving can be faster. Tomēr, lai Emuāru autori, kuri ir aizņemts un lielo blogu, un vērsta ierobežojumus pārkārtošanās interneta uzņēmējas sistēmas specifikācijām, un nevēlaties izmantot statisku lapu caching spraudnis, piemēram, WP-Cache, pastāvīgs savienojums ir pieejama iespēja melodija un optimizēt interneta serveri lai redzētu, vai lapas, kas kalpo, var ātrāk. Persistent connection allows connection to be open once and will not be closed when the execution of the script ends. Noturīgiem savienojums ļauj pieslēgumu varētu atvērt vienu reizi, un nebūs slēgti, kad izpildi, skriptu galiem. Instead, the link is kept in pool and will remain open for future use. Tā vietā, saikni tur baseins un paliks atvērts izmantošanai nākotnē. Thus, using persistent connections will eliminate the process of opening and closing the connection. Tādējādi, izmantojot noturīgi savienojumi novērsīs process atvēršanās un aizvēršanās savienojumu. This will indirectly reduce MySQL connection related server overheads such as authentication to establish connection where only once is needed, saving extra network traffic, and resources used to handle extra connection. Tas netieši samazināt MySQL savienojums related servera pieskaitāmās piemēram, autentifikāciju, lai noteiktu saikni, ja tikai vienu reizi, ir nepieciešams, ietaupot papildu tīkla trafiku un resursi, lai apstrādātu papildu savienojumu. Beside, there could be some connection level caches, which need to be filled up for proper performance, and potentially reduce the number of connections to the database. Bez tam varētu būt daži savienojumu līmenis Kešatmiņa, kas jāaizpilda līdz pienācīgai izpildei un, iespējams, samazinātu to personu skaitu, savienojumi ar datu bāzi.
By default, WordPress is using mysql_connect() function that establishes a new database connection on every page. Pēc noklusējuma WordPress izmanto mysql_connect () funkciju, kas izveido jaunu datubāzi savienojums par katru lapu. The persistent connection feature will require mysql_pconnect() function which uses the exact same API, but has built-in connection pooling to keep connections alive between requests. Ilgstošie savienojums iezīme būs nepieciešama mysql_pconnect () funkcija, kas izmanto tieši tādu API, bet ir iebūvēts savienojums apvienošana, lai saglabātu savienojumu dzīvs starp pieprasījumu. So to switch to use persistent connection to run WordPress, the mysql_connect() function has to be replaced with mysql_pconnect(). Tātad, lai pārslēgtos izmantot pastāvīgs savienojums palaist WordPress, tad mysql_connect () funkcija ir jānomaina ar mysql_pconnect ().
To enable and use persistent connections with WordPress, simply login to your web host with SSH (or insecure Telnet), and change to the webroot home directory where WordPress blog is installed. Lai aktivizētu un izmantot noturīgi savienojumi ar WordPress, vienkārši ieejiet savā interneta uzņēmējas ar SSH (vai nedrošs Telnet), un izmaiņas, kas, webroot mājas direktoriju, kur WordPress blog ir uzstādīta. Then change directory into wp-includes directory. Tad mainīt directory vērā wp-ietver direktorijā. Inside the wp-includes directory, there is wp-db.php file. Inside the wp-ietver directory, ir wp-db.php fails. Use any text editor such as vi to edit wp-db.php. Izmantot jebkuru teksta redaktoru, piemēram, vi, lai rediģētu wp-db.php. Search or locate the function of mysql_connect (or @mysql_connect ). Meklēt vai atrodiet funkciju mysql_connect (vai @ mysql_connect). There is only one instance of mysql_connect. Ir tikai viena instance mysql_connect. Just change the mysql_connect to mysql_pconnect , then save and exit the wp-db.php. Vienkārši nomainiet mysql_connect uz mysql_pconnect, tad saglabātu un izietu no wp-db.php. WordPress and PHP (as long as you don't turn off the mysql.allow_persistent in PHP.INI) will immediately use persistent connections to connect to MySQL database. WordPress un PHP (kamēr jums nav izslēgtu mysql.allow_persistent in PHP.INI) nekavējoties izmantot noturīgi savienojumi, lai izveidotu savienojumu ar MySQL datubāzi. It's worth to try out which setting is best for your environment. Tas ir vērts izmēģināt, kas, kurā ir vislabākā jūsu vidē.
IMPORTANT : The page is machine translated and provided "as is" without warranty. SVARĪGI: Šī lapa ir mašīna tulkoto un ar nosacījumu ", kas ir" bez garantijas. Machine translation may be difficult to understand. Machine translation var būt grūti saprast. Please refer to Lūdzu, skatiet original English article oriģināls angļu rakstu whenever possible. kad vien iespējams.
Related Articles Saistītie raksti
- How to Move WordPress Blog to New Domain or Location Kā Move WordPress Blog uz New Domēns vai Location
- WordPress MySQL SQL Query Error in WPDB Class WordPress MySQL SQL vaicājumu Kļūda WPDB klase
- Moderate WordPress Blog Comments Via Moderator with Desktop Client Mērens WordPress Blog Comments Via moderatori ar Desktop Client
- How to Customize, Modify or Change WordPress Database Connection Error Page Kā Pielāgot, grozīt vai mainīt WordPress Database Connection Error Page
- Replace Google Blog Search with Technorati for Incoming Links in Dashboard of WordPress Aizstāt Google Blog Search ar Technorati ienākošo saites Dashboard no WordPress
- WLWManifest Disabler Plugin to Remove XLM Link in WordPress Blog Header WLWManifest Disabler Plugin, lai novērstu XLM Saikne ar WordPress Blog Header
- AdSense and Display Banner Ads Rotation in WordPress Blog or Websites AdSense un Display Banner Ads Rotācija in WordPress Blog vai Websites
- Integrate and Display Google AdSense for Search and Co-Op Custom Search Engine Results in WordPress Blog Page Template Integrējiet un Google AdSense meklēšanas un Co-Op pielāgoto meklētājprogrammu Rezultāti WordPress Blog Page Template
- Change and Reset MySQL root Password Pārmaiņām un Reset MySQL root parole
- Paginating or Split WordPress Post or Page with NextPage in WordPress Not Working Paginating vai sadalīt WordPress Post vai ar Nextpage in WordPress Not Working










































November 22nd, 2008 10:20 Novembris 22, 2008 10:20
THANK YOU SO MUCH! Thank you so much!
WordPress is running so much faster now! WordPress darbojas tik daudz ātrāk tagad!
I am running all on Windows Server 2008 with: Es esmu rādīt visas uz Windows Server 2008 ar:
- MySQL Server v5.0 x64 (on dedicated server) - MySQL Server v5.0 x64 (par veltīta server)
- IIS7 with FastCGI z32 (on dedicated server) - IIS7 ar FastCGI z32 (par veltīta server)
Regards, Sveicieni,
raja Raja
September 27th, 2007 22:14 Septembris 27, 2007 22:14
This seemed to do the trick for. Tas, šķiet, darīt to triks par. Thanks so much for the info! Thanks so much par info!