How to find the configuration file path of my.cnf, http.conf / apache2.conf and php.ini files

Linux Tutorials

June 6, 2020 by Harry

How to find the configuration file path of my.cnf, http.conf / apache2.conf and php.ini files

In this post, we will learn how to find the configuration file path of php.ini files in PHP and my.conf file in MySQL database and http.conf file in Apache which makes LAMP (Linux, Apache, MySQL, / MariaDB, PHP) with each other.

A configuration file actually contains application settings or system settings. This file allows programmers and system administrators to control an application or system operation. As a system administrator, it is important to know the location of config files, and to find the configuration file path is a valuable skill.

In the Linux Directory structure, the /etc directory or sub-directories are where the application’s configuration files or system-related configuration files are stored.

Although this is actually the main path of config files, some programmers choose other directories to store config files.

find the configuration file path

How to find my.conf configuration file path in MySQL

You can find the MySQL configuration file oath using the mysql or mysqladmin command (MySQL server management client).

The following command will show you the mysql or mysqladmin guide page, which includes a section that talks about files (config files/settings) through which the default options are read and called.

In the following command, the -A option in the grep command displays the line number of the desired contact after the matching line.

# mysql --help | grep -A1 'Default options'

OR

# mysqladmin --help | grep -A1 'Default options'

Find mysql file path

How to find php.ini configuration file path in PHP

PHP can be controlled through the terminal using the php command and used with the -i option to display PHP information and settings, and using the grep command you can find the PHP settings file as below.

# php -i | grep "Loaded Configuration File"

Find php.ini file in PHP

How to find http.conf / apache2.conf configuration file path in Apache

You can use apache2 directly (which is often not recommended) or manage it using the apache2ctl control interface, as in the example below, using the -V option (an option that displays the version and parameters of apache2).

--------- On CentOS / RHEL / Fedora ---------
# apachectl -V | grep SERVER_CONFIG_FILE

--------- On Debian / Ubuntu / Linux Mint ---------
# apache2ctl -V | grep SERVER_CONFIG_FILE
Find the path http.conf in php

find http.conf in Apache

Conclusion

In this article, we found how to find a configuration file path in Linux VPS.

Remember to share your valuable comments about this post or, if possible, other possible ways to find the configuration file path.

Helpful

About the Author Harry

I like to learn and to teach to make things easier

Leave a Reply

Your email address will not be published. Required fields are marked *