Home >Backend Development >PHP Problem >php5.6.15 installation tutorial
php5.6.15 installation method: 1. Prepare the installation files; 2. Prepare the installation environment and necessary packages; 3. Install through the command install; 4. Configure the php-fpm service; 5. Restart the httpd service; 6. Modify the client listening address and port to allow nginx access.
The operating environment of this article: nginx1.0.4 system, php5.6.15 version, DELL G3 computer
PHP 5.6.15 compilation and installation
1. Prepare the installation files
php-5.6.15.tar http://php.net/downloads.php
2. Prepare the installation environment and necessary packages
yum install -y libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel yum install gcc gcc-c++ #编译工具
If you want the compiled php to support mcrypt extension, you need to install libmcrypt libmcrypt-devel or compile and install
tar -zxvf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure make && make install
3. Install
cd php-5.6.15 ./configure --prefix=/usr/local/php5615 --with-config-file-path=/usr/local/php5615/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=www --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-opcache --enable-mbstring --enable-soap --enable-zip --enable-bcmath --with-openssl --with-zlib --with-curl --with-gd --with-zlib-dir=/usr/lib --with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-mhash --with-apxs2=/usr/local/apache/bin/apxs
Note that the last line points to the apxs location. If you don't know, just find / -name "apxs" to find it, so that php will generate
after compilation into libphp5.so for apache to call. If the system is not installed, you can install it through yum -y install httpd-devel
The first line is the installation location. I installed it in the /usr/local/php5615 directory. You can change it yourself. Then make && make install
4. Subsequent configuration
(a). Configure php-fpm service
in php5 Versions of php-fpm before .3.3 exist in the form of a patch package, and php-fpm after php5.3.3 only needs to be installed with --enable-fpm to enable this function.
After the compilation and installation is completed, you need to copy the php-fpm.conf.default configuration example file in the installed etc directory and rename it as a configuration file
(b) . Add system startup service
Enter the installation source file directory
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm56 chmod+x /etc/init.d/php-fpm56 chkconfig --add php-fpm56 service php-fpm56 start ss -tnl
We can clearly see that php-fpm has started normally.
Note that php-fpm listens to port 9000 by default.
(c). php.ini configuration file
Copy php.ini-production in the source code directory to the configuration file directory /usr/local/ specified during compilation Under php5615/etc, and rename
to php.ini (the default path of php.ini can also be viewed by writing an index.php file and using phpinfo())
4. Combining php with apache
Modify apache’s http.conf configuration file
(a) Add LoadModulephp5_module modules/libphp5. So
Pay attention to check whether there is already the line in the configuration file. ## Use apache's FilesMatch
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
If you want files ending in .php, .php2, .php3, .php4, .php5, .php6, .phtml, use apache
as php To execute, you can write like this:
<FilesMatch \.php$> etHandlerapplication/x-httpd-php </FilesMatch>
(c) Locate DirectoryIndex index.html
Modify to: DirectoryIndex index.php index.html
5. Test
Restart the httpd service, write an index.php and use phpinfo() to see the effect, and test the database connection by the way. If everything is normal, you can see the php information
<FilesMatch "\.ph(p[2-6]?|tml)$"> SetHandlerapplication/x-httpd-php </FilesMatch>
6. Combining php with Nginx
If php and nginx are not on the same machine, change the client listening address and port in the php configuration file to allow nginx to access
<?php $conn =mysql_connect('127.0.0.1','root','123456'); if($conn) echo succ; else echo fail; mysql_close(); phpinfo(); ?>
Configure nginx to support php, as follows:
vim /usr/local/php/etc/php-fpm.conf listen=192.168.61.161:9000;
Then create a new index.php in the root directory of the nginx website File test, the content is as follows:
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
If the detailed information of php can be displayed, it is normal
php Some installation parameter descriptions
vim /usr/local/nginx/html/index.php <?php phpinfo(); ?>
Recommended study: "
PHP Video Tutorial"
The above is the detailed content of php5.6.15 installation tutorial. For more information, please follow other related articles on the PHP Chinese website!