Home Linux ServerWeb Server Quickly find the location of the php.ini file on a Linux server

Quickly find the location of the php.ini file on a Linux server

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

When you use and manage a VPS/server running Linux with a website using PHP source code, you are probably no longer unfamiliar with the ‘php.ini’ file because to edit or change related configurations regarding the PHP Backendoperation, you need to edit this file directly.

What is a php.ini file?

Note: If you use Shared Hosting services, the provider will not let you set up the php.ini file yourself, either there will be a similar file named user.ini or no file at all.

The file ‘php.ini’ is a configuration file that translates and processes PHP code. And for some reason, if you need to edit the parameters in this file to better suit the source code or programming needs, now it’s time to determine the exact path of the php.ini file to be able to adjust. It is quite important to adjust the desired configuration.

Because there are now many Control Panels, Scripts, and modules, each control will have different php.ini file locations or there may be many different php.ini files on the same server, resulting in a file some users edit the php.ini file at the default path, causing the configuration edit to fail.

Locate the file php.ini

To quickly locate the php.ini file on a Linux server, there is a quick way you can apply that is to use the command line on Linux, with this way, you don’t need to care what you are using control, script because it will automatically list the exact path according to the control, the script you are using.

Step 1: SSH into your server

To upgrade the ProFTPD version on DirectAdmin, we first need to SSH or access your VPS/server with root privileges. If you don’t know how to SSH into your VPS/Server, you can refer to the following tutorial:

Step 2: Use the Command line

To quickly and accurately locate the php.ini file, you can use the command below:

AZDIGI Tutorial
php -i | grep "Loaded Configuration File"
    

Explanation of the above command:

  • php -i | grep “Loaded Configuration File”: Quickly find the Loaded Configuration File value (this value is the path of the php.ini file)

Here are the results of some common php.ini file paths that you often encounter:

  • cPanel
AZDIGI Tutorial
[trungkie@chv10-24851 ~]$ php -i | grep "Loaded Configuration File"
Loaded Configuration File => /opt/alt/php74/etc/php.ini
    
Quickly find the location of the php.ini file on a Linux server

  • DirectAdmin
AZDIGI Tutorial
[root@sv ~]# php -i | grep "Loaded Configuration File"
Loaded Configuration File => /usr/local/php72/lib/php.ini
    
Quickly find the location of the php.ini file on a Linux server

  • aaPanel
AZDIGI Tutorial
[root@sv ~]# php -i | grep "Loaded Configuration File"
Loaded Configuration File => /www/server/php/74/etc/php.ini
    
Quickly find the location of the php.ini file on a Linux server
  • Hostvn Script
AZDIGI Tutorial
[root@sv ~]# php -i | grep "Loaded Configuration File"
Loaded Configuration File => /etc/php.ini
    
CleanShot 2022 04 20 at 17.28.51

So in this article, AZDIGI showed you how to quickly locate the php.ini file on your Linux server so that you can edit the PHP configuration correctly. Hope this article will help you, wish you success!

You can refer to other instructions at the link below:

If you need assistance, you can contact support in the ways below:

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign