最小安装CentOS-6.4-x86_64-minimal
1、nginx的配置
yum -y install pcre gcc pcre-devel
yum -y install openssl-devel openssl
yum -y install make
./configure --prefix=/home/web/nginx --conf-path=/home/web/nginx/conf/nginx.conf --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --with-file-aio --with-pcre
make
make install
配置nginx的conf文件
user nginx;
worker_processes 2;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;
events {
use epoll;
worker_connections 10240;
}
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;
sendfile on;
tcp_nopush on;server_names_hash_bucket_size 128;
client_header_buffer_size 128k;
large_client_header_buffers 4 128k;
client_max_body_size 50m;#keepalive_timeout 0;
keepalive_timeout 120;#FastCgi Conf
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 128k;#启动预压缩功能,对所有类型的文件都有效
gzip_static on;#找不到预压缩文件,进行动态压缩
gzip on;
gzip_min_length 1000;
gzip_buffers 4 16k;
gzip_comp_level 5;
gzip_types text/plain application/x-javascript text/css application/xml;#gzip公共配置
#gzip_http_version 1.1
gzip_proxied expired no-cache no-store private auth;#纠结的配置
#对于ie有个bug,响应vary头后将不会缓存请求,每次都会重新发新的请求。所以,对于ie 1-6直>接禁用gzip。
gzip_disable "MSIE [1-6]\.";
#开启Http Vary头,vary头主要提供给代理服务器使用,根据Vary头做不同的处理。例如,对于支>持gzip的请求反向代理缓存服务器将返回gzip内容,不支持gzip的客户端返回原始内容。
gzip_vary on;aio on;
directio 1;
output_buffers 1 128k;include webs/*.conf;
}
配置多域名配置文件
mkdir /home/web/nginx/conf/webs
vi /home/web/nginx/conf/webs/defaults.conf
server {
listen 80;
server_name XXX.COM;#access_log logs/host.access.log main;
root /home/www/xxx.com;
index index.html index.htm index.php default.php;#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
nginx的服务启动配置
groupadd nginx
useradd -g nginx nginxvi /etc/init.d/nginx
-----------------------------
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: 234 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /home/web/nginx/conf/nginx.conf
# pidfile: /home/web/nginx/logs/nginx.pid# Source function library.
. /etc/rc.d/init.d/functions# Source networking configuration.
. /etc/sysconfig/network# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0nginx="/home/web/nginx/sbin/nginx"
prog=$(basename $nginx)NGINX_CONF_FILE="/home/web/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}restart() {
configtest || return $?
stop
start
}reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}force_reload() {
restart
}configtest() {
$nginx -t -c $NGINX_CONF_FILE
}rh_status() {
status $prog
}rh_status_q() {
rh_status >/dev/null 2>&1
}case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac-------------------------------
chmod +x /etc/init.d/nginx
/sbin/chkconfig nginx on
/sbin/chkconfig --list nginx
nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
至此,nginx配置完成。
2、安装PHP。
下载最新版本
安装支持库先
yum -y install libxml2-devel
yum -y install bzip2 bzip2-devel
yum -y install curl curl-devel
yum -y install libjpeg libjpeg-devel
yum -y install libpng libpng-devel
yum -y install freetype freetype-devel
yum -y install openldap openldap-devel
cp -frp /usr/lib64/libldap* /usr/lib/ ***64位的系统,必须这样做
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make
make install
PHP编译参数
./configure --prefix=/home/web/php --with-config-file-path=/home/web/php --with-openssl --with-zlib --with-curl --enable-gd-native-ttf --with-mysql --with-libxml-dir --with-bz2 --with-gd --enable-ftp --enable-mbstring --with-mcrypt --with-mysqli --enable-embedded-mysqli --enable-zip --enable-fpm --with-pic --enable-sockets --with-png-dir --with-freetype-dir --with-iconv-dir --with-jpeg-dir --enable-bcmath --enable-inline-optimization --disable-debug --with-mhash --enable-pcntl --with-ldap=/usr --with-xmlrpc
通过make 和make install以后
cp php.ini-production /mnt/web/php/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp /home/web/php/etc/php-fpm.conf.default /home/web/php/etc/php-fpm.confchmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig --level 2345 php-fpm on
还有一个Zend
yum -y install unzip
wget https://github.com/zend-dev/ZendOptimizerPlus/zipball/master
unzip master
cd zendtech-ZendOptimizerPlus-d6f6e6f/
/home/web/php/bin/phpize
./configure --with-php-config=/home/web/php/bin/php-config
make
make installvi /home/web/php/php.ini
-------------
zend_extension=/home/web/php/lib/php/extensions/no-debug-non-zts-20121212/opcache.so
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
下面可以启动php了
service php-fpm start