Monday, April 22, 2013

Run multiple commands in Linux Launcher

If you want to run multiple commands in launcher.




Example:- If you want to stop apache2 (httpd) & mysql (mysqld) simultaneously. You would use 

service apache2 stop && service mysql stop
or
service httpd stop && service mysqld stop

But unfortunately it won't work in Launcher. It runs the first command but does not execute second.

To run multiple commands as a Launcher, you should use
sh -c "service apache2 start && service mysql start"
Now when you run launcher, it executes all commands.

If you want to run three commands,
sh -c "service apache2 start && service mysql start && cat > redirect"
In above example, it would start both services as well as create a file redirect.

Run sudo without asking user password

No password for sudo


Open file /etc/sudoers  and uncomment following line.
%sudo ALL=NOPASSWD: ALL
Save the file.

Now if you run commands with sudo, it does not ask user password.

Friday, April 19, 2013

.htaccess - Error 500 - Internal Server Error

Error 500 - Internal Server Error



To remove this error, check the content of .htaccess. It should be like this. 

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /your-web-project-directory-name/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /your-web-project-directory-name/index.php [L] <IfModule>

If Apache can’t understand any line in your .htaccess, it will cause an error.
When you try to access your web page, it generates the error.

A garbage line in .htaccess can create Internal Server Error.

Example:
Create a file name .htaccess, write your name into it, save it and put it in your web project directory. Now try to access the web page, it will give this error.

Define rewrite rule carefully in your .htaccess. If you write anything in .htaccess which apache can't understand, it will be the reason of Internal Server Error.

If rewrite module is not enabled and you are using rewrite engine in the .htaccess, you may have this error. To find a solution, click here or you can find another solution here.