How to Change PHP Configuration on a Dedicated Server

The Tech Trend
3 min readJun 1, 2022
PHP initially started as a small open source project that evolved as awareness spread about its versatility and usefulness. Rasmus Lerdorf created PHP way back in 1994.

PHP scripts are written, executed on the server, processed, and embedded in HTML. PHP can be integrated with popular databases. These include MySQL, Microsoft SQL Server, Oracle, etc. The latest release is version 8.13, released in February 2022.

There are many web hosting services that provide hosting with PHP and MySql. If you are looking to do your own coding via PHP, then a dedicated hosting plan is for you.

Changing the PHP configuration on a dedicated server will require you to edit the PHP.ini file on the server. This guide will show you how to alter PHP configuration on an Apache Web Server. Read on for more information on how to edit an ini file.

How to View Your Current PHP Settings.

There is a built-in function called phpinfo() within PHP for viewing PHP settings. This can be useful if you need to check on the default PHP settings. It also comes in handy to follow up on changes in the PHP settings.

A file named phpinfo.php needs to be created to view the PHP settings.

Follow these steps for creating the file.

Step 1: Log in to the cPanel

Look for the File Manager option in the files section of the cPanel. Open it and navigate to the directory you are working with. This is an essential step as each folder can actually have different PHP settings.

In the top menu, locate the +File option in the top menu to create a new file. Type in phpinfo.php when prompted for a file name. It can be named anything as per your preference.

Once you locate the phpinfo.php file, right-click on it and choose the edit option.

  • A ‘Text Editor’ prompt will pop up. This is the PHP configuration editor. Select ‘utf-8’ from the drop-down list and select Edit.
  • The next step would be to enter the following code into the phpinfo.php file.
  • <? phpinfo(); ?>
  • Once that is done, click Save Changes

Step 2: Access the PHP File

Now that the phpinfo page has been created, you can proceed to access it and view the PHP settings. This page can be accessed on the browser. If the file was created in the public_html folder, type the URL https://example.com/phpinfo.php in the address bar.

Use ‘Ctrl+F’ and search for memory_limit to look for any specific value of the setting. The first value that you come across is the local value and is set for the current directory. The setting value is also referred to as the master value.

The local value is the setting that you are looking for. It is the critical value as the local values override the master value.

PHP Settings on the Apache Webserver

For global settings, the Apache Webserver uses the httpd.conf file and the .htaccess file for directory access settings. In older versions of Apache, the httpd.conf file was split up into access.conf, httpd.conf, and srm.conf, and some users prefer this arrangement.

If you have performed a standard installation, then the httpd.conf file can be found at /etc/httpd/conf.This is the default configuration file path of the php.ini file on the Apache Webserver.

PHP Settings on the Nginx Webserver

Text-based configuration files are used by Nginx to govern its behavior. The default location is usually /etc/nginx/. You may also find a few different config files here, though the location may vary depending on the installation settings. The primary configuration file is nginx.conf.

  • The Nginx configuration folder default location is:
  • /etc/nginx/
  • This is the most likely default location for all typical installations.

Originally published on The Tech Trend

--

--

The Tech Trend

The Tech Trend is a leading platform of news & information on the latest Tech, Business Growth, Startup, Digital Innovation, Reviews, Fintech, & many more.