[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

[Latest version of Reiwa] About the influence of PHP version and how to check it

php -v

Introduction

Hello, I'm [Enoki] from the System Development Department, and this time I'm going to write an article about checking the PHP version.

By the way, if the PHP version is old, there will be problems and impacts on security etc.

(Actually) I won't specifically touch on that in this article, so

if you 're not familiar with how web systems work, but you're curious about the effects of PHP version differences, I recommend the article below

[Explanation] Effects and countermeasures caused by differences in PHP versions

For now, this is "this".

php -v

It's OK if the version information appears like this.

PHP 8.2.1 (cli) (built: Jan 11 2023 07:28:38) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.1, Copyright (c) Zend Technologies with Xdebug v3.2.2, Copyright (c ) 2002-2023, by Derick Rethans


You can almost hear someone saying, "I know this many commands, but I can't find the version, so I'm looking into it!"

If that is the case (version information does not appear), the execution location may be incorrect.

'php' is not recognized as an internal or external command, operable program or batch file.

About execution location

Here are the execution locations in typical environments and what to do if it still does not appear.

Environment Linux/Windows

First is the environment.

Linux: Start a terminal and run
php -v Windows: Start a command prompt (or PowerShell) and run php -v

Execution location (for those wondering what an arbitrary directory is)

The arbitrary directory is the directory where PHP is installed.

If you think about it, it's obvious, but you can't run it in a place where PHP doesn't exist.

You can find the PHP installation location by running the command below.

Linux:

# Command to find PHP installation location find / -type f -name "php" -executable -print

Windows:

# Command in terminal to find PHP installation location dir /s /b php.exe
# Command in PowerShell to find the PHP installation location where.exe php

Running these commands will display the path where PHP is installed.

Once you know the location of PHP

you run the above command and see a path like /usr/local/bin/php

the /php at the end to move to the execution location as follows.

 # Example command to move to PHP installation location cd /usr/local/bin

After that, php -v should display PHP version information correctly.
Now you can now execute PHP commands, but
to be honest, it's a pain to have to go all the way here every time.
So let's continue for a little while.

Executable from anywhere via path

Once you find the PHP location (installation directory) you can pass it through.
This allows you to use PHP executables in any directory.

Linux

Add the path by running the following command in Terminal:

export PATH=$PATH:[installation path]

For example, if the PHP installation path is /usr/local/bin , it will look like this:
This installation path is the path to the php installed directory (location) that you discovered earlier.

export PATH=$PATH:/usr/local/bin

For Windows

In Windows, you can pass the path by changing the environment variable settings.

1. Search for and open “Edit System Environment Variables”.
2.Click the "Environment Variables" button.
3. Select the Path environment variable in the System Environment Variables section and click Edit.
4.Click the New button to add the PHP installation path.
5. Save your changes and close the dialog.

This will add the PHP installation path to the environment variable Path and make it passable.

Now you can execute PHP commands without having to move each time! !
Please use it for a comfortable PHP life! !

If you found this article helpful , please give it a like!
8
Loading...
8 votes, average: 1.00 / 18
2,328
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author

Enoki

I play everything from FPS, RPG, MMO, crafting, etc.