Edit the PHP configurations on a cloud server with Linux

Learn how to change the PHP configurations on a Cloud Server with Linux by locating and editing the php.ini file.


    • A Cloud Server with Linux (any distribution)

    Cloud backup from IONOS

    Make costly downtime a thing of the past and back up your business the easy way!


    View the server's PHP configurations

    To view the current PHP configurations of your server, create a file named phpinfo.php in your website's main directory:

    sudo nano /var/www/html phpinfo.php

    Put the following content into this file:

    <?php phpinfo() ?>

    Save and exit the file, then view it in a browser (http://example.com/phpinfo.php).

    For security reasons, it is best to delete this file after you are finished.

    Find the php.ini file

    When PHP starts up, it will search several possible locations on the server for a php.ini file. The default location for the php.ini file is:

    • Ubuntu 16.04:/etc/php/7.0/apache2
    • CentOS 7:/etc/php.ini

    You can also create a new php.ini file with only the configurations you need to change, and place it in the same directory as the PHP script. This will override the configurations in the default php.ini file.

    However, this will only be effective for scripts in the same directory as the php.ini file. It will not affect subdirectories. You will need to copy the new php.ini file to each working directory.

    Edit the php.ini file

    To open the default php.ini file for editing:

    • Ubuntu 16.04:sudo nano /etc/php/7.0/apache2
    • CentOS 7:sudo nano /etc/php.ini

    Make the required changes. Each line which begins with a semicolon is "commented out," which means that PHP will ignore that line. If you are enabling an option which is disabled this way, delete the semicolon at the beginning of the line to enable it.

    Save and exit the file. Then restart the web server in order for the changes to take effect:

    • Ubuntu/Debian:sudo systemctl restart apache2
    • CentOS:sudo systemctl restart httpd

    Own your online success
    IONOS takes care of your online challenges
    Create your website with the perfect domain and the UK's fastest hosting!