Thursday, 13 February 2020

Error - "Forbidden : You don't have permission to acces /phpmyadmin/ on this server" on Linux server (CentOS 7).

After installing LAMP on your Linux server, if you are getting error like "Forbidden:You don't have permission to access /phpmyadmin/ on this server", then it means that you are accessing it from server ip address and it is allowed from only localhost or you are accessing it from localhost and it is allowed only from ip address. So what to do next?


Type command -

sudo gedit /etc/httpd/conf.d/phpMyAdmin.conf

You will get the phpMyAdmin.conf file and at top you will find following code

Chane the line Require ip 127.0.0.1 and Allow from 127.0.0.1 if you want to access it using localhost on local machine. If you want to access it using your system ip address  on local machine then change 127.0.0.1 to to your system ip address

<Directory /usr/share/phpMyAdmin/>
      AddDefaultCharset UTF-8
  
<IfModule mod_authz_core.c>
    # Apache 2.4
   <RequireAny>
        Require ip 127.0.0.1
        Require ip ::1
   </RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny, Allow
     Deny From All 
     Allow from 127.0.0.1
     Allow from ::1
</IfModule>
</Directory>
 
If you want to access this server from any machine then replace the above code with

<Directory /usr/share/phpMyAdmin/>
      AddDefaultCharset UTF-8

<IfModule mod_authz_core.c>
     # Apache 2.4

     <RequireAny>
       Require all granted
     </RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
     #Apache 2.2
      Order Allow, Deny
      Allow from all
      Allow from 127.0.0.1
      Allow from ::1
</IfModule>
</Directory>


Monday, 10 February 2020

Unable to access Tomcat server running on Linux from another machine.

If you have installed Tomcat server on Linux and it is working on properly on installed machine, but you are unable to access it from other machine. If both machines are connected properly but again you are unable to access this. Then you can try this method.

(If have used this on CentOS running Tomcat 9 server)

It might be problem of firewall, so please use this command-
(I suppose your Tomcat server is using port 8080, if it uses another then use that port number in command)

sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent

sudo firewall-cmd --reload



Sunday, 9 February 2020

Add multiple Jar file to classpath with javac command in Java.

Look how we can add multiple or single jar file to javac command.

Example given below for adding single jar file to javac-

javac -cp "absolute_path_of_jar_file" java_file_name.java
(javac -cp "F:\tomcat\lib\servlet-api.jar" test.java)

or

javac -classpath "absolute path of jar file" java_file_name.java

( javac -classpath "F:\tomcat\lib\servlet-api.jar" test.java )

For adding multiple files -

javac -cp "absolute path of jar file1; path of jar file2" java_file_ name.java

javac -classpath "absolute path of jar file1; path of jar file2" java_file_name.java

(javac -cp "F:\tomcat\lib\servlet-api.jar;F:\tomcat\webapps\file-sharing\WEB-INF\lib\anyjar.jar" test.java)

If all jar files in a same directory then, suppose if all in lib folder then

javac -cp "c:\tomcat\webapps\project\lib\*"  java_file_name.java

(javac -cp "F:\tomcat\lib\servlet-api.jar;F:\tomcat\webapps\file-sharing\WEB-INF\lib\*" test.java)

Sunday, 31 March 2019

KVM is required to run this AVD. /dev/kvm/ device:permission denied. Grant current user access to /dvm/kvm

When I updated my Android Studio to 3.2.2 and when tried to run emulator got the problem -


After searching on internet, I found the successful solution here .

Solution is to need to install qemu-kvm. To do this run command type -

sudo apt-get install qemu-kvm

After successful installation of qemu-kvm, check the ownership of /dev/kvm, to check this, type-

ls -al /dev/kvm 

After this command you can see that kvm is under root ownership.

Now type following command to check the which user is under kvm group -

grep kvm /etc/group

This command will give output like -

kvm:x:127:

So, there is nothing after second colon (:), there should be a username after second colon.

So, to add user (your system username) to kvm group, type

sudo adduser <your_system_user> kvm

This command will add you (your system user) to the kvm group.
Once again run the command -

grep kvm /etc/group

Output may be like -

kvm:x:127:your_system_username

Now all done. Re-login/restart  is required to apply the effects.

See all steps screen shot bellow -





Saturday, 30 March 2019

Execute any command/script at system startup in Ubuntu 18.04 (LTS)

Today, after installing Ubuntu 18.04 after a long use of lower version of Ubuntu, I got there is no rc.local file in etc directory. Actually this file is used to start any script at system startup.

So, what to do if it is not available in Ubuntu 18.04?

Just create a file by typing any of given command -

sudo nano /etc/rc.local

or

sudo gedit /etc/rc.local

or

sudo cat /etc/rc.local


and paste the following text in this file -


#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0



After saving this, make it executable by command -

chmod +x /etc/rc.local


Now you can paste your scripting script in this file.

Sunday, 24 March 2019

Notice: Undefined variable: var in F\wamp\www\project\filename.php in PHP/WAMP

I got the following problem when I was migrating from WAMP server 2 to WAMP Server 3 version in my project.



Code I was written that -

<?php $var=$_GET['ll']; ?> //getting value from another page in a variable

<?php echo $var; ?> //Printing the value on page

This code segment has problem, when my project was developed in WAMP Server 2

I just replace this code segment in WAMP server 3 to resolve this issue.


<?php 
if(isset($_GET['ll'])){
    $var = $_GET['ll'];
}
?>


<?php 
if(isset($var)){ 
    echo $var;
}
?>


Friday, 22 March 2019

How to recover data/databases/tables from mysql in WAMP server.

Suppose you are running WAMP server on your local system and due to bad luck your WAMP server got corrupted or unable to start. You must have created some databases and tables in your MYSQL, then you would be unable to access these data. So, now here question arises that, any how we can get this data/databases/tables and recover our databases and tables.

Answer is "yes".

There might be several ways to recover data, but what I applied was very simple and hassle free. Let see, how I recovered my data.

I have applied this method on WAMP Server 3.1.7 on 64 bit Windows Server 2016.

Copy your old WAMP server data of location your_root_wampserver_folder\bin\mysql\mysql5.7.24\data ( in my case it was D:\wamp64\bin\mysql\mysql5.7.24\data ). Copy either data folder or data of data folder for recovery to any location.

Note:- You can see your all databases name as folder in data folder, you have been previously created.

Now back up your new installed WAMP server MYSQL data folder (location your_root_wampserver_folder\bin\mysql\mysql5.7.24\data) data to any safe location.

 After backing up after data folder of your new system, copy the old data folder to new data folder.

Important :- Both WAMP versions should be same.

Change image source dynamically on hyperlink

 Changing image source dynamically using JQuery. Here in this example I have created there hyperlink and stored all images in the same folde...