首页 > √freebsd, √linux, √web, √个人碎语, √历史, √思科华为, √文章精选 > freebsd下apache+nginx+php+mysql+eaccelerator+memcache安装配置
viyin.net

freebsd下apache+nginx+php+mysql+eaccelerator+memcache安装配置

2010年4月19日 发表评论 阅读评论

freebsd下apache+nginx++++memcache安装配置
太长了。到后面没那么细心了。直接复制粘贴上来。就不加说明了。
1.安装apache

bsd1# pwd
/usr/ports/www/22
bsd1# make install clean

2.安装MYSQL
./configure –prefix=/usr/local/mysql –enable-assembler –with-charset=utf8 –enable-thread-safe-client –with-extra-charsets=all –with-big-tables –with-readline –with-ssl –with-embedded-server –enable-local-infile –with-plugins=innobase

make -j 5
make install
groupadd mysql
useradd -g mysql mysql
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db –user=mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/.
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
这是linux的安装命令。BSD照着改一下

2.安装PHP
先装组件jpeg,libpng,freetype,zlib,gd,curl,libxml2,libxslt,libmcrypt
pkg_add -r gd
pkg_add -r freetype
pkg_add -r curl
pkg_add -r libxml2
pkg_add -r libxslt
pkg_add -r libmcrypt
pkg_add -r mhash
./configure –prefix=/usr/local/php –with-config-file-path=/etc –with-apxs2=/usr/local/sbin/apxs –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir –enable-xml –disable-rpath –enable-discard-path –enable-magic-quotes –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –enable-ftp –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear –with-gettext –with-mime-magic –enable-suhosin
make &&make install
cp php.ini-dist /etc/php.ini

http://www.viyin.net

vi httpd.conf
AddType application/x-httpd-php .php

3.安装PHP扩展
tar zxvf -2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
make && make install

tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql
make
make install

tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/usr/local/php/bin/phpize
./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config –with-eaccelerator-shared-memory
make
make install
mkdir -p /usr/local/eaccelerator_cache
cat >>/etc/php.ini< [eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="1"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
eaccelerator.keys = "disk_only"
eaccelerator.sessions = "disk_only"
eaccelerator.content = "disk_only"
EOF

fetch http://www.viyin.net/vi/web/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
mkdir -p /usr/local/zend/
cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/

cat >>/etc/php.ini< [Zend Optimizer]
zend_optimizer.optimization_level=1
zend_extension="/usr/local/zend/ZendOptimizer.so"
EOF

修改php.ini文件
  手工修改:查找/etc/php.ini中的extension_dir = "./"
  修改为extension_dir = "/usr/local/bin/php/lib/php/extensions/no-debug-non-zts-20060613/"
  并在此行后增加以下几行,然后保存:
  extension = "memcache.so"
  extension = "pdo_mysql.so"
  再查找output_buffering = Off
  修改为output_buffering = On

sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\n#' /etc/php.ini
sed -i 's#output_buffering = Off#output_buffering = On#' /etc/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /etc/php.ini

nginx配置
./configure --user=www --group=www --prefix=/usr/local/nginx --without-http_rewrite_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-pcre
make
make install

修改nginx.conf
转发PHP请求到本地的81端口,让Apache处理.
location ~ \.php$ {
proxy_pass http://127.0.0.1:81;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header Content-Type;

}

bsd1# cat nginx.conf

user www www;
worker_processes 4;

http://viyin.net

error_log logs/nginx_error.log crit;

pid /usr/local/nginx/logs/nginx.pid;

worker_rlimit_nofile 65535;

events {
use kqueue;
worker_connections 65535;
}

http {
include mime.types;
default_type application/octet-stream;

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

server_tokens off;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

server {
listen 80;
server_name lwww.viyin.net viyin.net;
#access_log logs/host.access.log main;

index index.html index.htm index.php;
root /usr/www/viyin.net;

location ~ \.php$ {
proxy_pass http://127.0.0.1:81;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header Content-Type;

}
}

include server/*.conf;
}

编辑httpd.conf 。去掉#号
# Virtual hosts
Include etc/apache22/extra/httpd-vhosts.conf

编辑httpd-vhosts.conf ,绑上与nginx.conf相对应的目录和域名


ServerAdmin vi@viyin.net
DocumentRoot “/usr/www/viyin.net”
ServerName www.viyin.net
ServerAlias viyin.net
# ErrorLog “/var/log/dummy-host.example.com-error_log”
# CustomLog “/var/log/dummy-host.example.com-access_log” common

Options FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all


apache开启的模块
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule access_module libexec/apache2/mod_access.so
LoadModule setenvif_module libexec/apache2/mod_setenvif.so
LoadModule mime_module libexec/apache2/mod_mime.so
LoadModule autoindex_module libexec/apache2/mod_autoindex.so
LoadModule negotiation_module libexec/apache2/mod_negotiation.so
LoadModule alias_module libexec/apache2/mod_alias.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so

操!!!!终于结束了!!!!!!!

viyin.net
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.