#搭建环境
linux版本:CentOS 5.5 64位
nginx版本:nginx-1.2.9
php版本: php-5.3.27
mysql版本: mysql-5.1.50
#安装数据库
[root@manage lnmp]# yum remove mysql
[root@manage lnmp]# yum -y install gcc-c++ ncurses ncurses-devel openssl openssl-devel libtool*
[root@manage lnmp]# mkdir -p /data/dbdata
[root@manage lnmp]# cd mysql-5.1.50
[root@manage mysql-5.1.50]# autoreconf --force --install
[root@manage mysql-5.1.50]# libtoolize --automake --force
[root@manage mysql-5.1.50]# automake --force --add-missing
[root@manage mysql-5.1.50]# ./configure --prefix=/usr/local/mysql --localstatedir=/data/dbdata/ \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock --with-charset=utf8 --with-extra-charsets=complex \
--with-pthread --enable-thread-safe-client --with-ssl --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static \
--with-plugins=partition,federated,ndbcluster,innobase,csv,blackhole,myisam,innodb_plugin,heap,archive --enable-shared --enable-assembler
[root@manage mysql-5.1.50]# make
[root@manage mysql-5.1.50]# make install
[root@manage mysql-5.1.50]# groupadd mysql
[root@manage mysql-5.1.50]# useradd -g mysql mysql
[root@manage mysql-5.1.50]# chown -R mysql:mysql /usr/local/mysql
[root@manage mysql-5.1.50]# chown -R mysql:mysql /data/dbdata/
[root@manage mysql-5.1.50]# /usr/local/mysql/bin/mysql_install_db --user=mysql
[root@manage mysql-5.1.50]# cp support-files/my-medium.cnf /etc/my.cnf
[root@manage mysql-5.1.50]# cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
[root@manage mysql-5.1.50]# chkconfig --level 345 mysqld on
#安装nginx
[root@manage lnmp]# groupadd www
[root@manage lnmp]# useradd -s /sbin/nologin -g www www
[root@manage lnmp]# yum -y install openssl openssl-devel pcre pcre-devel gcc gcc-c++ make wget zlib zlib-devel
[root@manage lnmp]# tar xzvf nginx-1.2.9.tar.gz
[root@manage lnmp]# cd nginx-1.2.9
[root@manage nginx-1.2.9]# ./configure --prefix=/usr/local/nginx --with-google_perftools_module \
--with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --user=www --group=www
[root@manage nginx-1.2.9]# make
[root@manage nginx-1.2.9]# make install
[root@manage nginx-1.2.9]# /usr/local/nginx/sbin/nginx
[root@manage nginx-1.2.9]# netstat -nltp | grep "LISTEN" | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9291/nginx
#安装PHP依赖库
[root@manage libs]# yum -y install libxml2 libxml2-devel curl curl-devel gd gd-devel
[root@manage jpeg-9]# mkdir -p /usr/local/lnmplibs/
[root@manage libs]# wget
[root@manage libs]# tar xzvf jpegsrc.v9.tar.gz
[root@manage libs]# cd jpeg-9/
[root@manage jpeg-9]# ./configure --prefix=/usr/local/lnmplibs --enable-shared --enable-static --prefix=/usr/local/lnmplibs
[root@manage jpeg-9]# make
[root@manage jpeg-9]# make install
[root@manage jpeg-9]# cd ..
[root@manage libs]# wget
[root@manage libs]# tar xzvf libpng-1.6.2.tar.gz
[root@manage libs]# cd libpng-1.6.2
[root@manage libpng-1.6.2]# ./configure --prefix=/usr/local/lnmplibs
[root@manage libpng-1.6.2]# make
[root@manage libpng-1.6.2]# make install
[root@manage libpng-1.6.2]# cd ..
[root@manage libs]# wget
[root@manage libs]# tar xzvf freetype-2.4.12.tar.gz
[root@manage libs]# cd freetype-2.4.12
[root@manage freetype-2.4.12]# ./configure --prefix=/usr/local/lnmplibs
[root@manage freetype-2.4.12]# make
[root@manage freetype-2.4.12]# make install
[root@manage freetype-2.4.12]# cd ..
[root@manage libs]# wget ""
[root@manage libs]# wget ""
[root@manage libs]# wget ""
[root@manage libs]# tar xzvf libmcrypt-2.5.8.tar.gz
[root@manage libs]# cd libmcrypt-2.5.8
[root@manage libmcrypt-2.5.8]# ./configure --prefix=/usr/local/lnmplibs
[root@manage libmcrypt-2.5.8]# make
[root@manage libmcrypt-2.5.8]# make install
[root@manage libmcrypt-2.5.8]# cd libltdl/
[root@manage libltdl]# ./configure --prefix=/usr/local/lnmplibs --enable-ltdl-install
[root@manage libltdl]# make
[root@manage libltdl]# make install
[root@manage libltdl]# cd ../..
[root@manage libs]# tar xzvf mhash-0.9.9.9.tar.gz
[root@manage libs]# cd mhash-0.9.9.9
[root@manage mhash-0.9.9.9]# ./configure --prefix=/usr/local/lnmplibs
[root@manage mhash-0.9.9.9]# make
[root@manage mhash-0.9.9.9]# make install
[root@manage mhash-0.9.9.9]# cd ..
[root@manage libs]# vim /etc/ld.so.conf
/usr/local/lnmplibs
[root@manage libs]# ldconfig
[root@manage mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lnmplibs/lib: LD_LIBRARY_PATH
[root@manage libs]# tar zxvf mcrypt-2.6.8.tar.gz
[root@manage libs]# cd mcrypt-2.6.8
[root@manage mcrypt-2.6.8]# export LDFLAGS="-L/usr/local/lnmplibs/lib -L/usr/lib"
[root@manage mcrypt-2.6.8]# export CFLAGS="-I/usr/local/lnmplibs/include -I/usr/include"
[root@manage mcrypt-2.6.8]# touch malloc.h
[root@manage mcrypt-2.6.8]# ./configure --prefix=/usr/local/lnmplibs --with-libmcrypt-prefix=/usr/local/lnmplibs
[root@manage mcrypt-2.6.8]# make
[root@manage mcrypt-2.6.8]# make install
[root@manage libs]# cd ../../
#安装PHP
[root@manage lnmp]# tar xzvf php-5.3.27.tar.gz
[root@manage lnmp]# cd php-5.3.27
#[root@manage php-5.3.27]# export LIBS="-lm -ltermcap -lresolv"
[root@manage php-5.3.27]# export DYLD_LIBRARY_PATH="/usr/local/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
[root@manage php-5.3.27]# export LD_LIBRARY_PATH="/usr/local/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
[root@manage php-5.3.27]# yum install libstdc++-devel
[root@manage php-5.3.27]# ./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 --with-freetype-dir=/usr/local/lnmplibs \
--with-jpeg-dir=/usr/local/lnmplibs --with-png-dir=/usr/local/lnmplibs --with-zlib --with-libxml-dir=/usr --enable-xml \
--disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex \
--enable-fpm --enable-mbstring --with-mcrypt=/usr/local/lnmplibs --with-gd --enable-gd-native-ttf --with-openssl --with-mhash \
--enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-pdo-mysql=/usr/local/mysql
[root@manage php-5.3.27]# make
#此处如安装mysql5.1.50,可能报/usr/local/mysql/include/mysql/my_global.h:626:25: 错误:my_compiler.h:没有那个文件,
解决方法:在源安装目录找到my_compiler.h复制到/usr/local/mysql/include/mysql/
[root@manage php-5.3.27]# make install
[root@manage php-5.3.27]# mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@manage php-5.3.27]# cd ..
[root@manage lnmp]# wget
[root@manage lnmp]# tar xzvf autoconf-latest.tar.gz
[root@manage lnmp]# cd autoconf-2.69/
[root@manage autoconf-2.69]# ./configure --prefix=/usr/local/lnmplibs
[root@manage autoconf-2.69]# make
[root@manage autoconf-2.69]# make install
[root@manage autoconf-2.69]# cd ..
[root@manage lnmp]# wget
[root@manage lnmp]# tar xzvf memcache-2.2.7.tgz
[root@manage lnmp]# cd memcache-2.2.7
[root@manage memcache-2.2.7]# export PHP_AUTOCONF="/usr/local/lnmplibs/bin/autoconf"
[root@manage memcache-2.2.7]# export PHP_AUTOHEADER="/usr/local/lnmplibs/bin/autoheader"
[root@manage memcache-2.2.7]# /usr/local/php/bin/phpize
[root@manage memcache-2.2.7]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@manage memcache-2.2.7]# make
[root@manage memcache-2.2.7]# make install
[root@manage memcache-2.2.7]# cd ..
cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/php/etc/php.ini
extension_dir=”./” èextension_dir=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613”
extension = “memcache.so”
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9000
user = www
group = www
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
#配置nginx
server {
listen 80;
server_name localhost;
#charset koi8-r;
access_log logs/localhost.access.log main;
root html;
index index.html index.htm index.php;
#配置nginx支持PHP
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
#缓存图片
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
#缓存js/css相关信息
location ~ .*\.(js|css)?$
{
expires 1h;
}
#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;
}
}
}
#fastcgi.conf配置内容
[root@manage php-5.3.27]# cat /usr/local/nginx/conf/fastcgi.conf
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
#加入开机启动
cat /etc/rc.local
ulimit -SHn 65535
/usr/local/php/sbin/php-fpm
/usr/local/nginx/sbin/nginx
阅读(2331) | 评论(0) | 转发(0) |