http://simply.blog.51cto.com/1069052/424859
所需源码以及组件软件如下:
wget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.46.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.14.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.14-fpm-0.5.14.diff.gz
wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.1.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz
wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-8.10.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2
wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.3.0.tgz
可以从以下载所需软件 ^_^
------------------------------------------------------------------------------------
1 .安装 mysql
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.5.3-m3.tar.gz
cd mysql-5.5.3-m3/
./configure --prefix=/usr/local/lnmp/mysql/
--with-client-ldflags=-all-static
--with-mysql-ldflags=-all-static
--enable-assembler
--with-extra-charsets=utf8,gbk,gb2312
--with-charset=utf8
--enable-thread-safe-client
--with-big-tables
--with-readline
--with-ssl
--with-embedded-server
--enable-local-infile
--with-plugins=partition,innobase,myisammrg
--with-unix-socket-path=/tmp/mysql.sock
--
make && make install
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
运行bin/mysql_install_db //创建初始化数据库
chown -R root .
chgrp -R mysql .
chown -R mysql var
启动mysql : /usr/local/mysql/bin/mysqld_safe &
------------------mysql安装完成--------------------------------------------------------
安装php(FastCGI模式)和相关的支持库
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
------------------------------支持库安装完成 --------------------------
安装php(fastcgi)
首先为php(fastcgi)安装补丁 php-fpm
tar zxvf php-5.2.14.tar.gz //首先解压php 再打补丁
----------------------------------------------------------------------------------------
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
-----------------------------------------------------------------------------------------
这一步就可以打上补丁了
接下来安装Php
./configure --prefix=/usr/local/lnmp/php
--with-config-file-path=/usr/local/lnmp/php/etc
--with-mysql=/usr/local/lnmp/mysql
--with-mysqli=/usr/local/lnmp/mysql/bin/mysql_config
--with-iconv-dir=/usr/local
--with-freetype-dir
--with-jpeg-dir
--with-png-dir
--with-zlib
--with-libxml-dir=/usr
--enable-xml
--disable-rpath
--enable-discard-path
--enable-safe-mode
--enable-bcmath
--enable-shmop
--enable-sysvsem
--enable-inline-optimization
--with-curl
--with-curlwrappers
--enable-mbregex
--enable-fastcgi
--enable-fpm
--enable-force-cgi-redirect
--enable-mbstring
--with-mcrypt
--with-gd
--enable-gd-native-ttf
--with-openssl
--with-mhash
--enable-pcntl
--enable-sockets
--with-ldap
--with-ldap-sasl
--with-xmlrpc
--enable-zip
--enable-soap
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/lnmp/php/etc/php.ini
------------------------------------------------------------------------完成
配置eAccelerator或zend加速PHP:
这里我用的是zend加速PHP安装 这用的是Zend-3.3.9
注意安装zend 要切记版本的问题
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
mkdir -p /usr/local/zend/
cp -r ZendOptimizer-3.3.9-linux-glibc23-i386/ /usr/local/zend
cp /usr/local/zend/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/
接下来:在php.ini 文件最后加入以下二句 ,如下:
zend_optimizer.optimization_level=15
zend_extension=/usr/local/Zend//ZendOptimizer.so
-------------------------------------------------------------------------------启动php(fastcgi模式)------
安装nginx
groupadd www
useradd -g www www
注:前提要安装PCRE ------------nginx重写规则时用到 支持perl脚本
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install
cd ../
tar zxvf nginx-0.8.46.tar.gz
cd nginx-0.8.46/
./configure --user=www
--group=www
--prefix=/usr/local/webserver/nginx
make && make install
cd ../
---------------------------------------------------------------------------------------------------------
到此 安装基本完成,还要做一些配置如下:
1.首先启动mysql
2. 对nginx.conf做更改 , 贴下配置文件:
user www www;
worker_processes 8;
error_log /data1/logs/nginx_error.log crit;
pid /usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http
{
include mime.types;
default_type application/octet-stream;
#charset gb2312;
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;
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 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;
#limit_zone crawler $binary_remote_addr 10m;
server
{
listen 80;
server_name blog.s135.com;
index index.html index.htm index.php;
root /data0/htdocs/blog;
#limit_conn crawler 20;
************************************
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcig_params;
}
***********************************
注:以上是开启Nginx支持php(fast-cgi)模式,
在该Location里的include里包含的文件里添加一句
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
ok 现在启动nginx和php-fpm
*************************************************************************
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /data1/logs/access.log access;
}
server
{
listen 80;
server_name www.s135.com;
index index.html index.htm index.php;
root /data0/htdocs/www;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
log_format wwwlogs '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /data1/logs/wwwlogs.log wwwlogs;
}
server
{
listen 80;
server_name status.blog.s135.com;
location / {
stub_status on;
access_log off;
}
}
}
3.启动nginx
/usr/local/lnmp/nginx/sbin/nginx
4. 启动php-fpm
如果启动失败,常见的原因是要需要改/usr/local/lnmp/php/etc/php-fpm.conf文件
把里面的启动用户和组注释取消掉 即可……
/usr/local/lnmp/php/sbin/php-fpm start
--------------------------到此基本上就可以运行了 OK !!! ------------------------------------
接下来我们安装个discuz论坛 看看……
下载DISCUZ 7.2
这个安装首先要安装ucenter ,里面都有教程 ,ok 环境基本上行了。
******************************************************************
最重要的就是优化和负载情况 其实这才是我们真正要干的事了
就到这里了^_^