thinkphp nginx+phpcgj安装配置

时间:2024-01-02 21:02:14

环境:mysql-5.6.26             nginx-1.9.4.tar.gz   php-5.6.13

程序框架ThinkPHP

客户要求必须使用nginx + php

1.首先安装nginx ,mysql ,php

2.安装扩展php扩展:pdo_mysql

 cd /usr/local/src/php-5.6./ext/pdo_mysql/
/usr/local/php/bin/phpize # /usr/local/php为php安装后的目录
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
sudo make && sudo make install

3.修改php.ini文件

sudo vi /usr/local/php/lib/php.ini

增加以下内容:

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-x x x x/"
extension = pdo_mysql.so

4.修改php.ini文件

php.ini(/usr/local/php/etc/php.ini)的配置中中找到

  cgi.fix_pathinfo=0

  将其改成

  cgi.fix_pathinfo=1

5.在nginx/conf/vhosts/目录下创建一个配置文件,并在nginx.conf中引用

 server {
listen ;
server_name 127.0.0.1;
location / {
root /html/htdocs_xxx/;
index index.htm index.html index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$ last;
break;
}
}
location ~ \.php/?.*$ {
root /html/htdocs_xxx/;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi.conf; set $fastcgi_script_name2 $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
set $fastcgi_script_name2 $;
set $path_info $;
}
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
}
}