How to install php5.6.15: 1. Prepare the installation files; 2. Prepare the installation environment and necessary packages; 3. Pass "cd php-5.6.15 ./configure --prefix=/usr/local /php5615..." command to install PHP; 4. Configure the fpm service.
The operating environment of this article: windows7 system, php version 5.6.15, DELL G3 computer
How to install php 5.6.15?
PHP 5.6.15 Compile and install
1. Prepare installation files
php-5.6.15.tar http://php.net/downloads.php
2. Prepare 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++ #编译工具如果想让编译的php支持mcrypt扩展,需安装libmcrypt libmcrypt-devel 或者编译安装 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 Find / -name "apxs" look for 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-fpm56chmod+x /etc/init.d/php-fpm56chkconfig --add php-fpm56service php-fpm56 startss -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 you can display the detailed information of php, it is normal
7. php some Installation parameter description
vim /usr/local/nginx/html/index.php<?php phpinfo(); ?>
Recommended study: "
PHP Video Tutorial"
The above is the detailed content of How to install php 5.6.15. For more information, please follow other related articles on the PHP Chinese website!