环境: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
1 cd /usr/local/src/php-5.6.13/ext/pdo_mysql/ 2 /usr/local/php/bin/phpize # /usr/local/php为php安装后的目录 3 ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql 4 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中引用
1 server { 2 listen 80; 3 server_name 127.0.0.1; 4 location / { 5 root /html/htdocs_xxx/; 6 index index.htm index.html index.php; 7 if (!-e $request_filename) { 8 rewrite ^/(.*)$ /index.php/$1 last; 9 break; 10 } 11 } 12 location ~ \.php/?.*$ { 13 root /html/htdocs_xxx/; 14 fastcgi_pass 127.0.0.1:9000; 15 fastcgi_index index.php; 16 include fastcgi.conf; 17 18 set $fastcgi_script_name2 $fastcgi_script_name; 19 if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") { 20 set $fastcgi_script_name2 $1; 21 set $path_info $2; 22 } 23 fastcgi_param PATH_INFO $path_info; 24 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2; 25 fastcgi_param SCRIPT_NAME $fastcgi_script_name2; 26 } 27 }
时间: 2024-10-29 19:11:34