How to modify the port of php installed by yum

PHPz
Release: 2023-03-23 14:28:01
Original
1448 people have browsed it

When we install Apache and PHP, Apache usually listens on ports 80 and 443 (HTTP and HTTPS). However, in some cases you may want PHP to use a different port number. This article will introduce how to modify the port number of PHP installed through yum.

Step 1: Check the current PHP version

First, we need to know the PHP version installed in the current system. You can view it with the following command:

php -v
Copy after login

This will output the PHP version number installed in the system. In this article, we will use PHP 7.4 as an example.

Step 2: Install additional PHP extensions

If you are not using the standard PHP installation, you need to install additional PHP extensions. For example, if you are using PHP-FPM, you need to install the extension. It can be installed through the following command:

yum install php-fpm
Copy after login

After installing this extension, you can use it to modify the port number and also extend other functions.

Step 3: Edit php.ini settings

Now, we need to modify the php.ini configuration file to change the port number. The configuration file can be opened using the following command:

vim /etc/php.ini
Copy after login

In this file, the listen option can be found to configure the port number used by PHP-FPM. In this article, we will use the 9000 port.

listen = 9000
Copy after login

You can also change other settings in this file, such as max_execution_time and memory_limit etc.

Step 4: Restart the PHP service

After completion, restart the PHP service to apply the changes.

systemctl restart php-fpm
Copy after login

Now, your PHP service has been updated to use the new port number. You can check if it is available with the following command:

curl http://localhost:9000
Copy after login

If you are using PHP-FPM, you can also check the php-fpm logs to make sure the service is working properly.

Conclusion

As can be seen from the above steps, it is also very easy to modify the port number through PHP installed with yum. As long as you know the version of PHP installed on your system and install the required additional extensions, you can change the port number and restart the PHP service to take effect.

The above is the detailed content of How to modify the port of php installed by yum. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template