FreeBSD7.0编译安装nginx+php+mysql_Unix/BSD教程-查字典教程网
FreeBSD7.0编译安装nginx+php+mysql
FreeBSD7.0编译安装nginx+php+mysql
发布时间:2016-12-27 来源:查字典编辑
摘要:环境系统:FreeBSD7.0软件:mysql-5.0.51a,nginx-0.6.30,lighttpd-1.4.19,php-5.2.6...

环境

系统: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/

makefetch

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

makefetch

cd/usr/ports/lang/php5

makefetch

cd/usr/ports/www/lighttpd

makefetch

二、编译安装

MySQL

cd/usr/ports/distfiles/

tar-jxfmysql-5.0.51a.tar.gz

cdmysql-5.0.51a

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

make&&makeinstall

Nginx

cd/usr/ports/devel/pcre

makeinstallclean

cd/usr/ports/distfiles/

tar-jxfnginx-0.6.30.tar.gz

cdnginx-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&&makeinstall

Lighttpd

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

cd/usr/ports/distfiles/

tar-jxflighttpd-1.4.19.tar.bz2

cdlighttpd-1.4.19

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

Php

cd/usr/ports/textproc/libxml2

makeinstallclean

cd/usr/ports/ftp/curl

makeinstallclean

cd/usr/ports/graphics/jpeg

makeinstallclean

cd/usr/ports/graphics/png

makeinstallclean

cd/usr/ports/devel/gettext

makeinstallclean

cd/usr/ports/distfiles/

tar-jxfphp-5.2.6.tar.bz2

cdphp-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&&makeinstall

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

三、配置

MySQL

cd/usr/local/vhost/mysql

pwaddusermysql-d/dev/null-s/sbin/nologin

bin/mysql_install_db

cpshare/mysql/mysql.server./

chmod+xmysql.server

chown-Rmysql./

启动

引用:/usr/local/vhost/mysql/mysql.serverstart

配置nginx

cd/usr/local/vhost/nginx/

pwadduserwebuser-d/dev/null-s/sbin/nologin

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

rm-rf/usr/local/vhost/lighttpd

visbin/php.sh

#!/bin/sh

/usr/local/vhost/nginx/sbin/spawn-fcgi-a127.0.0.1-p9000-C8-uwebuser-f/usr/local/vhost/php/bin/php-cgi

引用:chmod+xsbin/php.sh

启动phpforfast-cgi

引用:sbin/php.sh

viconf/enable_php

location~.php${

roothtml;

fastcgi_pass127.0.0.1:9000;

fastcgi_indexindex.php;

fastcgi_paramSCRIPT_FILENAME/usr/local/vhost/nginx/html$fastcgi_script_name;

fastcgi_paramQUERY_STRING$query_string;

fastcgi_paramREQUEST_METHOD$request_method;

fastcgi_paramCONTENT_TYPE$content_type;

fastcgi_paramCONTENT_LENGTH$content_length;

fastcgi_paramSCRIPT_NAME$fastcgi_script_name;

fastcgi_paramREQUEST_URI$request_uri;

fastcgi_paramDOCUMENT_URI$document_uri;

fastcgi_paramDOCUMENT_ROOT$document_root;

fastcgi_paramSERVER_PROTOCOL$server_protocol;

fastcgi_paramGATEWAY_INTERFACECGI/1.1;

fastcgi_paramSERVER_SOFTWAREnginx/$nginx_version;

fastcgi_paramREMOTE_ADDR$remote_addr;

fastcgi_paramREMOTE_PORT$remote_port;

fastcgi_paramSERVER_ADDR$server_addr;

fastcgi_paramSERVER_PORT$server_port;

fastcgi_paramSERVER_NAME$server_name;

#PHPonly,requiredifPHPwasbuiltwith--enable-force-cgi-redirect

fastcgi_paramREDIRECT_STATUS200;

}

viconf/nginx.conf

userwebuserwebuser;

worker_processes1;

events{

worker_connections4096;

usekqueue;

}

http{

includemime.types;

default_typeapplication/octet-stream;

#log_formatmain'$remote_addr-$remote_user[$time_local]$request'

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

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

#access_loglogs/access.logmain;

client_header_timeout3m;

client_body_timeout3m;

send_timeout3m;

client_max_body_size5m;

client_header_buffer_size1k;

large_client_header_buffers44k;

gzipon;

gzip_min_length1100;

gzip_buffers48k;

gzip_typestext/plain;

output_buffers132k;

postpone_output1460;

sendfileon;

tcp_nopushon;

tcp_nodelayon;

send_lowat12000;

keepalive_timeout7520;

server{

listen80;

server_namelocalhost;

location/{

roothtml;

indexindex.phpindex.htmlindex.htm;

}

if(-d$request_filename){

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

}

location/nginx_status{

stub_statuson;

access_logoff;

}

includeenable_php;

error_page500502503504/50x.html;

location=/50x.html{

roothtml;

}

}

}

测试配置文件

引用:sbin/nginx-t

2008/05/0811:50:19[info]3336#0:theconfigurationfile/usr/local/vhost/nginx/conf/nginx.confsyntaxisok

2008/05/0811:50:19[info]3336#0:theconfigurationfile/usr/local/vhost/nginx/conf/nginx.confwastestedsuccessfully

vihtml/phpinfo.php

<?php

phpinfo();

?>

启动测试

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

在浏览器里输入

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

安装配置phpMyadmin

cd/usr/ports/databases/phpmyadmin/

makefetch

cd/usr/ports/distfiles

tar-jxfphpMyAdmin-2.11.6-all-languages.tar.bz2

mvphpMyAdmin-2.11.6-all-languages/usr/local/vhost/nginx/html/dbadmin

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

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

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Unix/BSD学习
    热门Unix/BSD学习
    操作系统子分类