How to change common php settings on an ubuntu 18


PHP. is a hệ thống side scripting language used by many popular CMS and blog platforms like WordPress and Drupal. It is also part of the popular LAMP & LEMP stacks. Updating the PHP configuration settings is a comtháng task when setting up a PHP-based trang web. Locating the exact PHPhường configuration file may not be easy. There are multiple installations of PHP.. running normally on a server, và each one has its own configuration tệp tin. Knowing which tệp tin to edit and what the current settings are can be a bit of a mystery.

Bạn đang xem: How to change common php settings on an ubuntu 18

This guide will show how lớn view the current PHPhường configuration settings of your web hệ thống & how khổng lồ make updates khổng lồ the PHP. settings.


For this guide, you need the following:

Ubuntu 14.04 DropletA website hệ thống with PHP installed.

There are many web hệ thống configurations with PHPhường, but here are two common methods:

This tutorial is applicable lớn these One-click Apps as well:


Note: This tutorial assumes you are running Ubuntu 14.04. Editing the php.ini tệp tin should be the same on other systems, but the file locations might be different.

All the commands in this tutorial should be run as a non-root user. If root access is required for the commvà, it will be preceded by subởi vì.

Reviewing the PHPhường. Configuration

You can nhận xét the live PHP configuration by placing a page with a phpinfo function along with your website files.

To create a tệp tin with this comm&, first change into the directory that contains your trang web files. For example, the default directory for webpage files for Apađậy on Ubuntu 14.04 is /var/www/html/:

cd /var/www/htmlThen, create the info.php file:

suvày nano /var/www/html/info.phpPaste the following lines inkhổng lồ this tệp tin và save it:


Note: Some One-cliông chồng Apps have an info.php tệp tin placed in the web root automatically.

When visiting the info.php tệp tin on your web hệ thống ( you will see a page that displays details on the PHPhường environment, OS version, paths, and values of configuration settings. The file to lớn the right of the Loaded Configuration File line shows the proper tệp tin to lớn edit in order lớn update your PHP.. settings.

Xem thêm: Phần Mềm Xlstylestool For Windows 8, Download Tải Kutools For Excel Free Download


This page can be used lớn reveal the current settings your website VPS is using. For example, using the Find function of your website browser, you can search for the settings named post_max_sizeupload_max_filesize to lớn see the current settings that restrict tệp tin upload sizes.

Warning: Since the info.php tệp tin displays version details of the OS, Web Server, & PHPhường, this tệp tin should be removed when it is not needed lớn keep the hệ thống as secure as possible.

Modifying the PHPhường Configuration

The php.ini file can be edited to lớn change the settings and configuration of how PHP functions. This section gives a few common examples.

Sometimes a PHPhường application might need lớn allow for larger upload files such as uploading themes and plugins on a WordPress site. To allow larger uploads for your PHP.. application, edit the php.ini file with the following command (Change the path & file lớn match your Loaded Configuration File. This example shows the path for Apabịt on Ubuntu 14.04.):

suvị nano /etc/php5/apache2/php.iniThe mặc định lines that control the tệp tin size upload are:


post_max_kích thước = 8Mupload_max_fileform size = 2MChange these mặc định values khổng lồ your desired maximum file upload kích cỡ. For example, if you needed lớn upload a 30MB file you would changes these lines to:


post_max_kích cỡ = 30Mupload_max_filesize = 30MOther comtháng resource settings include the amount of memory PHP can use as mix by memory_limit:


memory_limit = 128Mor max_execution_time, which defines how many seconds a PHP. process can run for:


max_execution_time = 30When you have sầu the php.ini tệp tin configured for your needs, save the changes, và exit the text editor.

Restart the web VPS to lớn enable the changes. For Apabịt on Ubuntu 14.04, this command will restart the web server:

suvì service apache2 restartRefreshing the info.php page should now show your updated settings. Remember to lớn remove the info.php when you are done changing your PHP configuration.


Many PHP-based applications require slight changes lớn the PHP configuration. By using the phpinfo function, the exact PHP. configuration tệp tin và settings are easy lớn find. Use the method described in this article khổng lồ make these changes.