Difference between revisions of "WordPress"

From Hostek.com Wiki
Jump to: navigation, search
(How to Update WordPress)
Line 3: Line 3:
 
==What is WordPress?==
 
==What is WordPress?==
 
WordPress is an open source CMS, often used as a blog publishing application powered by PHP and MySQL.
 
WordPress is an open source CMS, often used as a blog publishing application powered by PHP and MySQL.
 
==How to Move WordPress from one directory to another within the same server==
 
If you want to move WordPress to your root directory, make sure all index.php, .htaccess, and other files that might be copied over are backed up and/or moved, and that the root directory is ready for the new WordPress files.
 
#Log in to your site.
 
#Go to the Administration > Settings > General panel.
 
#In the box for WordPress Address (URL): change the address to the new location of your main WordPress core files.
 
#In the box for Site Address (URL): change the address to the new location, which should match the WordPress (your public site) address.
 
#Click Save Changes.
 
#(Do not try to open/view your site now!)
 
#Move your WordPress core files to the new location. This includes the files found within the original directory, such as http://example.com/wordpress, and all the sub-directories, to the new location.
 
#Now, try to open your site by going to yourdomain.com/wp-admin. Note, you may need to go to yourdomain.com/wp-login.php
 
#If you are using Permalinks, go to the Administration > Settings > Permalinks panel and update your Permalink structure to your .htaccess file, which should be in the same directory as the main index.php file.
 
#Existing image/media links uploaded media will refer to the old folder and must be updated with the new location. You can do this with the Velvet Blues Update URLs or Better Search Replace plugins, WP-CLI's #search-replace if your hosting provider (or you) have installed WP-CLI, a search and replace script, or manually in your SQL database.
 
#In some cases your permissions may have changed, depending on your ISP. Watch for any files with "0000" permissions and change them back to "0644".
 
#If your theme supports menus, links to your home page may still have the old subdirectory embedded in them. Go to Appearance::Menus and update them.
 
  
  
Line 161: Line 146:
 
[http://hostek.com/tutorials/wp-upgrade.html How to update your WordPress installation]
 
[http://hostek.com/tutorials/wp-upgrade.html How to update your WordPress installation]
  
[[Category:Tutorials]]
+
[[Category:WordPress]]

Revision as of 05:18, 16 February 2017


What is WordPress?

WordPress is an open source CMS, often used as a blog publishing application powered by PHP and MySQL.


How to Protect WordPress

Windows Server

  1. Edit or Create a file named .htaccess within the directory of your WordPress installation (yes, the file starts with .)
  2. Place this code in the .htaccess file (this example assumes your IP is 123.123.123.123). Click to see your IP.
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)?xmlrpc\.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123$
RewriteRule .* http://0.0.0.0/Please_check_your_htaccess_file_or_contact_your_hosting_provider_for_assistance [R=301]

NOTE: If you need to allow access from more than 1 IP replace the REMOTE_ADDR line with this example and update accordingly

RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123$

Linux Server

  1. Edit or Create a file named .htaccess within the directory of your WordPress installation (yes, the file starts with .)
  2. Place this code in the .htaccess file (this example assumes your IP is 123.123.123.123). Click to see your IP.
<FilesMatch 'wp-login|admin-ajax.php|wp-admin'>
  RewriteEngine On
  RewriteCond %{REMOTE_ADDR} !123.3123.123.123
  RewriteRule .* http://0.0.0.0/Please_check_your_htaccess_file_or_contact_your_hosting_provider_for_assistance [R=301]
</FilesMatch>

NOTE: If you need to allow access from more than 1 IP replace the REMOTE_ADDR line with this example and update accordingly

RewriteCond %{REMOTE_ADDR} !123.123.123.123

Changing Domain Name on a Wordpress Site

  1. Update Wordpress and all of your themes and plugins.
  2. Backup site files.
  3. Backup your database.
  4. Login to phpMyAdmin.
  5. Click the link to your Database (If your not sure what database its using check the main "wp-config.php" file. It will have your MySQL host, database name, and the database username/password).
  6. A list of your databases will appear. Choose the one that is your WordPress database.
  7. All the tables in your database will appear on the screen.
  8. From the list, look for wp_options. Note: The table prefix of wp_ may be different if you changed it when installing.
  9. Click on the small icon indicated as Browse.
  10. A screen will open with a list of the fields within the wp_options table.
  11. Under the field option_name, scroll down and look for siteurl.
  12. Click the Edit Field icon which usually is found at the far left at the beginning of the row.
  13. The Edit Field window will appear.
  14. In the input box for option_value, carefully change the URL information to the new address.
  15. Verify this is correct and click Go to save the information.
  16. You should be returned to your wp-options table.
  17. Look for the home field in the table and click Edit Field. Note There are several pages of tables inside wp_options. Look for the > symbol to page through them.
  18. In the input box for option_value, carefully change the URL information to the new address.
  19. Verify this is correct and click Go to save the information.
  20. Now, via your FTP for the site, Delete the folder wp-content/cache (this is a new folder added with WordPress 2.0).
  21. After following the steps above, login into your WordPress admin and change the domain name at the following places:
    1. Settings - General - Update the "WordPress address (URL)" and the "Blog address (URL):" if filled.
    2. Settings - Misc. - Update the domain name in the "Store uploads in this folder" path, if it has the olddomain.

Error Establishing Database Connection

This error means wordpress cannot connect to the database but can have any number of causes.

  1. If this is a site transfer, ensure the wp-config.php file has the correct database name and database user for your new Hostek site.
  2. First check to see if your wp-admin section gets the same error. When you browse to http://yourdomain.com/wp-admin, if it has any other error (or none at all) add the following line to your wp-config.php file:
define('WP_ALLOW_REPAIR', true);

and visit http://yourdomain.com/wp-admin/maint/repair.php and you can repair the database. Remove the added code from wp-config.php when you are done.

  1. DB_HOST will be set differently depending on what server your site is on. In wp-config.php, confirm that your 'DB_HOST', line has either localhost (for shared Linux/CPanel servers and VPSs) or an IP Address that corresponds to the database's hosted server (you can find this in your control panel). If you are supposed to use localhost but still get the error, try replacing it with '127.0.0.1' which may sometimes solve the issue.
  2. Test general connections to the MySQL server which hosts the database. Make a blank php file somewhere on your site called dbconnecttest.php and use the following code:
<?php
$link = mysql_connect('localhost', 'root', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

(Replace the 'localhost', 'root', and 'password' sections with the appropriate host, username, and password.)

  1. If you still get the same error, the user may have insufficient permission or the database can't be reached at all, in which case please create a support ticket at http://support.hostek.com with the problem and troubleshooting you've gone through. You can also try connecting to the database with PHPMyadmin and if the user doesn't have permissions, it will show a corresponding error.
  2. There may be some junk data in the database that a repair won't fix. Commonly the tables "active_plugins" and "recently_edited" can contain extra non-used information from switching between themes and plugins that cause the site to stop connecting to the database. Go to your PHPMyadmin, find the wordpress database, then find those two tables. Remove the contents for the two tables specified that have nothing to do with your site (for example, do not remove information related to your theme).
  3. If the site is relatively small or new and you're willing to start over, downloading the latest version of Wordpress and installing it or using our Wordpress installer from the application menu (Windows servers), and Fantastico (CPanel/Linux).
  4. Try changing the user's password for the database (be sure to update this in wp-config.php). Sometimes MySQL or something else has an update which can change password formatting compatability.

Wordpress Slowness Troubleshooting

Site slowness can be a common problem that has causes ranging anywhere from too many requests, large file size requests, poor DNS mapping, or server slowness.

  1. First check your site on http://tools.pingdom.com which should come up with a lot of information. Verify that the site's load time is high there as well for you. If it's low for pingdom, you more than likely are having an issue with your local internet connection speed or proxy. If your local speed is fast, it could also be the amount of client-side coding on the site (such as JavaScript). Consider switching most elements to server-side coding such as PHP, Coldfusion, Ruby, or ASP.
  2. As the page size increases, the time it takes to fulfill a request goes up. Larger files can hang and time out, so be sure to reduce image filesizes and check the amount of media on a site.
  3. Check to make sure none of the listed files are red. If they are, they are missing and could be causing the browser to wait for it for an unnecessarily long time, especially if the file is integral.
  4. As the number of requests increase, the time also increases. Requests are handled in concurrent chunks. Different browsers can handle a different maximum number (usually 2-8, but sometimes 15+). The more requests your page makes to JS files, CSS files, images, and so forth, the more time it will take depending on the browser and server's limitations for concurrent requests. Even if they are all extremely small file sizes, consider reducing these by combining external CSS files and JS files, and combining smaller images into "sprites" which load that image once, but display different parts of it in different places (More information: http://css-tricks.com/css-sprites/ and http://spriteme.org/faq.php#def ).
  5. Any external requests (to other hosts) will increase response time as this will be dependent on that host, as well as your browser's settings. Limit the number of external image and code loading.
  6. Complicated DNS entries can cause slowness. Since DNS begins a request, it has to go through the route set out for it ahead of time. If that route involves multiple other services such as Google API, Cloudflare, Dropbox, or Microsoft Office 365, you may experience additional load time.
  7. SSL can slightly slow down a site, and loading external elements which authenticate over SSL (such as paypal or donate buttons) will cause some level of slowdown due to the secure "handshake" that must occur.
  8. Redirects listed will increase load time. These can be due to DNS records or just due to redirection performed in site code.
  9. If you have lots of requests, the initial DNS resolve time can be improved by having your domain Registrar be the same as your website host. For example, at Hostek we use our own DNS clusters; when you have both your domain and web site hosted through us, there will be a slight speed difference than if your Registrar has to point to our servers from a remote location.
  10. A CMS such as Wordpress, generally come in much more resource-intensive packages. Try ensuring your plugins are reduced to a minimum and that themes are not too overly complicated. If you have already optimized your site or require a more elaborate site, consider making a support ticket at http://support.hostek.com to inquire about what other packages we may have available to speed up your performance. If you have a VPS, check to see if the site is taking up a lot of resources and consider ordering more processing power or memory if necessary.

Plugin and Theme Problems

When your Wordpress site is not working or is performing poorly, themes and plugins are the best first investigation point as they tend to cause most of the issues.

  1. If you can log into your wp-admin, disable some plugins one by one and check the site each time. Alternatively, disable all of the plugins and check to see if this fixes the issue. If it does, re-enable plugins individually until you find the culprit.
  2. Always keep plugins and Wordpress up to date with the latest version. Even if it breaks some usability, you will be more secure and less likely to have larger problems overall. Updates mostly include critical bug fixes, compatibility changes and security updates.
  3. If you cannot even log into your wp-admin section, open either an FTP client or your file manager from the control panel and simply find the folder "/wp-content/plugins" and rename "plugins" to something else. Try logging into your wp-admin and check to see if this solved the problem. If it did, rename the folder back and then rename each plugin except for one. Continue restoring their names until you find the culprit.
  4. Sometimes plugins or themes are simply incompatible with each other due to third party development being so open. If you find conflicting plugins (that work fine separately but not together), consider changing one of the plugins to another one that suits the same purpose.
  5. Make a backup copy of your site by zipping it or moving it into another folder. Now try switching themes and check to see that the problem is gone. If the problem is gone, try either a new theme or get with your developer on fixing the compatibility with the current theme if it is needed. Restore the backup of the site when done.

URL Redirects / Permalink Troubleshooting

Sometimes site pages do not load (even when they may have done so before).

  1. Check the links themselves by hovering over them to make sure the path is correct. If anything is present shouldn't be or missing, then you will have a better idea of what may be happening.
  2. Check .htaccess to be sure there are no redirects occurring that have broken this. This can be as simple as improper syntax (use a syntax checker: http://htaccess.madewithlove.be/ ) or making sure the redirects and rewrites are operating the way they were intended. If your Wordpress is on Windows, be sure that your .htaccess is using proper ISAPI compatible rewrites.
  3. Check Wordpress permalinks by going into wp-admin and looking for the site settings and then permalinks. Once there, you can troubleshoot the issue by saving any custom permalink format you may be using and checking the Default (first) option to see if this resolves the issue. If the issue is resolved, revise the permalink format or consider one of the pre-made options.

How to modify your PHP Settings

Windows/WCP Plans

  • Please refer to our separate wiki here

Linux/cPanel Plans

  • This is a very useful tool when it comes to making specific changes to PHP. Instead of using a "php.ini" file it will change it directly on the server for your Domain.
  1. Login to cPanel (e.g. http://yourdomain.com/cpanel)
  2. Under the "Software and Services" section, go to PHP Settings
    • If you don't see the PHP Settings button, you'll want to follow these steps:
    1. Click on Select PHP Version
    2. Click on Switch to PHP Settings -- This is located on the upper-right hand side of the page.
  3. Start modifying any of the values here by clicking on them.
  4. Click Save

WordPress - Video Tutorials

How to manage categories in WordPress

How to write a comment in WordPress

How to change your header in WordPress

How to install WordPress

How to manage pages in WordPress

How to change your password in WordPress

How to manage users in WordPress

How to manage your plugins in WordPress

How to write a new post in WordPress

How to edit your profile in WordPress

How to configure your settings in WordPress

How to update your WordPress installation