如何使Web应用程序只能从某些计算机上访问?

I need a solution, how to make a web application hosted in web server can be accessible to certain computer machines using PHP language or Java. I need to restrict a web application to certain computer machines. So please tell me how it can achieved??

You make a whitelist of IP addresses that are allowed to connect to the web server.

Then you can get the client's IP addresses in PHP:

$userIpAddress = $_SERVER['REMOTE_ADDR'];

or in Java:

String userIpAddress = request.getHeader("Remote_Addr");

Note that getting the real IP address of the user can be tricky. See these questions:

The easiest way, though, would be to restrict clients' access directly in the webserver configuration.

Basically you have several options. You could secure your application using apache authentication which requires user to insert username and password. You could restrict access to the application using IP address or implement the authentication on the application layer.

I do not suggest using IP authentication tho, because it simply isn't secure.

Apache authentication: apache documentation

PHP Authentication: PHP Documentation

If you are using apache web server then you can restrict certain IPs in webserver configuration itself as suggested here.

This is not only in Apache but any webserver out there, you can do the same thing but configuration style differs.