nginx连接php,nginx调用php

2020-12-18 100阅读 毓睿整理

内容简介:环境系统:freebsd7.0软件:mysql-5.0.51a、nginx-0.6.30、lighttpd-FreeBSD7.0编译安装nginx php mysql1.4.19、php-5.2.6。所有软件安装在usr本地Vhost中。如有必要,请...

环境

系统:FreeBSD7.0

软件:mysql-5.0.51a,nginx-0.6.30,lighttpd-1.4.19,php-5.2.6

所有软件都安装到/usr/local/vhost,如果需要请自行修改

一、下载源代码

cd /usr/ports/databases/mysql50-server/

make fetch

cd /usr/ports/www/nginx-devel/

make fetch

cd /usr/ports/lang/php5

make fetch

cd /usr/ports/www/lighttpd

make fetch

二、编译安装

MySQL

cd /usr/ports/distfiles/

tar -jxf mysql-5.0.51a.tar.gz

cd mysql-5.0.51a

./configure --prefix=/usr/local/vhost/mysql --with-charset=utf8 --with-extra-charsets=all --with-big-tables --with-pthread

make make install

Nginx

cd /usr/ports/devel/pcre

make install clean

cd /usr/ports/distfiles/

tar -jxf nginx-0.6.30.tar.gz

cd nginx-0.6.30

./configure --prefix=/usr/local/vhost/nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_sub_module

make make install

Lighttpd

(安装lighttpd是为了得到启动fastcgi进程)

cd /usr/ports/distfiles/

tar -jxf lighttpd-1.4.19.tar.bz2

cd lighttpd-1.4.19

./configure --prefix=/usr/local/vhost/lighttpd

Php

cd /usr/ports/textproc/libxml2

make install clean

cd /usr/ports/ftp/curl

make install clean

cd /usr/ports/graphics/jpeg

make install clean

cd /usr/ports/graphics/png

make install clean

cd /usr/ports/devel/gettext

make install clean

cd /usr/ports/distfiles/

tar -jxf php-5.2.6.tar.bz2

cd php-5.2.6

./configure --prefix=/usr/local/vhost/php --with-mysql=/usr/local/vhost/mysql -enable-fastcgi --enable-sockets --enable-ftp --enable-zip --enable-mbstring --enable-mbregex --enable-calendar --with-curl=/usr/local/clude --with-curlwrappers --disable-debug --enable-inline-optimization --with-zlib --with-gd --with-kerberos --with-gettext --enable-force-cgi-redirect --with-jpeg-dir=/usr/inlocal/clude --with-png-dir=/usr/local/include --with-bz2 --enable-pcntl --with-iconv

make make install

cp php.ini-dist /usr/local/vhost/php/lib/php.ini

三、配置

MySQL

cd /usr/local/vhost/mysql

pw adduser mysql -d /dev/null -s /sbin/nologin

bin/mysql_install_db

cp share/mysql/mysql.server ./

chmod x mysql.server

chown -R mysql ./

启动

引用:/usr/local/vhost/mysql/mysql.server start

配置nginx

cd /usr/local/vhost/nginx/

pw adduser webuser -d /dev/null -s /sbin/nologin

cp /usr/local/vhost/lighttpd/bin/spawn-fcgi ./sbin/

rm -rf /usr/local/vhost/lighttpd

vi sbin/php.sh

#!/bin/sh

/usr/local/vhost/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 8 -u webuser -f /usr/local/vhost/php/bin/php-cgi

引用:chmod x sbin/php.sh

启动php for fast-cgi

引用:sbin/php.sh

vi conf/enable_php

location ~ /.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /usr/local/vhost/nginx/html$fastcgi_script_name;

fastcgi_param QUERY_STRING $query_string;

fastcgi_param REQUEST_METHOD $request_method;

fastcgi_param CONTENT_TYPE $content_type;

fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;

fastcgi_param REQUEST_URI $request_uri;

fastcgi_param DOCUMENT_URI $document_uri;

fastcgi_param DOCUMENT_ROOT $document_root;

fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;

fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;

fastcgi_param REMOTE_PORT $remote_port;

fastcgi_param SERVER_ADDR $server_addr;

fastcgi_param SERVER_PORT $server_port;

fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect

fastcgi_param REDIRECT_STATUS 200;

}

vi conf/nginx.conf

user webuser webuser;

worker_processes 1;

events {

worker_connections 4096;

use kqueue;

}

http {

include mime.types;

default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] $request '

# '"$status" $body_bytes_sent "$http_referer" '

# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

client_header_timeout 3m;

client_body_timeout 3m;

send_timeout 3m;

client_max_body_size 5m;

client_header_buffer_size 1k;

large_client_header_buffers 4 4k;

gzip on;

gzip_min_length 1100;

gzip_buffers 4 8k;

gzip_types text/plain;

output_buffers 1 32k;

postpone_output 1460;

sendfile on;

tcp_nopush on;

tcp_nodelay on;

send_lowat 12000;

keepalive_timeout 75 20;

server {

listen 80;

server_name localhost;

location / {

root html;

index index.php index.html index.htm;

}

if (-d $request_filename){

rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;

}

location /nginx_status {

stub_status on;

access_log off;

}

include enable_php;

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}

}

测试配置文件

引用:sbin/nginx -t

2008/05/08 11:50:19 [info] 3336#0: the configuration file /usr/local/vhost/nginx/conf/nginx.conf syntax is ok

2008/05/08 11:50:19 [info] 3336#0: the configuration file /usr/local/vhost/nginx/conf/nginx.conf was tested successfully

vi html/phpinfo.php

?php

phpinfo();

?

启动测试

引用:/usr/local/vhost/nginx/sbin/nginx

在浏览器里输入

引用:http://192.168.29.128/phpinfo.php

安装配置phpMyadmin

cd /usr/ports/databases/phpmyadmin/

make fetch

cd /usr/ports/distfiles

tar -jxf phpMyAdmin-2.11.6-all-languages.tar.bz2

mv phpMyAdmin-2.11.6-all-languages /usr/local/vhost/nginx/html/dbadmin

此时MySQL的root没有密码,如果一切正常可以用

http://192.168.29.128/dbadmin/index.php来管理MySQL了

作者给您推荐的内容
  1. 很多朋友都收到了朋友发来的QQ红包。QQ红包只能通过在手机上安装最新版本的手机软件获得,但QQ红包也可QQ钱包怎么通过电脑登陆并提现?以通过电脑提取。那么如何登录QQ钱包,在电脑上取现呢?...

  2. 登录支付宝,看到支付宝页面已经被更改,当前页面有一个账号的安全等级,可以看到怎样防止支付宝被盗刷?自己账户的安全等级点击顶部的安全中心地图就可以进入支付宝安全中心,我们一进来...

  3. Office是我们常用的软件,越来越流行,但是有很多合作伙伴在使用Excel表格如何设置Excel表格自动保存?,经常会因为生产时间紧迫,或者他们有紧急情况而退出而不保存文件,下面编辑就教你如何...

  4. 随着科学技术的发展,手机已经成为人们日常生活中不可缺少的工具。当我们使用oppo手机时,如果手怎么通过oppo手机查询售后服务网点的位置机出现问题,需要到oppo的售后服务网络进行维护。接...

  5. 下载垃圾软件最麻烦的是它会绑定很多其他奇怪的软件。那我们怎么才能删除毒霸的完整网站呢?今天我们来看看。具体内容如下:1。首先,打开计算机的控制面板,然毒霸网址大全怎么才能彻底...

  6. 现在很多人在电脑安装软件时,都养成了修改安装路径的习惯,把软件安装到其他硬盘分区,可以为系统磁盘节省修改win7临时文件路径方法不少空间。但计算机使用时间长,系统磁盘的占用率会继...

  7. 1当您打开百度网站时,百度证书已过期,出网页提示您的连接不是私密连接怎么办?现“您的连接不是私有连接”的错误页面。此时,我们可以点击下面的高级按钮,如下图所示。2点击高级设置后...

  8. 我们有这篇文章向您展示一个sql2005自动备份数据库文件,然后自动将备份文件同步到其他主机教程。SQL2005下载地址软件名称:SQLServer2005软件版本:x86SQL2005自动备份及文件自动同步到网络上的主机...

  9. 许多用户在浏览网页时都会使用计算器,但多次打开Windows计算器是非常不方便的。针对这个需求,我Chrome浏览器一秒变身计算器们可以使用Chrome浏览器的计算器插件,让用户不用打开任何工具就可...

  10. 什么是TTS?TTS的功能是什么?TTS的全名是texttospeech,意思是从文本到语音。这是一部同时运用语言学和心理学的杰出著作。在内置芯片的支持下,通过神经网络的设计,可以将文本智能tts是什么意...