September 2006
Monthly Archive
Sun 10 Sep 2006
Courtesy of Electric Toolbox
If you have made changes to the Apache configuration file httpd.conf on you need to reload the Apache service for the changes to take effect. From
the command line you do this with the apachectl command. The exact location of this command varies on the Unix or Linux variant you are using (eg Fedora, OSX, FreeBSD, Slackware, Mandrake, SUSE) and the compile time settings, but typically it is accesible at /usr/sbin/apachectl . An example of restarting Apache gracefully is shown below:
/usr/sbin/apachectl graceful
Note that you will either need to be running as root or use the “sudo” command in order to run this command.
If Apache is not already running it will be started. If it is already running then it will reload with the new changes but will not abort active connections, meaning that anyone who is in the middle of downloading something will continue to be able to download it.
Before restarting the Apache service a check will be done on the configuration files to ensure they are valid. If there is an error in them the error will be displayed and the Apache service will continue running using the old settings. You need to correct your settings before attempting to restart again.
You can also just check the settings without restarting Apache like so:
/usr/sbin/apachectl configtest
This will check the httpd.conf file and report whether the syntax of the file is valid or not. A list of errors will be displayed including the line numbers if there are any. This makes it easy to isolate any problems.
The following are all the available options that can be passed to the apachectl command. This text is from the apachectl man page.
apachectl start: Start the Apache daemon. Gives an error if it is already running.
apachectl stop: Stops the Apache daemon.
apachectl restart: Restarts the Apache daemon by sending it a SIGHUP. If the daemon is not running, it is started. This command automatically checks the configuration files via configtest before initiating the restart to make sure Apache doesn’t die.
fullstatus: Displays a full status report from mod_status. For this to work, you need to have mod_status enabled on your server and a text-based browser such as lynx available on your system. The URL used to access the status report can be set by editing the STATUSURL variable in the script.
apachectl status: Displays a brief status report. Similar to the fullstatus option, except that the list of requests currently being served is omitted.
apachectl graceful: Gracefully restarts the Apache daemon by sending it a SIGUSR1. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted. A side effect is that old log files will not be closed immediately. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them. This command automatically checks the configuration files via configtest before initiating the restart to make sure Apache doesn’t die.
apachectl configtest: Run a configuration file syntax test. It parses the configuration files and either reports Syntax Ok or detailed information about the particular syntax error.
apachectl help: Displays a short help message.
Fri 8 Sep 2006
I just tried to transfer a plugin to my server using FTP, but kept getting Connection Refused whenever I logged in. My hosting provider’s solution was to reboot my VPS - a little problematic as I was in the middle of editing httpd.conf, so now my HTTP access is hosed
The FTP server started working though
Here’s what you should do to test your FTP server
- Open a command prompt
- Start a telnet session by typing telnet mydomain ftp then type the items entered in BOLD below
connecting to mydomain…
220 mydomain FTP server (Version wu-2.6.2(1) Mon Aug 16 17:10:57 IDT 2004)
ready.
150 Opening BINARY mode data connection for file list.
226 Transfer complete.
USER anonymous
331 Guest login ok, send your complete e-mail address as password.
PASS mozilla@
230 Guest login ok, access restrictions apply.
SYST
215 UNIX Type: L8
TYPE I
200 Type set to I.
PASV
227 Entering Passive Mode (192,168,0,10,239,190)
NLST
Do not worry if you get the reply 550 *: No such file or directory
- Start another command prompt
- Start another telnet session, but this time use the data received in reply to the PASV command above. In our example, the FTP server at IP Address 192.168.0.10 is listening on port ((239* 256) + 190), or 61374, so we would type telnet mydomain 61374
- If you received error 550, then type LIST in the first telnet session and you will see a list of files appear in the second telnet window and a couple of messages in the first window
150 Opening BINARY mode data connection for /bin/ls.
226 Transfer complete.
If you did not receive error 550, then you will see a list of the directories appear in the second telnet window, followed by Connection to host lost and
the two messages below in the first telnet window. There will be a pause between the first and second message while the data is transmitted.
150 Opening BINARY mode data connection for file list.
226 Transfer complete.
- Type QUIT in the first telnet window to close the FTP session. You may need to type QUIT again to terminate the telnet session.
If you like, you can edit /etc/ftpaccess and remove the ‘#’ from the two lines
#log commands real
#log transfers anonymous,real inbound,outbound
to enable logging for your FTP server. Beware as these log files can suck up disk space! Look here for full details, or do a Google on log commands real wu-ftp
Fri 8 Sep 2006
Well, it has been some months since I last used WordPress and I could not access the blog for some reason. All that appeared was a nicely presented page with the message
Error establishing a database connection
This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at DB_HOST. This could mean your host's database server is down.
* Are you sure you have the correct username and password?
* Are you sure that you have typed the correct hostname?
* Are you sure that the database server is running?
Luckily, my host lets me do practically anything, so it was off to Google to find a bit out about mySQL.
The first thing to do is open a session to your server. I use PuTTY which is a freeware Telnet client that lets me open a secure session to my server. Navigate to the directory where WordPress is installed. On my installation, this is /var/www/html/worpress. There is a file called wp-config.php in this directory. Check the first few lines of this file using the head command as shown below
$ head -7 /var/www/html/wordpress/wp-config.php
<?php
// ** MySQL settings ** //
define('DB_NAME', 'wordpressdb'); // The name of the database
define('DB_USER', 'username'); // Your MySQL username
define('DB_PASSWORD', 'password'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
I then used this data to try connecting to the database manually and was promptly thrown out!
$mysql -h 'localhost' -u 'username' -p 'password'
ERROR 1045 (28000): Access denied for user 'username'@'localhost' (using password: YES)
Somehow, the password for my database had been changed. Had I got it right, I would have received the reply
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 126 to server version: 4.1.9-standard-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
If you get the error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2), then your SQL server is not running. See my other post on restarting MySQL (when I sort it out!)
I therefore decided to create a new privilege (user) and granted them access to the wordpress database given by DB_NAME.
$mysql
mysql> GRANT USAGE ON * . * TO 'newuser'@'localhost' IDENTIFIED BY 'newpassword' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 ;
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT ALL PRIVILEGES ON `wordpressdb` . * TO 'newuser'@'localhost' WITH GRANT OPTION ;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
$
All you have to do then is edit the wp-config.php file we started with (/var/www/html/wordpress/wp-config.php) to use the new username and password. I used the pico editor on my Linux server to do this. It's very simple, but if you need some help, then try here
For an alternate solution, you can try the answer provided by astrashe at WordPress.org
I used this to get a more specific error message -- replace the connection parameters with what you're using on your server, put this in a file called something.php, and pull it up in your browser.
HTML:
-
-
-
-
-
<?php
-
-
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
-
or die('Could not connect: ' . mysql_error());
-
-
?>
-
-
</body>
-
</html>
Don't forget to replace mysql_host, mysql_user and mysql_password with the data you obtained from wp-config.php
(more...)
Fri 8 Sep 2006
Direct quotes from WordPress's website
Plugin Installation
To install a plugin, the following are the general directions to follow. Be sure and follow the specific instructions provided by the Plugin author. Remember: BACKUP - just in case.
- Read through the "readme" file thoroughly that usually accompanies a plugin, or the website article from where you found the plugin. It is often helpful to print out the instructions so you can check off the installation steps as you complete them.
- Upload the plugin to the wp-content/plugins folder in your WordPress directory online.
- Make any changes to templates or files as required by the Plugin instructions including adding Plugin template tags.
- Activate the Plugin:
- Access the Plugin Panel in your Admin Panel
- Scroll down through the list of Plugins to find the newly installed Plugin (if not visible, start from the beginning to check to see if you followed the instructions properly and uploaded the file correctly).
- Click on the Activate link to turn the Plugin on.
- Continue making any modifications necessary from the "readme" file instructions to make the plugin's actions meet your needs.
Hiding Plugins When Deactivated
Some plugins feature tags inside of the template files. If the plugin is not activated, it will "break" the Theme and it may report errors or fail to load. It is therefore imperative to prevent the plugin from being detected in case it is turned off.
To detect if a plugin is installed, you can use a simple function_exists() check. The if (function_exists()) checks for the plugin, and if it exists, it will use it. If it returns FALSE or "not found", it will ignore the plugin tag and continue loading the page.
PHP:
-
<?php
-
-
FUNCTION_NAME();
-
}
-
?>
This example plugin uses a function called jal_get_shoutbox() to print out its contents.
PHP:
-
<?php
-
-
jal_get_shoutbox();
-
}
-
?>
Troubleshooting Plugins
If you are experiencing problems with a plugin you installed or one that stopped working after upgrading, the following are the steps you need to take to troubleshoot the plugin:
- Check that you have followed the plugin author's instructions to the letter.
- Check that any plugin tags or usage within your template files are correct, spelled right, and placed in the appropriate place, i.e., within the WordPress Loop or outside of it.
- Check that you uploaded the file to the plugins folder under wp-content. If you are uploading a new version to replace the old, delete the old version prior to uploading the new one.
- Check that the plugin has been activated in your Plugin Panel of your Administration Panels.
- Deactivate and re-activate the plugin to see if this makes it work.
- Visit the plugin author's website, typically linked from the Plugin Panel, and look to see if someone else is having the same trouble and an answer has been posted, or a new version released.
- Contact the plugin author directly via their website or email requesting assistance.
- Search the Internet for the name of the plugin and the trouble you are having as someone else might have had the same problem and found a fix and posted it on their site.
- Visit the WordPress Support Forum (http://www.wordpress.org/support) and post a clear question about the plugin and the problem you are having and you may get an answer from someone familiar with the plugin.
- If the problem persists and you cannot seem to solve it, check to see if there are any similar plugins that you can try instead.
Fri 8 Sep 2006
mysql> show grants for 'olduser'@'localhost';
+----------------------------------------------------------------------------------------------------------------+
| Grants for newuser@localhost |
+----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'olduser'@'localhost' IDENTIFIED BY PASSWORD '*D8DECEC305209EEFEC43008E1D420E1AA06B19E0' |
| GRANT USAGE ON `database`.* TO 'olduser'@'localhost' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> REVOKE ALL PRIVILEGES ON `database` . * FROM 'olduser'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> REVOKE GRANT OPTION ON `database` . * FROM 'olduser'@ 'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> REVOKE ALL PRIVILEGES ON * . * FROM 'olduser'@ 'localhost';
mysql> DROP USER 'olduser'@ 'localhost';
« Previous Page