Home > Article > Backend Development > How to modify the port of php installed by yum
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.
First, we need to know the PHP version installed in the current system. You can view it with the following command:
php -v
This will output the PHP version number installed in the system. In this article, we will use PHP 7.4 as an example.
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
After installing this extension, you can use it to modify the port number and also extend other functions.
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
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
You can also change other settings in this file, such as max_execution_time
and memory_limit
etc.
After completion, restart the PHP service to apply the changes.
systemctl restart php-fpm
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
If you are using PHP-FPM, you can also check the php-fpm
logs to make sure the service is working properly.
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!