MySql not updating Privileges

Had problems with this error today and spend ages trying to find the answer. I then realized that the upgrade to MySQL recently (I think 5.1) had probably been the cause. Updating through WHM and Cpanel just sometimes is not very thorough.

This command solved it for me in the end

# /scripts/mysqlup --force --verbose
# /scripts/restartsrv_tailwatchd

Thanks to this page for the tip.

Posted in Uncategorized | Leave a comment

Regex, Find Replace

Working on a list of data that was 5,000 lines long I discovered that I needed to reorganize the way the list was formatted. Doing this manually would have taken a long time, but luckily the editor I use for programming, NetBeans, has a Search/Replace facility that accepts regular expressions.

Not as easy as it sounds, since RegEx can be difficult to work with, I finally came up with this

INSERT INTO dg_surname VALUES \(.*\, '(.*)'\);

to rework my list that looks like this:

Using RegEx

Using RegEx

The slashes are there to allow special characters to be used as normal characters.
The brackets without slashes have a special meaning allowing me to replace with $1 or $2 or $3 depending on how many brackets I use. The contents of the brackets get put in the var $.

This saved me a few hours of work.

For a quick cheatsheet on regex check here.

Posted in Uncategorized | Tagged | Leave a comment

Xdebug for PHP

Have been playing around with xDebug for php to help me do some debugging on the site. Still havent found out how to use it proerly, but have started with this command as an example

xdebug_print_function_stack ();
Posted in Uncategorized | Tagged , | Leave a comment

MySQL from apache command line

Was working on some large tables, over 50mb each, that needed importing to mysql and found the best way to do this was from the command line

cd /home/{web directory}/tmp
where I had saved the .sql file to for importing

mysql
use {database name};
showtables;
{database name} < {filename.sql};

At one stage I also ran the command direct

mysql {database name} < {filename.sql};
Posted in Uncategorized | Tagged , , | Leave a comment

Cron

Have been adding a few items to the cron table recently. Have found this useful to remember to access cron

crontab -e
Posted in Uncategorized | Tagged | Leave a comment

suExec

I have suExec installed on the apache server to help with permissions and groups. This has been helpful with many installation, but caused me some problems with a recent cgi program.

To find the source of the problem, I had a look at the error log file

/usr/local/apache/logs/suexec_log

This showed me the group permission problem I was having and allowed me to fix it with a simple “chown” command.

Posted in Uncategorized | Tagged , , | Leave a comment

Apache Error Log

I was checking out the error log for my apache server recently to try and understand what errors might be coming from web pages that I had not noticed.

The error logs were at:

/usr/local/apache/logs

I was specifically interested in the “error_log”, although there were others like the “access_log”

They are shown in reverse order in an editor like pico

pico error_log

but you can search to the end of the log using the CTRL-W key and input the date.

I had over 700,000 errors in just 3 days mostly relating to the following:

Error Log file from Apache

Error Log file from Apache

It shows that a function previously used in apache for MaxRedirects is no longer available. Looks like I can save about quarter of a million unneeded writes to the disk by changing this. Definitely a good thing to look out for in the future.

Posted in Uncategorized | Leave a comment

Checking Apache redirect log files

Looks like these files are not made standard and have to be requested first

Because I am using a SuExec setup I need to add the following to the httpd.conf set of include file rather than direct to the htaccess file

RewriteEngine On
RewriteLog "/home/{account_name}/public_html/rewrite.log"
RewriteLogLevel 5

These could be saved anywhere on the server for viewing later

Posted in Uncategorized | Tagged , , | Leave a comment

Bugzilla Install

Bugzilla is a downloadable software unit that lets you track bugs on projects you are working on through the use of a web based platform. I downloaded the latest version of bugzilla and installed it to my Apache server at

/usr/local/bugzilla/

There were a number of scripts to be run to confirm that the right modules for perl and cgi were setup on my server. These were well documented in the bugzilla setup files.

I then made a Symlink from the folder I wanted to use as my web based url

cd /home/{website_directory}/
ln -s /usr/local/bugzilla/ bugs

At one stage I made a directory by mistake with the same name I wanted to use for the Symlink directory, and had to delete it. This command came in handy.

rm -rf bugs

to delete the bugs folder.

httpd folder settings to solve errors with letting cgi be used
Thanks to stackoverflow, who always have clear suggestions on how to solve things
http://stackoverflow.com/questions/465222/bugzilla-error-after-installation-test-failed-web-server-is-not-executing-cgi-f

the 2 things which i kept having to do were

  • update the localconfig file in /usr/local/bugzilla/ and then run ./checksetup.pl
  • and then ./testserver http://{domain_name}

this command came in handy as well, courtesy of this site.

service httpd restart

Need to come back and check what happens when I want multiple accounts working here.
http://www.bugzilla.org/docs/3.6/en/html/multiple-bz-dbs.html

Posted in Uncategorized | Tagged , | Leave a comment

Installing Symfony

I have been working with PHP for about a year, prior to that using the .NET platform. I liked the flexibility of the PHP language and its closeness to working with the structures of the web, but also missed some of the framework and DAL/MVC aspects I was used to in .NET. Having read about frameworks for PHP I decided to install Symfony.

Being new to Apache servers as well, it was quite a task to try and get things installed.

Step 1.
Download latest copy of Symfony

I installed the copy of Symfony in a shared folder on my linux server. If you are going to use Symfony for a number of projects then it is better to have one copy of the shared files rather than many of them sitting on the server. I have seen a number of different paths suggested for this:

/usr/local/lib/php/data/symfony
/usr/local/siwapp/lib/vendor/symfony
/home/sfproject/lib/vendor/symfony

I went with /usr/local/lib/php/data/symfony. I can’t remember why now, but that’s the folder it got installed to.

Setting up a Symlink from my web directory to the shared Symfony directory.

There was a lot of documentation about how to edit the httpd.conf files and include a Virtual Host (better than using Alias) to allow access to the shared Symfony folder, but the latest version of Apache and WHM/Cpanel overwrite the base httpd.conf file each time Apache is reconfigured. (I realized later there is a way to include extra httpd.conf through the WHM panel, by clicking Service Configuration -> Include Editor and then choosing one of the places to include text that will get merged later).

WHM configure httpd

WHM configure httpd

My choice here instead was to create a Symlink. Here is how to do it

Go to the folder that you want to create a subfolder for a virtual symlink hookup, then write the command to make a symlink as follows:

cd /home/websitename/public_html
ln -s /usr/local/lib/php/data/symfony/web/sf/ sf

You can see I referenced the shared folder discussed before, and this time called it all the way to the sub-folder “sf”. I then named my virtual symlink folder in the local web directory as “sf”. To check this type

ls -l

and see the newly created “sf” virtual folder will point to the Symfony shared folder

Creating Symlinks

Creating Symlinks

These sites were very useful

  • http://www.weblincs.co.uk/symfony-framework-cPanel-shared-hosting.html
  • http://librosweb.es/symfony_1_2_en/capitulo3/configuring_the_web_server.html
  • http://www.cpanel.net/documentation/easyapache/customdirectives.html#vhost
  • Posted in Uncategorized | Tagged | Leave a comment