lnmp搭建wordpress实例(一)


  申明:此文档目的是搭建基础的lnmp环境,不做nginx、php-fpm过多优化说明。wordpress安装参考官方文档即可,过程介绍比较粗略,为的是验证lnmp环境正常,同时不介绍wordpress个性化设置。
   nginx+mysql+php+memcache+Zend Optimizer+eaccelerator

   zend optimizer 是一个代码优化的模块,可以调优php代码,实现的原理是对那些在被最终执行之前由运行编译器(Run-Time Compiler)产生的代码进行优化。代码性能可以提高40%到100%,

eAccelerator 是一个将编译之后的php代码缓存在share memory中的模块。通过访问共享内存可以得到编译后的代码并直接执行用以提高效率,这个对于php的执行效率的提高还是很大的。


一、环境准备:

1、系统约定:

系统:centos5.6 32Bit
软件包存放:/usr/local/src
apache网站根目录:/home/wwwroot/
mysql数据目录:/data/mysql
vhost日志根目录:/home/wwwlogs/
apache运行账户:www
mysql运行账户:www
服务器ip:172.16.57.10
domainname:www.iceman10.com

软件下载URL
wget -c http://soft.vpser.net/web/pcre/pcre-8.12.tar.gz
wget -c http://soft.vpser.net/web/nginx/nginx-1.0.10.tar.gz
wget -c http://soft.vpser.net/datebase/mysql/mysql-5.1.60.tar.gz
wget -c http://soft.vpser.net/web/php/php-5.2.17.tar.gz
wget -c http://memcached.googlecode.com/files/memcached-1.4.7.tar.gz
wget -c http://soft.vpser.net/web/memcache/memcache-3.0.6.tgz
wget -c
http://soft.vpser.net/web/phpfpm/php-5.2.17-fpm-0.5.14.diff.gz
wget -c
http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.13-stable.tar.gz

wget -c http://soft.vpser.net/web/zend/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
wget -c 
http://nchc.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.tar.bz2
wget -c http://cn.wordpress.org/wordpress-3.3.1-zh_CN.tar.gz


2、yum 安装开发包

yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel openssl openssl-devel openldap openldap-devel gd gd-devel libmcrypt libmcrypt-devel libtool gcc  gcc-c++

gd库使用yum安装


二、编译安装NMP环境

2.1、创建Nginx账户及目录

创建nginx用户
groupadd www
useradd -s /sbin/nologin -g www www

创建nginx数据、日志目录
mkdir -p /home/wwwroot
mkdir -p /home/wwwlogs
chown -R www:www wwwlogs wwwroot

2.2、安装pcre

安装pcre 是为了nginx支持rewrite模块

tar zxvf pcre-8.12.tar.gz
cd pcre-8.12/
./configure
make && make install

2.3、安装、配置nginx
tar zxvf nginx-1.0.10.tar.gz
cd nginx-1.0.10/
 ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
make && make install

nginx.conf配置
/usr/local/nginx/conf/nginx.conf
user  www www;
worker_processes 1;
error_log  /home/wwwlogs/nginx_error.log  crit;
pid        /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
        {
                use epoll;
                worker_connections 51200;
        }
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 50m;
                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 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;
                #limit_zone  crawler  $binary_remote_addr  10m;
include vhost/*.conf;
}

创建 vhost/www.iceman10.com.conf

server
        {
                listen       80;
                server_name www.iceman.com bbs.iceman.com;
                index index.html index.htm index.php default.html default.htm default.php;
                root  /home/wwwroot/www.iceman10.com/htdocs;
                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  127.0.0.1:9000;
                                fastcgi_index index.php;
                                include fastcgi.conf;
                        }
                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }
                location ~ .*\.(js|css)?$
                        {
                                #expires      12h;
                                access_log   off;
                        }
                log_format  www.iceman.com  '$remote_addr - $remote_user [$time_local] $request '
             '$status $body_bytes_sent $http_referer '
             '$http_user_agent $http_x_forwarded_for';
                access_log  /home/wwwlogs/www.iceman.com.log  www.iceman.com;
        }


/usr/local/nginx/sbin/nginx �Ct   \\检测nginx.conf配置文件


2.4、创建mysql运行账户及目录

groupadd mysql
useradd -s /sbin/nologin -M -g mysql mysql


mkdir -p /data/mysql
chown -R mysql:mysql  /data/mysql/



2.5、mysql 编译安装
tar xzvf mysql-5.1.60.tar.gz
cd mysql-5.1.60
./configure  --prefix=/usr/local/mysql --with-extra-charsets=all --with-charset=utf8 --enable-thread-safe-client --with-big-tables --enable-assembler --with-mysqld-ldflags=-all-static --with-plugins=all
make && make install


 cd /usr/local/mysql/
 chown -R mysql:mysql .
 /usr/local/mysql/bin/mysql_install_db --user=mysql
 chown -R root .
 chown -R mysql var
 cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
 cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql


修改my.cnf
datadir = /data/mysql
sed -i "s/skip-locking/skip-external-locking/g" /etc/my.cnf

/usr/local/mysql/bin/mysql_install_db --user=mysql
/usr/local/mysql/bin/mysqld_safe --user=mysql &


2.6、php编译安装

tar zxvf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
cd php-5.2.17/
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --enable-fastcgi --enable-fpm --enable-discard-path --enable-force-cgi-redirect --with-libxml-dir --with-xmlrpc --with-gd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-curl --with-curlwrappers --enable-mbstring --with-mcrypt --enable-soap --enable-ftp

make
make install

cp php.ini-dist  /usr/local/php5/etc/php.ini


2.7 php-fpm 配置
 
/usr/local/php5/etc
 
Unix user of processes
 <value name="user">www</value>                         
 
Unix group of processes
<value name="group">www</value>
 
2.8 lnmp 验证
/usr/local/nginx/sbin/nginx   启动 nginx 服务
/usr/local/php5/sbin/php-fpm restart  启动 php-fpm
 
创建 /home/wwwroot/www.iceman10.com/htdocs/phinfo.php
 
[root@demo10 htdocs]# cat phpinfo.php
<?
phpinfo();
?>





你可能感兴趣的:(wordpress,Zend,LNMP,eaccelerator,休闲)