Home Linux ServerWeb Server How to change php.ini parameters on OpenLiteSpeed using Docker Compose

How to change php.ini parameters on OpenLiteSpeed using Docker Compose

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

Changing php.ini parameters on OpenLiteSpeed using Docker Compose with 5 steps.

Introduction

In the previous article, AZDIGI showed you how to install WordPress with OpenLiteSpeed using Docker Compose on Ubuntu 22.04 and continuing in this article, AZDIGI will show you how to change php.ini parameters to increase performance more processing power for the server.

Implementation Guide

Step 1: Create an info file and check the configuration

  • Create an info file to pre-check the configuration

In the previous article, AZDIGI showed you how to download the ols-docker-env package directly from litespeedtech; you download and configure it at which path, then you access the right path to create the info.php file.

By default, the path I configure will be at /home/ols-docker-env/sites/localhost/html/, so we will proceed to create the info.php file with the command:

AZDIGI Tutorial
nano /home/ols-docker-env/sites/localhost/html/info.php
    

Next, add the content below to the newly created file and save it.

<?php

phpinfo();

?>
CleanShot 2022 05 17 at 17.25.08

Now open your browser and visit http://<IP-Addressem>/info.php to check the current PHP parameters.

The parameters I want to edit:

  • max_execution_time: The default parameter is 30 (seconds), I will change it to 300 (seconds).
  • memory_limit: The default parameter is 128M, I will change it to 512M
  • upload_max_filesize: The default parameter is 2M, I will change it to 64M
  • post_max_size: The default parameter is 8M, I will change it to 64M
CleanShot 2022 05 17 at 17.33.36

Step 2: Locate php.ini and copy the file out

  • Locate the php.ini file

To locate the php.ini file, you can quickly look through the info.php file in Step 1. At the check interface, you will see the Loaded Configuration File, section showing the path containing the php.ini file on openlitespeed container.

CleanShot 2022 05 17 at 18.07.57
And my php.ini file path is located at /usr/local/lsws/lsphp74/etc/php/7.4/litespeed/php.ini

After determining the location of the php.ini file, we now need to copy the php.ini file from the Openlitespeed container to be able to edit it.

  • Copy the php.ini file located in the openlitespeed container out for editing.
AZDIGI Tutorial
docker-compose exec litespeed su -c 'mv /usr/local/lsws/lsphp74/etc/php/7.4/litespeed/php.ini /usr/local/lsws/conf'
    

Note: Replace lsphp74 and 7.4 with the PHP version you are using. For example, in PHP 8.0, you will enter lsphp80 and 8.0.

Command annotation:

  • Lệnh (1): Path to save the php.ini file on your server when edited.
  • Lệnh (2): The path containing the php.ini file in the Openlitespeed container to return.
  • Command (3): IMAGE_ID of the PHP service.

Step 3: Edit the php.ini file

Now you proceed to edit the php.ini file at your server by opening the php.ini file with the following command:

AZDIGI Tutorial
nano lsws/conf/php.ini
    

Next, you find the values you need to change and save them.

CleanShot 2022 05 17 at

Step 4: Copy the file back to the Openlitespeed container

After editing the php.ini file, we will now move the edited file back to the Openlitespeed container. You do the following commands in turn:

  • Copy the file back to the Openlitespeed container
AZDIGI Tutorial
docker-compose exec litespeed su -c 'mv /usr/local/lsws/conf/php.ini /usr/local/lsws/lsphp74/etc/php/7.4/litespeed/php.ini'
    
  • Restart PHP in the container
AZDIGI Tutorial
docker-compose exec litespeed su -c 'pkill lsphp'
    
CleanShot 2022 05 18 at 08.54.50 1

Step 5: Recheck the parameters

After completing the above steps, open your browser and visithttp://<IP-Address>/info.php to check the parameters of PHP.

And below is my result, the parameters have been edited successfully.

CleanShot 2022 05 18 at 09.13.17

So in this article, AZDIGI guide you to change php.ini parameters on OpenLiteSpeed using Docker Compose with a few speedy steps. Changing php.ini parameters will increase processing performance for your server, thereby helping the work become smooth and reach the highest efficiency. Wishing you success!

You can refer to other instructions at the link below:

If you need support, 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