FreeBSD上搭建nginx 07x + PHP 53xFastCGI第二版Word文档格式.docx
- 文档编号:17368859
- 上传时间:2022-12-01
- 格式:DOCX
- 页数:14
- 大小:22.07KB
FreeBSD上搭建nginx 07x + PHP 53xFastCGI第二版Word文档格式.docx
《FreeBSD上搭建nginx 07x + PHP 53xFastCGI第二版Word文档格式.docx》由会员分享,可在线阅读,更多相关《FreeBSD上搭建nginx 07x + PHP 53xFastCGI第二版Word文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
/usr50GB
/data40GB
/home55GB
FreeBSD不同于Linux,我们最小化安装FreeBSD后,系统中并没有wget(可能完全安装也没有,呵呵),因为我已经习惯了使用wget进行下载,所以为了可以在FreeBSD中使用wget,我们需要安装wget,方法如下:
cd/usr/ports/ftp/wget
makeinstallclean
#在出现的对话框中去掉IPV6前面的选择
刚刚安装完后,wget并未能使用,需要执行下面的命令后方可生效。
rehash
一、首先,我们来安装nginx。
安装Nginx前,需要先安装pcre,因为nginx需要pcre支持。
FreeBSD8.0-Release已经包含了pcre7.9,所以选择安装Package的时候,选择上pcre即可。
或者使用ports方式安装pcre。
ports方式安装如下:
cd/usr/ports/devel/pcre
1、下载与解压nginx
wgethttp:
//sysoev.ru/nginx/nginx-0.7.67.tar.gz
tarzxvfnginx-0.7.67.tar.gz
cdnginx-0.7.67
2、修改nginx原文件。
如果不进行修改,nginx编译会以debug方式编译,编译后的文件有3兆之巨。
经以下修改后,文件减小到500KB左右。
cdauto/cc
vigcc
将文件最后的
#debug
CFLAGS="
$CFLAGS-g"
修改为
#CFLAGS="
3、编译安装nginx。
因为在安装FreeBSD的时候,已经内建了www用户和www用户组,因此不需要在自己建立了。
这是与在Linux上安装的一个小小区别。
cd../../
./configure--user=www--group=www--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module--with-http_sub_module
make
makeinstall
如果要开机后自动启动nginx,那么需要在/etc/rc.local中加入一行命令:
/usr/local/nginx/sbin/nginx
二、接下来,我们来安装MySQL,因为安装PHP需要用到MySQL支持,所以要先于PHP安装。
wget
tarzxvfmysql-5.1.47.tar.gz
cdmysql-5.1.47
./configure--prefix=/usr/local/mysql/--enable-assembler--with-extra-charsets=complex--enable-thread-safe-client--with-big-tables--with-readline--with-ssl--with-embedded-server--enable-local-infile--with-plugins=innobase--with-mysqld-user=mysql--without-ndb-debug--without-debug--with-charset=utf8--localstatedir=/data/mysql/data--with-collation=utf8_general_ci
make
如果你希望在这台服务器上运行MySQL数据库服务端,那么执行以下步骤。
1、创建mysql的用户及用户组(这点与Linux稍有不同)
pwgroupaddmysql
pwuseraddmysql-gmysql-d/data/mysql-s/usr/sbin/nologin
2、创建MySQL数据存放目录
mkdir-p/data/mysql/data/
chown-Rmysql:
mysql/data/mysql/
3、以mysql用户的身份建立数据表
/usr/local/mysql/bin/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/mysql/data--user=mysql
4、创建配置文件
cd/usr/local/mysql/share/mysql
cpmy-f/etc/f
cpmysql.server/usr/local/mysql/mysqld
chmod755/usr/local/mysql/mysqld
5、打开/etc/rc.local,如果不存在的话,就新建一个,输入以下内容:
/usr/local/mysql/mysqldstart
6、创建一个可以远程登录的root账户,密码是123456,这样我们就可以使用mysql连接工具进行远程管理了。
/usr/local/mysql/bin/mysql-uroot-p-S/tmp/mysql.sock
GRANTALLPRIVILEGESON*.*TO'
root'
@'
%'
IDENTIFIEDBY'
123456'
;
quit
三、编译安装PHP(FastCGI)
1、编译安装PHP5.3.2所需的支持库
//ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gz
tarzxvflibiconv-1.13.tar.gz
cdlibiconv-1.13/
./configure--prefix=/usr
cd..
wget"
tarzxvflibmcrypt-2.5.8.tar.gz
cdlibmcrypt-2.5.8
tarzxvfmhash-0.9.9.9.tar.gz
cdmhash-0.9.9.9
tarzxvfmcrypt-2.6.8.tar.gz
cdmcrypt-2.6.8
cdsrc
virfc2440.c
FreeBSD与Linux的不同点,造成需要对mcrypt的源码进行一下小小的修改,才能在FreeBSD下编译通过。
将其中的
#include<
malloc.h>
stdlib.h>
然后继续编译
2、编译安装PHP5.3.2
wget
//php-fpm.org/downloads/0.6/php-fpm-0.6~5.3.tar.gz
tarzxvfphp-5.3.2.tar.gz
tarzxvfphp-fpm-0.6~5.3.tar.gz
php-fpm-0.6-5.3/generate-fpm-patch
cdphp-5.3.2
patch-p1<
../fpm.patch
./buildconf--force
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-iconv-dir=/usr--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr/local--enable-xml--disable-rpath--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curl--with-curlwrappers--enable-mbregex--with-fpm--enable-mbstring--with-mcrypt--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--disable-ipv6--without-pear
makeZEND_EXTRA_LIBS='
-liconv'
cpphp.ini-production/usr/local/php/php.ini
3、安装PHP扩展
安装扩展前,有些扩展需要一些包支持,所以先要安装以下包。
cd/usr/ports/devel/autoconf262
接下来就可以顺利安装PHP扩展了。
tarzxvfmemcache-2.2.5.tgz
cdmemcache-2.2.5
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
tarjxvfeaccelerator-0.9.6-rc1.tar.bz2
cdeaccelerator-0.9.6-rc1
./configure--enable-eaccelerator=shared--with-php-config=/usr/local/php/bin/php-config
tarzxvfPDO_MYSQL-1.0.2.tgz
cdPDO_MYSQL-1.0.2
./configure--with-php-config=/usr/local/php/bin/php-config--with-pdo-mysql=/usr/local/mysql
wgetftp:
//mirror.aarnet.edu.au/pub/imagemagick/ImageMagick-6.5.4-2.tar.gz
tarzxvfImageMagick-6.5.4-2.tar.gz
cdImageMagick-6.5.4-2
./configure
tarzxvfimagick-2.2.2.tgz
cdimagick-2.2.2
4、修改php.ini
vi/usr/local/php/php.ini
查找output_buffering=4096
修改为output_buffering=On
再查找extension_dir="
./"
修改为extension_dir="
/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
并在此行后增加以下几行,然后保存:
extension="
memcache.so"
pdo_mysql.so"
imagick.so"
eaccelerator.so"
5、配置eAccelerator,加速PHP
mkdir-p/data/php/eaccelerator_cache
在文件末尾增加下面的内容。
[eaccelerator]
eaccelerator.shm_size="
64"
eaccelerator.cache_dir="
/data/php/eaccelerator_cache"
eaccelerator.enable="
1"
eaccelerator.optimizer="
eaccelerator.check_mtime="
eaccelerator.debug="
0"
eaccelerator.filter="
"
eaccelerator.shm_max="
eaccelerator.shm_ttl="
3600"
eaccelerator.shm_prune_period="
eaccelerator.shm_only="
press="
press_level="
9"
6、开机启动php-fpm
vi/etc/rc.local
增加下面语句
/usr/local/php/bin/php-fpmstart
四、配置nginx使其支持PHP
1、创建网站根目录
mkdir-p/data/www
chmod+w/data/www
chown-Rwww:
www/data/www
2、创建PHP测试页
vi/data/www/index.php
在文件中输入以下内容
<
?
php
phpinfo();
>
3、修改/usr/local/nginx/conf/nginx.conf如下:
user
wwwwww;
worker_processes
8;
events{
usekqueue;
worker_connections
51200;
}
http{
include
mime.types;
default_type
application/octet-stream;
server_names_hash_bucket_size128;
client_header_buffer_size32k;
large_client_header_buffers432k;
client_max_body_size8m;
sendfile
on;
tcp_nopush
on;
keepalive_timeout
65;
fastcgi_connect_timeout300;
fastcgi_send_timeout300;
fastcgi_read_timeout300;
fastcgi_buffer_size64k;
fastcgi_buffers464k;
fastcgi_busy_buffers_size128k;
fastcgi_temp_file_write_size128k;
gzip
gzip_min_length
1k;
gzip_buffers
416k;
gzip_http_version1.0;
gzip_comp_level2;
gzip_types
text/plainapplication/x-javascripttext/cssapplication/xml;
gzip_varyon;
tcp_nodelayon;
server{
listen
80;
server_name
192.168.1.3;
root
/data/www;
indexindex.htmlindex.php;
location~.*\.(php|php5)?
${
fastcgi_pass
127.0.0.1:
9000;
fastcgi_index
index.php;
fastcgi.conf;
error_page
500502503504
/50x.html;
location=/50x.html{
html;
4、修改/usr/local/nginx/conf/fastcgi.conf文件,在其最前面加入如下代码:
if($request_filename~*(.*)\.php){
set$php_url$1;
if(!
-e$php_url.php){
return404;
5、修改/usr/local/etc/php-fpm.conf文件如下:
xmlversion="
1.0"
?
configuration>
Allrelativepathsinthisconfigarerelativetophp'
sinstallprefix
sectionname="
global_options"
Pidfile
valuename="
pid_file"
/usr/local/php/logs/php-fpm.pid<
/value>
Errorlogfile
error_log"
/usr/local/php/logs/php-fpm.log<
Loglevel
log_level"
notice<
WhenthisamountofphpprocessesexitedwithSIGSEGVorSIGBUS...
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- FreeBSD上搭建nginx 07x PHP 53xFastCGI第二版 FreeBSD 搭建 nginx 07 53 xFastCGI 第二
链接地址:https://www.bdocx.com/doc/17368859.html