Categories
Laptop linux Microsoft

Where is environment variables?

Every process has an environment block that contains a set of environment variables and their values. There are two types of environment variables: user environment variables (set for each user) and system environment variables (set for everyone). An environment variable is a dynamic-named value that can affect the way running processes will behave on a computer.

By default, a child process inherits the environment variables of its parent process. Programs started by the command processor inherit the command processor’s environment variables.

How to set or change the Environment Variables?

Windows

Environment Variables

Windows 10 and Windows 8
  1. In Search, search for and then select: System (Control Panel)
  2. Click the Advanced system settings link.
  3. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  4. In the Edit System Variable (or New System Variable) window, specify the value of the PATHenvironment variable. Click OK. Close all remaining windows by clicking OK.
  5. Reopen Command prompt window, and run your java code.
Windows 7
  1. From the desktop, right click the Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced system settings link.
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATHenvironment variable. Click OK. Close all remaining windows by clicking OK.
  6. Reopen Command prompt window, and run your java code.
Windows Vista
  1. From the desktop, right click the My Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced tab (Advanced system settings link in Vista).
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATHenvironment variable. Click OK. Close all remaining windows by clicking OK.
  6. Reopen Command prompt window, and run your java code.
Windows XP
  1. Select Start, select Control Panel. double click System, and select the Advanced tab.
  2. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  3. In the Edit System Variable (or New System Variable) window, specify the value of the PATHenvironment variable. Click OK. Close all remaining windows by clicking OK.
  4. Reopen Command prompt window, and run your java code.

Mac OS X

To run a different version of Java, either specify the full path, or use the java_home tool:

% /usr/libexec/java_home -v 1.8.0_73 --exec javac -version

Solaris and Linux

  1. To find out if the path is properly set:
    In a terminal windows, enter:
    % java -version
    This will print the version of the java tool, if it can find it. If the version is old or you get the error java: Command not found, then the path is not properly set.
  2. Determine which java executable is the first one found in your PATH
    In a terminal window, enter:
    % which java
Set the PATH permanently

To set the path permanently, set the path in your startup file.
Note: Instructions for two most popular Shells on Linux and Solaris are listed.

Bash Shell

Edit the startup file (~/.bashrc)

  1. Modify PATH variable
    PATH=/usr/local/jdk1.8.0/bin:$PATH
    export PATH
  2. Save and close the file
  3. Load the startup file
    % . /.profile
  4. Verify that the path is set by repeating the java command
    % java -version
C Shell (csh)

Edit the startup file (~/.cshrc)

  1. Set Path
    set path=(/usr/local/jdk1.8.0/bin $path)
  2. Save and close the file
  3. Load the startup file
    % source ~/.cshrc
  4. Verify that the path is set by repeating the java command
    % java -version

 

'Coz sharing is caring
Categories
App linux PHP

How to debug remote PHP code?

Are you maintaining, developing, debugging PHP application? Been in a situation to debug remote php code when site is in production? Are you taking your site down or using immatured die() or exit() while site is live? Gone are the days, now you can enjoy debugging without any disruption in service. You need to install xdebug on the remote server (only once).

php debugging on local system

The process of Xdebug installation differs from OS to OS. In this article we are covering Amazon Linux. Let’s install it on Amazon Linux.

$ sudo yum install php-pear
$ sudo pecl install xdebug

Forward the local xdebug port to remote server.

$ ssh -R 9669:127.0.0.1:9669 ec2-swatantra@your.remote.host

Run an xdebug client, like macGDBp, or Netbeans debugger.

Make sure to match the port forwarded above and set an IDE key in the debugger you are using.

Local Port: 9669
Remote Port: 9669
IDE Key: xdebug-swatantra

Also you can configure local to remote path mapping on Netbeans or on macGDBp to use code navigation with your local checked out code.

Local Path: /Users/swatantra/workspace/php-code
Remote Path: /home/ec2-swatantra/workspace/php-code

Initiate debugging on your debugger of choice.

Run the php cli command on remote host, remember to use the IDE key you wrote above.

$ alias phpdr="php -d zend_extension=/usr/lib64/php/5.6/modules/xdebug.so -d xdebug.remote_enable=1 -d xdebug.remote_autostart=1 -d xdebug.remote_host=127.0.0.1 -d xdebug.remote_port=9669 -d xdebug.idekey=xdebug-swatantra"
$ phpdr /home/ec2-user/workspace/php-code/src/script.php --option=value
php debugging on remote system

You can save the above alias ‘phpdr’ in your .bashrc or .zshrc based on your choice of shell.

'Coz sharing is caring