Various PHP installation and expansion methods
PHP has various installation and expansion methods, including package-managed yum installation, pecl installation, and underlying source code compilation and installation.
Package-managed installation and uninstallation are particularly convenient, while source code-compiled installation facilitates parameter optimization.
We recommend package-managed installation to build a local development environment to save time. For the online deployment environment, it is recommended to compile and install the environment to facilitate optimization.
Install yum
# Yum installation can automatically install extended. so dynamic library, and configure php. ini # such as installing mysql expand yum search mysql | grep php # We search to expand the name of the php-mysql.x86_64sudo yum install php-mysql # so php-mysql expansion will be installed # if the emergence of extended version and php version conflict, you can install any of the following yum sources: atomic-release.noarchwebtatic-release.noarch # these sources provide php extensions for other versions, and each source provides multiple versions for specific extensions, you just need to install one source. For example: atomic source can search for mysql 5.4 expansion atomic-php54-php-mysql.x86_64 webtatic source can search for mysql 5.5 expansion php55w-mysql.x86_64
Pecl installation
# We need to download the go-pear tool from the pear official website # This tool will help us install the pecl package manager (manage php C extension) pear package manager (manage php class libraries) at the same time) wget http://pear.php.net/go-pear.phar# installation tool # installation process unless specifically specified, otherwise, install the tool to the/home/username/pear/bin directory by default. php go-pear.phar # add the tool directory to the environment variable # Edit/etc/profile to append a line of configuration export PATH = $ PATH: /home/username/pear/bin # configure the loading environment source/etc/profile # configure the php_ini option of the tool, so that the pecl tool can automatically configure php during the installation and expansion. ini file # vim/home/user name/pear/share/pear/PEAR/Config. php # Search for php_ini and modify the default key to your php. ini file path: 'php _ ini '=> array ('type' => 'File', 'default' =>'/etc/php. ini ', 'Doc' => 'location of php. ini in which to enable PECL extensions on install ', 'propt' => 'php. ini location ', 'group' => 'File Locations (Advanced)',), # confirm, pecl config-get php_ini # After successful configuration,/etc/php is displayed. ini # search for mysql to expand pecl search mysql # The update tool is usually prompted, so we will update sudo pecl channel-update pecl.php.net # search for mysql again, pecl search mysql # install and expand pecl install mysql
Source code compilation and installation
# Brief introduction: add it next time # Download the extended source code, go to the source code directory, and run the phpize command to generate the configure detection script for the compilation configuration file, # execute the configure script and generate the compilation configuration file makefile with parameters # make & make install the dynamic library that vividly expands # migrate the generated extended dynamic library. so file to php. # php. ini adds configuration information for this extension in the section.
Check whether mysql expansion is successfully installed
php -i | grep mysql
After successful installation, the above command displays the mysql expansion status information in a section.
However, you need to restart to expand the load to the running environment.Web servicesOrPhp-fpm