brightlemon web design london [accesskey: .] brightlemon london web design
company services products support case studies training resources contact us
Web contact
Call me back
Request a quote
PQQs/RFPs

Search blog

Pages
  • About the Brightlemon web design london blog

  • Archives
  • August 2009
  • July 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • December 2007
  • November 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • January 2007
  • December 2006
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006

  • Categories
  • Accessibility (16)
  • Adobe (3)
  • ajax (3)
  • Analytics (1)
  • Apache (9)
  • Blogs (5)
  • Brightlemon news (19)
  • case study (8)
  • command line (6)
  • content management (4)
  • CSS (28)
  • database administration (1)
  • Design (11)
  • Dreamweaver (12)
  • Drupal (34)
  • Drupal configuration (22)
  • Drupal courses (4)
  • Drupal customisation (20)
  • Drupal development (27)
  • Drupal modules (22)
  • Drupal optimisation (13)
  • Drupal regions (9)
  • Drupal scalability (11)
  • Drupal styling (12)
  • Drupal Themes (19)
  • Drupal training (6)
  • Drupal video (10)
  • Drupal views (10)
  • e-commerce (6)
  • Email (2)
  • Errors (5)
  • Firefox Add-Ons (6)
  • Flash (18)
  • FTP (5)
  • HTML (20)
  • Illustrator (13)
  • Information Architecture (4)
  • Internet Security (10)
  • JavaScript (9)
  • javascript (3)
  • jquery (2)
  • LAMP (10)
  • Linux (12)
  • mathematics (3)
  • maths (3)
  • mobile web (2)
  • mysql (7)
  • Open Source (15)
  • Photoshop (22)
  • php (15)
  • Quality Assurance (4)
  • research & strategy (5)
  • Search engine optimisation (8)
  • seo (7)
  • Server administration (7)
  • Smarty (1)
  • social bookmarking (5)
  • social networking (15)
  • social tagging (4)
  • ssh (3)
  • subversion (2)
  • svn (1)
  • Tips (23)
  • typography (3)
  • Uncategorized (1)
  • Unix (4)
  • Usability (4)
  • Useful Links (14)
  • version control (1)
  • W3C (17)
  • Web 2.0 (44)
  • Web browsers (18)
  • Web design (84)
  • Web development (133)
  • Web marketing (5)
  • Web standards (12)
  • Web video (8)
  • xhtml (3)
  •       go - (© brightlemon web design london)

    Archive for the 'command line' Category

    Repair all mysql tables (and check and optimise them) in one command

    Sunday, May 24th, 2009

    Here’s how to check, repair and optimise all your mysql tables in all databases on a server…

    Am really loving the mysqlcheck command… it allows you to:

    • check all mysql tables
    • repair all mysql tables
    • optimise all mysql tables

    in one command…! Mysql rocks..!

    mysqlcheck - u root - p - -auto-repair - -check - -optimize - -all-databases

    That’s it..

    Some tips:

    1. it’s probably best to kill all incoming processes to speed this up
    2. even better just to stop the web server (httpd) run this command and restart (add a friendly message for users to see while the site is down)

    (Remember if you are using a tool like phpmyadmin (http://www.phpmyadmin.com) you can always log in, browse to the table, select operations and choose “repair”, “check”, “analyse” or “optimise table”)

    Basic Shell Programming

    Monday, November 5th, 2007

    Hello,

    The Bash shell is your main port of entry to Linux, since the shell interprets everything you enter on the command line before passing it along to the operating system for execution.
    A shell script is a program written for Bash. Basically script is a sequence of Linux commands, but when you add the power of variables and data manipulating, you can do a lot more with it.

    Shell scripts are interpreted, which means that the shell reads each line and acts on it immediately. This process differs from that of a formal programming language like C or C++, where the program is compiled and optimized for faster execution. So there’s a tradeoff–it’s easier to create quick little shell scripts, but if the task at hand requires serious number crunching or complicated logic, a compiled language is better.

    Note: All of the shell script syntax and examples in this section will work in both the Bash and Korn (pdksh) shells. The C shell (tcsh) has subtle differences in many areas, so scripts written for one shell may not work in another. If you decide to use the C shell instead of Bash, use the man tcsh command for more information on writing shell scripts for that environment.

    Creating a Shell Script

    To create a shell script, use a text editor and enter your Linux commands as if you were typing them at the command prompt. For example, try this:

    cd /tmp
    echo “Removing temp files…”
    ls -al
    rm junk*

    If you save those four lines in a file named deltemp, you will have a simple shell script that automates the process of switching to the /tmp directory, listing all the files there, and deleting the ones that start with the word junk.

    So how do you run this little wonder of technology? In DOS, all you have to do is name a file with a .bat extension and it’ll be recognized as an executable file–but not so with Linux. Since Linux attaches no meaning to file extensions, you have to mark the file as executable by using the chmod command, like this:

    $ chmod +x deltemp

    The x marks the file as executable; if you list the permissions for the deltemp file afterward, you will see the x in position four, confirming this:

    $ ls -l deltemp
    -rwx—— 1 hermie other 55 Feb 19 14:02 deltemp

    If you want other users to be able to run this script, give them both read and execute permission, like so:

    $ chmod ugo+rx deltemp
    $ ls -l deltemp
    -rwxr-xr-x 1 hermie other 55 Feb 19 14:04 deltemp

    Now the permissions show that any user can view or execute the deltemp script, but only you can modify it. To run the script, just enter its name at the command prompt, prefixed with ./ as shown here:

    $ ./deltemp

    Note: If the current directory is in the PATH environment variable, you can omit the ./ before the name.

    But there’s one important thing you should know about running shell scripts this way. When you enter the shell script name and tell Bash to run it, a subshell is created for the execution of the script. This subshell inherits all the shell environment variables, including the current directory, but you lose any changes made to that environment when the script terminates.

    What’s the practical meaning of this? Well, you might expect that the current directory would be /tmp after you’ve run the deltemp script, but it’s not. You’ll still be in hermie’s home directory. And if we had set an environment variable inside the script, its value would be good only during the execution of the script. Here’s an example to demonstrate this point. Create an executable setvar script with these lines:

    PS1=’My Prompt: ‘
    echo $PS1

    Now watch how the values of the current directory and the PS1 variable change:

    $ PS1=’Bash Me! ‘
    $ echo $PS1
    Bash Me! PS1 before setvar.
    $ setvar
    My Prompt: PS1 during setvar.
    $ echo $PS1
    Bash Me! PS1 after setvar.

    It looks like this script is absolutely useless for the intended purpose of setting the environment variable. But a little trick will make it work the way you want. Run the script by prefixing the name with a dot and a space, like so:

    . setvar

    This tells Bash to run the setvar script in the current shell environment, instead of creating a temporary subshell. Verify for yourself that the command prompt does in fact change to My Prompt: after running this script.

    In next part i will talk about Shell Script Variables

    Writing logs to separate files for each domain in Apache

    Friday, November 10th, 2006

    The default setting in Apache is for logs to store information (hits, page views etc.) in one log file. But what if you want to run reports for separate domain names or VirtualHosts on the server? You need a way to tell Apache to put the logfile information for each domain into a different file. Here’s how it’s done below.
    The main directive that needs adjusting in httpd.conf (the main confiuration file for Apache normally found in /etc/httpd/conf/httpd.conf - if you’re not sure type “whereis httpd.conf”) is in the section:

    <VirtualHost *:80>
    ServerName www.yourdomain.com
    DocumentRoot /path/to/your/domain
    TransferLog /otherpath/to/your/logs/gen_msg
    ErrorLog /otherpath/to/your/logs/error_msg
    </VirtualHost>

    By specifying locations for TransferLog and ErrorLog in the VirtualHost directive for each domain in your httpd.conf file your logs will now be written to separate files. Simple eh?

    Restarting a Linux server

    Tuesday, July 11th, 2006

    Restarting a linux server requires the following command:

    shutdown now -r

    (as with all linux commands type shutdown - - help to view all the options that are avaliable)

    source:

    Linux the essential reference (Petron, New Riders 2000)

    Restarting an apache server

    Tuesday, July 11th, 2006

    To restart apache the following commands are required:

    for apache version 1.x.x:

    service httpd restart

    or

    service httpd stop

    then

    service httpd start

    for apache version 2.x.x:

    apachectl -k stop

    or

    apachectl -k graceful

    source:

    Preventing Web Attacks with Apache (Barnett, Addison Wesley 2006)

    related links:

    apache version 1.3 http://httpd.apache.org/docs/1.3/stopping.html

    apache version 2.0 http://httpd.apache.org/docs/2.0/stopping.html

    Automating PHP scripts

    Tuesday, July 4th, 2006

    At brightlemon web design london, uk we do a lot of web development using the combination of Linux, Apache, Mysql and PHP (also know as LAMP).

    One issue we’ve encountered is how to automatically run PHP scripts.

    With PERL scripts it’s easy - just add the script path to the cron job. (the cron is an automatic scheduler for linux which allows scripts to run daily, weekly, monthly…)

    Two good resources that cover this topic are:

    http://www.phpfreaks.com/tutorials/28/1.php
    and
    http://www.htmlcenter.com/tutorials/tutorials.cfm?id=155&type=PHP

    social networking
    e-commerce
    search engine optimisation
    web design
    content management
    accessibility
    brightlemon london web design
    UK and London web site visitors

    Visiting from the UK or London? Visit our London web site...