nginx connection PHP 5.5 - ttlsa tutorial series nginx

This year IT renewal too quickly, nginx version 1.0 from 2 years ago to the current 1.5 version, each version to develop. Php PHP from the beginning to the current 5.2 5.3 / 5.4 / 5.5. Drafting of this article, I noticed an official has stopped the development of 5.3, the final version to 5.3.27 freeze, will fix some bug, declared the demise of 5.3 a. and suggest that you upgrade to 5.4 or 5.5, in view of the updated version so quickly, decided to write a nginx connection php5.5 article. Ever since, herbal finished article. 1. installation PHP 5.5.0
  •  download
cd /usr/local/src/
wget http://www.php.net/get/php-5.5.0.tar.bz2/from/jp1.php.net/mirror
# If the above PHP does not exist, you can go directly to the official download. If you still can not find a message, I will be sent through the mail.
  • Installation dependencies
Ensure installation gd, png, curl, xml, etc. lib development library before installation. If you are unsure, execute the following command:
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
  • Compile and install PHP 5.5.0
The following parameters are supported, ftp, picture function, pdo and other support, because of the use php comes mysqlnd, so no additional installation of mysql lib a library. If you are a 64-bit system, following the argument plus --with-libdir = lib64, if you can not skip.
tar -xjf php-5.5.0.tar.bz2
cd php-5.5.0
./configure --prefix=/usr/local/php-5.5.0 --with-config-file-path=/usr/local/php-5.5.0/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64
make
make install
NOTE: If you do not need to curl and PHP ftp support, can be more than --with-curl --enable-ftp get rid of if you are a professional linux practitioners, you can look at to help you select the installation parameters. If you do not, I suggest you just copy paste my configuration parameters. this can take some detours less.
  • Php configuration
cp php.ini-production /usr/local/php-5.5.0/etc/php.ini
cp /usr/local/php-5.5.0/etc/php-fpm.conf.default /usr/local/php-5.5.0/etc/php-fpm.conf
  • Start php-fpm
/usr/local/php-5.5.0/sbin/php-fpm
Execute the above command, if no error under normal circumstances indicating that the startup is normal, if not assured, can also be judged by the port PHP whether to start
# netstat -lnt | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
2, the installation configuration nginx
  • Install nginx
See <ttlsa tutorial series nginx - nginx installation>
  •  Configuration Test Site test.ttlsa.com
mkdir /data/logs/nginx/ # 用于存放nginx日志.请看2.3的配置文件
mkdir -p /data/site/test.ttlsa.com/ # 站点根目录
vim /data/site/test.ttlsa.com/info.php
Save and exit
  • nginx configuration
Add the following http-off in nginx.conf in:
server {
listen 80;
server_name test.ttlsa.com;
access_log /data/logs/nginx/test.ttlsa.com.access.log main;

index index.php index.html index.html;
root /data/site/test.ttlsa.com;

location /
{
try_files $uri $uri/ /index.php?$args;
}

location ~ .*\.(php)?$
{
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;

}
}
  • Configuration explain
nginx will connect the port to perform loopback address 9000 PHP file, you need to use tcp / ip protocols, more slowly. We recommend the use of socket replaced connected. The fastcgi_pass 127.0.0.1:9000; changed fastcgi_pass unix: /var/run/phpfpm.sock;
  • Start nginx
/usr/local/nginx-1.4.1/sbin/nginx
3. Access Test
# curl http://test.ttlsa.com/info.php
test php
As content appears, indicating that PHP installation is complete. Please indicate the source: ttlsa tutorial series nginx - nginx connection 5.5 PHP http://www.ttlsa.com/html/1548.html

Reproduced in: https: //my.oschina.net/766/blog/211301

Guess you like

Origin blog.csdn.net/weixin_33862188/article/details/91546707