Monday, November 23, 2015

apache user permisions

ls -l /var/www
sudo groupadd www
sudo usermod -a -G www user-name

// logout and login

to check group : groups
sudo chown -R root:www /var/www
[ec2-user ~]$
sudo chmod 2775 /var/www
[ec2-user ~]$
find /var/www -type d -exec sudo chmod 2775 {} +

Tuesday, October 13, 2015

How To Install No-ip In CentOS

No-ip client; use to update/resolve a server with a dynamic IP.

Prerequisite:

    Create a free no-ip account.  Log in to the no-ip website and create a host.
    Install “Make” compiler program in preparation to compile the no-ip program.  You might also have to install the “GCC” compiler if “Make” compiler don’t work; I have both GCC and Make installed.  The following is the  commands to download &install them:

yum install gcc

yum install make
Now onto the easy step-by-step installation of no-ip client.  Run the following 6 commands from the terminal:

    mkdir noip && cd noip
    wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
    tar zvxf noip-duc-linux.tar.gz
    cd noip-2.1.9-1
    make
    make install

You will then need to answer the following prompts:

Please enter the login/email string for no-ip.com

(Email account that you used to set-up no-ip account from their website)

Please enter the password for user

(Password that you used to login to no-ip website)

Please enter an update interval: [30] 30

(Increments in minutes that you want no-ip client to check if your router’s external dynamic IP address has changed and updates it accordingly.)

Do you wish to run something at successful update? [N] (y/N)

(Enter “N” here)
Now start no-ip client by running the following command:
/usr/local/bin/noip2
Now have no-ip client start every time the computer reboot by issuing the following command:
echo ‘/usr/local/bin/noip2’ >> /etc/rc.local
More useful no-ip commands:

    /usr/local/bin/noip2 -C                                       to configure noip client

    /usr/local/bin/noip2 -S                                       to display info about running noip client

    /usr/local/bin/noip2 -U                                       to set update intervals (in minutes)

Thursday, October 8, 2015

Centos disk space allocation

You need to unmount a filesystem to shrink it. So, for /home you'll want to be log in as root and umount /home. If it's 'busy'. You may need to stop any processes using files here.

Then, shrink the file system to just below your targeted logical volume size.

resize2fs /dev/mapper/vg_nastgweblls01-lv_home 99G

Shrink the logical volume to the targeted size.

lvreduce -L 100G /dev/mapper/vg_nastgweblls01-lv_home

Grow the filesystem to the logical volume's capacity.

resize2fs /dev/mapper/vg_nastgweblls01-lv_home

The reason I do it this so I don't have to do any math and keep the filesystem the size of the container. A bit lazy, but it works great.

Now, you have free space to grow root.

lvextend -L 75G /dev/mapper/vg_nastgweblls01-lv_root
resize2fs /dev/mapper/vg_nastgweblls01-lv_root


* remembered that I need to mount the home drive

mount /home

Tuesday, September 8, 2015

How to make a Case-insensitive url redirect to a case-sensitive url


Ex:
https://example.com/example/index.html to https://example.com/ExamPLe/index.html

RewriteEngine On
RewriteCond %{REQUEST_URI} !/WebMaster/ 
RewriteRule ^/?webmaster/(.*) http://www.example.com/WebMaster/$1 [NC,R=301,L]

Preventing Directory Listing

Preventing Directory Listing

Do you have a directory full of images or zips that you do not want people to be able to browse through? Typically a server is setup to prevent directory listing, but sometimes they are not. If not, become self-sufficient and fix it yourself:

    IndexIgnore *

The * is a wildcard that matches all files, so if you stick that line into an htaccess file in your images directory, nothing in that directory will be allowed to be listed.

On the other hand, what if you did want the directory contents to be listed, but only if they were HTML pages and not images? Simple says I:

    IndexIgnore *.gif *.jpg

This would return a list of all files not ending in .jpg or .gif, but would still list .txt, .html, etc.

And conversely, if your server is setup to prevent directory listing, but you want to list the directories by default, you could simply throw this into an htaccess file the directory you want displayed:

    Options +Indexes

If you do use this option, be very careful that you do not put any unintentional or compromising files in this directory. And if you guessed it by the plus sign before Indexes, you can throw in a minus sign (Options -Indexes) to prevent directory listing entirely--this is typical of most server setups and is usually configured elsewhere in the apache server, but can be overridden through htaccess.

Blocking users/ sites by referrer

Blocking users/ sites by referrer


Blocking users or sites that originate from a particular domain is another useful trick of .htaccess. Lets say you check your logs one day, and see tons of referrals from a particular site, yet upon inspection you can't find a single visible link to your site on theirs. The referral isn't a "legitimate" one, with the site most likely hot linking to certain files on your site such as images, .css files, or files you can't even make out. Remember, your logs will generate a referrer entry for any kind of reference to your site that has a traceable origin.

Before I get to the code itself, it's important to note that blocking access by referrer in .htaccess requires the help of the Apache module mod_rewrite to make out the referrer first. This module is installed by default on most servers (ask your host if you're not sure). So, to deny access all traffic that originate from a particular domain (referrers) to your site, use the following code:

Block traffic from a single referrer:

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} badsite\.com [NC]
RewriteRule .* - [F]

Block traffic from multiple referrers

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} badsite\.com [NC,OR]
RewriteCond %{HTTP_REFERER} anotherbadsite\.com
RewriteRule .* - [F]

In the "single referrer" case above, "badsite\.com" is the domain you wish to block. Note the backslash proceeding the period (".") to actually donate a period, as in Regular Expressions, a period donates any character, which is not what we want. The flag "[NC]" is added to the end of the domain to make it case insensitive, so whether the domain is "badsite.com", "Badsite.com" etc, however bad it gets, it gets blocked. Finally, the last line in the .htaccess file specifies that the action to take when a match is found is to fail the request, meaning the referrer traffic will hit a 403 Forbidden error. The only difference between blocking a single referrer and multiple referrers is the modified [NC, OR] flag in the later case to every domain but the last.

Friday, April 24, 2015

Change previouly commited svn commit message log

committed a change into SVN (subversion) and found that you used the wrong messages file - meaning that the log message for the revision is wrong?

If so: it's good to know that subversion allows you to change the message - possibly with some help from the administrator. If that's you - so much the better.

Here's one process that could help. This example is for a linux system, but can easily be adapted to others.

When in the working copy folder, try the command (replacing "1234" with the revision number you want to edit the message for).

    export SVN_EDITOR=vim
    svn propedit -r 1234 --revprop svn:log

This will launch "vim" and allow you to edit the message text. When you're done and you save the updated file svn will attempt to apply the change to the server repository.

It is possible that the svn server is not set up to allow this, in which case you may see something like this..

    svn: E165006: Repository has not been enabled to accept revision propchanges;
    ask the administrator to create a pre-revprop-change hook

If you see this message then you (assuming you are the admin) can check the "hooks" directory of the server's repository. For example (your repository will almost certainly be in a different place)..

    cd /opt/svn/myrepos/hooks
    ls -l

Check to see whether there is a file called "pre-revprop-change" listed with execute permissions. If not, and there is a "pre-revprop-change.tmpl" file then review it's contents and if you are happy with the logic it contains, copy it into place. If the file already exists then stop here (dont do the copy) - and investigate why it is preventing your request to update the log.

So, if the file is missing...

    cp pre-revprop-change.tmpl pre-revprop-change
    chmod +x pre-revprop-change

On my system, the template file has the default contents - namely (excluding comments)..

    REPOS="$1"
    REV="$2"
    USER="$3"
    PROPNAME="$4"
    ACTION="$5"

    if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi

    echo "Changing revision properties other than svn:log is prohibited" >&2
    exit 1

This allows the log to be modified, but blocks all other edits on revision properties. For our situation, this is perfectly fine.

Once the file is in place, return to the working copy and try again. Hopefully, this time your change will be accepted.

Monday, February 23, 2015

How to: Spreadtrum ADB (Android Debug Bridge) Drivers / Setup – ZTE U791 – Windows 7 64Bit and MAC

 recently bought a very cheap ZTE U791 that I wanted to use as a debugging device while developing an Android app.

It took me a whole day to find the correct drivers that would work, Windows 7 64Bit made it even harder.

Like every Android phone, you have to install ADB and its drivers to access the Android Debug Bridge.

To install the ADB intereface simple install the Android SDK if how have not already.

http://developer.android.com/sdk/installing/index.html

You will then have to install the Phone drivers on Windows:

You can check in the Device manager to make sure there are no devices with exclamation marks once you have installed the drivers below!

I tried tons of drivers to get it to work – the one that worked for me was the Debug Drivers below – but you might need to install both:



ADB Drivers: https://www.dropbox.com/s/r50r39o2ia6pmkt/Spreadtrum-Drivers.7z?dl=0

Debug Drivers: https://www.dropbox.com/s/kjt76ecr786zvke/SCI-android-usb-driver-jungo-v4.7z?dl=0



Then the VERY IMPORTANT STEP:

 Then you will have to tell ADB what phone to use. By that I mean adding the PCI ID to a text file to tell ADB that this peripheral is compatible.

The Spreadtrum PCI ID is 0x1782

add this line to “Your user directory/.android/adb_usb.ini”

for example

C:\Users\drk\.android\adb_usb.ini

If the file does not exist create it.

Add this Code:
1    0x1782

 Then the phone should work and be detected by your PC:

To test navigate to your Android SDK Directory and run: adb devices
1    C:\sdk\platform-tools adb devices
2    List of devices attached
3    19761202 device



On a Mac you would also need to add this Vendor ID – it is however easier and you also have the ability to FIND the Vendor ID for the specific phone.

Add the Vendor ID to the following file:
1    ~/.android/adb_usb.ini

You might have to kill and start the ADB server with
1    adb kill-server<br /><br />adb start-server



To find the Vendor ID on a Mac all you need to do is

1. Plug in the Phone

2. Click the Apple Logo

3. Hold the Control Button and Click on System Information

4. Open the USB and then the USB Phone Section

You should see something like this

MAC Spreadtrum Vendor ID

Monday, February 16, 2015

How to set up a proxy server with XAMPP on Windows

1. Set up Apache

    Open your apache config file C:\xampp\apache\conf\httpd.conf. Make sure the following lines are uncommented:

      Include "conf/extra/httpd-proxy.conf"
      LoadModule proxy_module modules/mod_proxy.so
      LoadModule proxy_connect_module modules/mod_proxy_connect.so
      LoadModule proxy_http_module modules/mod_proxy_http.so

2. Open your proxy config file C:\xampp\apache\conf\extra\httpd-proxy.conf. Edit it to match the following:

<IfModule proxy_module>
  <IfModule proxy_http_module>
    ProxyRequests On
    ProxyVia On
    <Proxy *>
      Order deny,allow
      Allow from 127.0.0.1
    </Proxy>
    ProxyBlock some-website-you-want-to-block.com another-website-you-want-to-block.com
  </IfModule>
  </IfModule>
 
3. Restart Apache

Monday, September 1, 2014

Apache Uthentication for single Page

If you don’t current have an .htpasswd, use the “-c” option to create the file with the first user. It will prompt you for a password and encrypt it for you.

htpasswd -c /var/www/domain.com/public_html/.htpasswd user1

Copy and Paste following in .htaccess (Change path and file name according to your ewquirement)
AuthUserFile /PATH-TO-HTPASSWD/.htpasswd
  AuthName "My restricted Area"
  AuthType Basic
# ErrorDocument 401 /test.php
  <Files "vox-videos.html">
   require valid-user
   </Files>

Monday, July 21, 2014

Get the phpMyAdmin's Visual Query Designer

Step 1) open phpMyAdmin/config.inc.php and modify the below lines of code.

/* change this info to whatever user has read-only access to the "mysql/user" and "mysql/db" tables */         
    $cfg['Servers'][$i]['controluser']   = 'root'; //this is the default user for MAMP's mysql
    $cfg['Servers'][$i]['controlpass']   = 'root'; //this is the default password for MAMP's mysql

/* this information needs to line up with the database we're about to create so don't edit it unless you plan on editing the SQL we're about to run */
    $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; 
    $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
    $cfg['Servers'][$i]['relation'] = 'pma__relation';
    $cfg['Servers'][$i]['table_info'] = 'pma__table_info';
    $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
    $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
    $cfg['Servers'][$i]['column_info'] = 'pma__column_info';
    $cfg['Servers'][$i]['history'] = 'pma__history';
    $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
    $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
    $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
    $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';


Step 2)    phpMyAdmin installs with the SQL we need to generate the database that the Designer relies on. We just need to locate the script. In 4.0.7 the file location is phpMyAdmin/examples/create_tables.sql. Alternatively, you can copy/download this from phpMyAdmin's github.
Once you locate the file, either import the file or copy/paste it into a SQL window and execute in phpMyAdmin.
Now, everything should be configured properly. We need to clear cookies and restart the browser.
When you open phpMyAdmin back up, navigate to a specific table and in the tabs you should see Designer tab.

Thursday, July 17, 2014

htaccess rules

# ---- Make pages render without their extension in the url
Options +MultiViews


404 custom file not found page

ErrorDocument 404 /filenotfound.php


Prevent directory or File listing :

IndexIgnore *

Redirect entire domain to another domain

Redirect 301 / http://www.devaraju.com/

Redrect individual pages

Redirect 301 /old.html http://www.devaraju.com/new.html

Redirect entire domain to respective pages

RewriteCond %{HTTP_HOST} !^www.\devaraju\.com
RewriteRule (.*) http://www.devaraju.com/$1 [R=301,L]

.htaccess ip bases restriction

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^111\.22\.333\.444$
RewriteCond %{REMOTE_ADDR} !^123\.22\.46\.56$
RewriteCond %{REQUEST_URI} !\.(jpg|jpeg|png|gif|svg|swf|css|ico|js)$ [NC]
RewriteRule ^ /maintenance.html

Thursday, July 10, 2014

.htaccess redirection

# Redirect to domain with www.


RewriteEngine on

# Redirect to domain with www.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Same for HTTPS:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


# Redirect to domain without www.

RewriteEngine on

# Redirect to domain without www.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule .* http://%1%{REQUEST_URI} [R=301,L]
# Same for HTTPS:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]


Do not force www/no-www domain

RewriteEngine on

# Redirect to another domain: www.test.org.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^(www\.)?test\.org$ [NC]
RewriteRule .* http://www.test.org%{REQUEST_URI} [R=301,L]
# Same for HTTPS:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^(www\.)?test\.org$ [NC]
RewriteRule .* https://www.test.org%{REQUEST_URI} [R=301,L]


Trailing slash for URLs

RewriteEngine on

# Ensure all directory URLs have a trailing slash.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\/$
RewriteCond %{REQUEST_URI} !\/[^\/]*\.[^\/]+$
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]
# Same for HTTPS:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\/$
RewriteCond %{REQUEST_URI} !\/[^\/]*\.[^\/]+$
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]


301 Redirect Directories

#301 Redirect Entire Directory.
RedirectMatch 301 ^/old/(.*)$ /new/$1


# Block users by IP
order allow,deny
deny from 127.0.0.1
deny from 127.0.0.2
allow from all


Change Default Directory Pages

# Change default directory pages.
DirectoryIndex new

Prevent viewing of .htaccess

# Prevent viewing of htaccess file.
<Files .htaccess>
    order allow,deny
    deny from all
</Files>



Change Default Directory Pages

# Change default directory pages.
DirectoryIndex new


Prevent viewing of htaccess file

# Prevent viewing of htaccess file.
<Files .htaccess>
    order allow,deny
    deny from all
</Files>


Prevent Directory Listing

# Prevent directory listings
Options All -Indexes


Compression

# Compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript



Enable Symbolic Links

# Follow symbolic links.
Options +FollowSymLinks

Import and Export CSV file into mysql database

SELECT * from  `table name` INTO OUTFILE 'table.csv' FIELDS ENCLOSED BY '"' TERMINATED BY ';' ESCAPED BY '"' LINES TERMINATED BY '\r\n'

find / -type f -name table name.csv

load data  infile 'table.csv' into table table name fields terminated by ',' enclosed by '"' lines terminated by '\n'

Wednesday, July 9, 2014

Redirect to domain without www.

redirection rule in .htaccess as follows

RewriteEngine on

# Redirect to domain without www.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule .* http://%1%{REQUEST_URI} [R=301,L]

Saturday, July 5, 2014

Git basic commands

This summary is not available. Please click here to view the post.

iis configuration for drupal clean-urls

web.config as follows

Drupal 6 :

<?xml version="1.0" encoding="UTF-8"?>

    <configuration>

        <system.webServer>

            <rewrite>

                <rules>

                    <rule name="Drupal Clean URLs" stopProcessing="true">

                        <match url="^(.*)$" />

                        <conditions>

                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

                         
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

                        </conditions>

                        <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />

                    </rule>

            </rules>

        </rewrite>

    </system.webServer>

</configuration>


Drupal 7 :

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

 <system.webServer>

 <rewrite>

   <rules>

     <rule name="Drupal clean URLs" enabled="true">

       <match url="^(.*)$" ignoreCase="false" />

       <conditions logicalGrouping="MatchAll">

         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 

         <add input="{REQUEST_URI}" negate="true" pattern="/favicon.ico$" />

       </conditions>

       <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />

     </rule>

   </rules>

</rewrite>

    </system.webServer>

</configuration>

Configuring Vitualhost in apache (Plesk)

 forwarding sub-domain to hosting server(IP).
create dns record in domain section like xxx.domain.com pointing to IP by following the link.
http://sdevaraju.blogspot.in/2014/07/a-step-by-step-guide-on-how-to-create.html

 <VirtualHost x.x.x.x:80>
  ServerName "domain/sub-domain"
  DocumentRoot "path-to site/test"
ScriptAlias  "/cgi-bin/" "path-to site/cgi-bin/"
<IfModule mod_fcgid.c>
    <Files ~ (\.php)>
        SetHandler fcgid-script
        FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
        Options +ExecCGI
        allow from all
    </Files>
</IfModule>
</VirtualHost>

A step by step guide on how to create a sub domain on godaddy account manager

Creating a sub-domain is sometimes handy if you’re looking to test new products or extend your website with secondary complementary material.   It’s often used by companies to create a testing website before launching a new website.  For example most people would use a sub-domain such as www2.mydomain.com  where www2 is pointed to a secondary folder on the web server or any other web server out on the internet.

For the purpose of this tutorial on how to setup a sub domain for your real estate website.  We are going to provide you with the steps you need in order to create a sub-domain on Godaddy, if you purchased your domain through them.

In order to setup a sub-domain on godaddy, you need to ensure that you’re currently logged into the website.   Once you have gained access to your godaddy account proceed by clicking on “My Account“.

Secondly, This page often changes on Godaddy, but you will want to locate the “Domains” link which shows you all the domains you currently have with Godaddy.  This will take you to what is known as your “Domain Manager”.

Third, you will arrive to a list of all the domains you currently have registered with godaddy. From the list below you will click on the domain name for which you would like to create a new sub-domain.

Fourth step is to launch the DNS manager for the domain we selected from the third step.  If you do not seethe “Launch” link on the DNS Manager section, you will need to contact the individuals who are currentlyhosting your website.  They likely have control of your DNS settings for your domain.

Finally,  Once you launched the DNS manager for the domain you were interested in creating for your domain.   You will be presented with the details of all the DNS settings for your particular domain.

In this section you will need to have ready an IP Address where you would want to point the sub domain to.   It’s important that you have this ready before proceeding with the changes.

in the “A (Hosts) section – click on Quick Add.   Enter the desired “host” name and “Points to” IP Address.    Once you entered this information click on Save Zone File.