LNMP环境搭建(httpd-2.4.9,mysql-5.6.17,php-5.5.12,nginx-1.4.6,zendopcache,memcache)

2 篇文章 0 订阅
1 篇文章 0 订阅
依赖软件:
yum install -y wget gcc gcc-c++ autoconf libjpeg libjpeg-devel perl perl* perl-CPAN libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers png jpeg autoconf gcc cmake make gcc-c++ gcc ladp ldap* ncurses ncurses- devel zlib zlib-devel zlib-static pcre pcre-devel pcre-static openssl openssl-devel perl libtoolt openldap-devel libxml2-devel ntpdate cmake gd* gd2 ImageMagick-devel jpeg jpeg* pcre-dev* fontconfig libpng libxml2 zip unzip gzip
需要软件:
wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.13.tar.gz
    wget http://lcmp.googlecode.com/files/libmcrypt-2.5.8.tar.gz
    wget http://jaist.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
    wget http://jaist.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
    wget http://vps.googlecode.com/files/PDO_MYSQL-1.0.2.tgz
    wget http://pecl.php.net/get/imagick-3.1.2.tgz
    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
    wget http://mynginx.googlecode.com/files/ImageMagick.tar.gz
    wget https://lnamp-web-server.googlecode.com/files/eaccelerator-eaccelerator-42067ac.tar.gz
    wget http://nginx.org/download/nginx-1.4.6.tar.gz
    wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz
安装apache:

groupadd www

useradd -g www -s /sbin/nologin -M www

    tar zxvf apr-1.5.1.tar.gz
    cd apr-1.5.1
    ./configure --prefix=/usr/local/apr
    make && make install

    tar zxvf apr-util-1.5.3.tar.gz
    cd apr-util-1.5.3
    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
    make && make install


    tar zxvf httpd-2.4.9.tar.gz
    cd httpd-2.4.9
    ./configure --prefix=/usr/local/apache2 --enable-headers --enable-so --enable-rewrite --with-mpm=prefork --disable-userdir --disable-cgid --disable-cgi --with- apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
    make && make install


    启动Apache(建议先不要启动,等我们全部设置完毕后,和Nginx启动)
    /usr/local/apache2/bin/apachectl start
    
    查看apache是否启动
    ps aux|grep httpd
    
    将apache设置成开机自启动:
    echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.local  //将 apachectl 的调用加入到你的系统启动文件中。




安装mysql:
tar zxvf mysql-5.6.17.tar.gz
cd mysql-5.6.17


cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 - DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock - DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1  -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci


make && make install


cd /usr/local/mysql
    chown -R mysql:mysql . 
    chown -R root:mysql . 
    chown -R mysql:mysql ./data
    cp support-files/my-default.cnf  /etc/my.cnf 
    vim /etc/my.cnf
    添加:
        datadir=/data/mysql
        #default-storage-engine=MyISAM
        innodb_buffer_pool_size = 128M
        port = 3306
        socket = MySQL
        key_buffer_size = 16K
        max_allowed_packet = 1M
        table_open_cache = 4
        sort_buffer_size = 64K
        read_buffer_size = 256K
        read_rnd_buffer_size = 256K
        net_buffer_length = 2K
        thread_stack = 128K
        server-id= 1
        character-set-server=gbk
        default-storage-engine=INNODB
        #开启查询缓存
        explicit_defaults_for_timestamp=true
    
    scripts/mysql_install_db --user=mysql --datadir=/data/mysql


    bin/mysqld_safe --user=mysql &  
#启动mysql,看是否成功  
    netstat -tnl|grep 3306


#将mysql的启动服务添加到系统服务中  
    cp support-files/mysql.server /etc/init.d/mysql  
    #现在可以使用下面的命令启动mysql  
    service mysql start  
    #停止mysql服务  
    service mysql stop  
    #重启mysql服务  
    service mysql restart


#将mysql添加到开机启动
    chkconfig --add mysql
    修改默认root账户密码,默认密码为空


    修改密码 cd 切换到mysql所在目录 
    cd /usr/local/mysql 
    ./bin/mysqladmin -u root password 
    回车在接下来的提示中设置新密码即可。。


#启动MySQL
    /usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf &
    #或者
    /etc/init.d/mysql start (service mysql start)
      
#测试MySQL是否启动
    # 1)查看是否有进程mysql
    ps -ef | grep mysql
    # 2)查看端口是否运行
    netstat -tnl | grep 3306
    # 3)读取mysql版本信息
    mysqladmin version


    mysql -uroot -h127.0.0.1 -p




php5.5.12安装配置:
依赖软件libmcrypt:
    tar zxvf libmcrypt-2.5.8.tar.gz
    cd libmcrypt-2.5.8
    ./configure --prefix=/usr/local/libmcrypt
    make && make install


    vim /etc/ld.so.conf.d/local.conf     # 编辑库文件
    /usr/local/lib                       # 添加该行
    :wq                                  # 保存退出
    ldconfig -v                          # 使之生效




    ./configure --prefix=/usr/local/php \
    --with-apxs2=/usr/local/apache2/bin/apxs \
    --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-jpeg-dir \
    --with-png-dir \
    --with-zlib \
    --with-libxml-dir \
    --enable-xml \
    --disable-rpath \
    --enable-bcmath \
    --enable-shmop \
    --enable-sysvsem \
    --enable-inline-optimization \
    --with-curl \
    --with-curlwrappers \
    --enable-mbregex \
    --enable-fpm \
    --enable-mbstring \
    --with-mcrypt=/usr/local/libmcrypt/ \
    --with-gd \
    --with-freetype-dir \
    --enable-gd-native-ttf \
    --with-openssl \
    --with-mhash \
    --enable-pcntl \
    --enable-sockets \
    --with-ldap \
    --with-ldap-sasl \
    --with-xmlrpc \
    --enable-zip \
    --enable-soap \
    --enable-session \
    --with-gettext \
    --enable-pdo \
    --with-pdo-mysql \
    --enable-shared \
    --enable-ftp \
    --enable-exif \
    --enable-opcache \
    --with-fpm-user=www \
    --with-fpm-group=www \
    --without-pear \
    --enable-opcache=no \
    --enable-maintainer-zts  #多线程使用


    make && make install


ERR:
    1、make: *** [ext/phar/phar.php] 错误 127
    先找出libmysqlclient.so.16所在的位置
    在src下执行  find -name libmysqlclient.so.18
    结果:./mysql-5.5.8/libmysql/libmysqlclient.so.18
    所以全路径为:/usr/local/webserver/mysql-5.5.8/libmysql/libmysqlclient.so.18
    然后:ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so /usr/lib/
    ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
    2、make: *** [install-pharcmd] 错误 1
    解决: configure时加上参数 –without-pear




准备PHP的配置文件
    # cd /home/down/php-5.5.11
    # cp php.ini-production /usr/local/php/etc/php.ini


准备php-fpm的配置文件
    # cd /usr/local/php/etc/
    # cp php-fpm.conf.default php-fpm.conf
    # vim php-fpm.conf


修改php-fpm.conf配置文件内容去掉如下前面的分号,并根据实际硬件配置进行更改
    这里仅做简单配置,下面会有PHP-FPM的详细的优化配置讲解
    pid = run/php-fpm.pid
    error_log = log/php-fpm.log
    listen = 127.0.0.1:9000 
    pm.max_children = 40  
    pm.start_servers = 12 
    pm.min_spare_servers = 4  
    pm.max_spare_servers = 20  
    pm.max_requests = 1000  




测试php-fpm配置(实际路径根据自己PHP安装路径自行替换)
    /usr/local/php/sbin/php-fpm -t
    /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf -t


出现类似如下提示证明测试通过,PHP/php-fpm安装成功
    [18-Apr-2014 23:20:15] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful




为php-fpm提供Sysv init脚本,并将其添加至服务列表 致使开机自动启动
    # cd/home/down/php-5.5.11
    # cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
    # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
    # chmod +x /etc/init.d/php-fpm
    # chkconfig --add php-fpm
    # chkconfig php-fpm on


    service php-fpm start|stop|restart 




php-fpm.conf重要参数详解
    pid = run/php-fpm.pid
    #pid设置,默认在安装目录中的var/run/php-fpm.pid,建议开启
     
    error_log = log/php-fpm.log
    #错误日志,默认在安装目录中的var/log/php-fpm.log
     
    log_level = notice
    #错误级别. 可用级别为: alert(必须立即处理), error(错误情况), warning(警告情况), notice(一般重要信息), debug(调试信息). 默认: notice.
     
    emergency_restart_threshold = 60
    emergency_restart_interval = 60s
    #表示在emergency_restart_interval所设值内出现SIGSEGV或者SIGBUS错误的php-cgi进程数如果超过 emergency_restart_threshold个,php-fpm就会优雅重启。这两个选项一般保持默认值。
     
    process_control_timeout = 0
    #设置子进程接受主进程复用信号的超时时间. 可用单位: s(秒), m(分), h(小时), 或者 d(天) 默认单位: s(秒). 默认值: 0.
     
    daemonize = yes
    #后台执行fpm,默认值为yes,如果为了调试可以改为no。在FPM中,可以使用不同的设置来运行多个进程池。 这些设置可以针对每个进程池单独设置。
     
    listen = 127.0.0.1:9000
    #fpm监听端口,即nginx中php处理的地址,一般默认值即可。可用格式为: 'ip:port', 'port', '/path/to/unix/socket'. 每个进程池都需要设置.
     
    listen.backlog = -1
    #backlog数,-1表示无限制,由操作系统决定,此行注释掉就行。backlog含义参考:http://www.3gyou.cc/?p=41
     
    listen.allowed_clients = 127.0.0.1
    #允许访问FastCGI进程的IP,设置any为不限制IP,如果要设置其他主机的nginx也能访问这台FPM进程,listen处要设置成本地可被访问的IP。默认值是any。每个地址是用逗号分隔. 如果没有设置或者为空,则允许任何服务器请求连接
     
    listen.owner = www
    listen.group = www
    listen.mode = 0666
    #unix socket设置选项,如果使用tcp方式访问,这里注释即可。
     
    user = www
    group = www
    #启动进程的帐户和组
     
    pm = dynamic #对于专用服务器,pm可以设置为static。
    #如何控制子进程,选项有static和dynamic。如果选择static,则由pm.max_children指定固定的子进程数。如果选择dynamic,则由下开参数决定:
    pm.max_children #,子进程最大数
    pm.start_servers#,启动时的进程数
    pm.min_spare_servers#,保证空闲进程数最小值,如果空闲进程小于此值,则创建新的子进程
    pm.max_spare_servers#,保证空闲进程数最大值,如果空闲进程大于此值,此进行清理
     
    pm.max_requests = 1000
    #设置每个子进程重生之前服务的请求数. 对于可能存在内存泄漏的第三方模块来说是非常有用的. 如果设置为 '0' 则一直接受请求. 等同于 PHP_FCGI_MAX_REQUESTS 环境变量. 默认值: 0.
     
    pm.status_path =/status
    #FPM状态页面的网址. 如果没有设置, 则无法访问状态页面. 默认值: none. munin监控会使用到
     
    ping.path =/ping
    #FPM监控页面的ping网址. 如果没有设置, 则无法访问ping页面. 该页面用于外部检测FPM是否存活并且可以响应请求. 请注意必须以斜线开头 (/)。
     
    ping.response = pong
    #用于定义ping请求的返回相应. 返回为 HTTP 200 的 text/plain 格式文本. 默认值: pong.
     
    request_terminate_timeout = 0
    #设置单个请求的超时中止时间. 该选项可能会对php.ini设置中的'max_execution_time'因为某些特殊原因没有中止运行的脚本有用. 设置为 '0' 表示 'Off'.当经常出现502错误时可以尝试更改此选项。
     
    request_slowlog_timeout = 10s
    #当一个请求该设置的超时时间后,就会将对应的PHP调用堆栈信息完整写入到慢日志中. 设置为 '0' 表示 'Off'
     
    slowlog = log/$pool.log.slow
    #慢请求的记录日志,配合request_slowlog_timeout使用
     
    rlimit_files = 1024
    #设置文件打开描述符的rlimit限制. 默认值: 系统定义值默认可打开句柄是1024,可使用 ulimit -n查看,ulimit -n 2048修改。
     
    rlimit_core = 0
    #设置核心rlimit最大限制值. 可用值: 'unlimited' 、0或者正整数. 默认值: 系统定义值.
     
    chroot =
    #启动时的Chroot目录. 所定义的目录需要是绝对路径. 如果没有设置, 则chroot不被使用.
     
    chdir =
    #设置启动目录,启动时会自动Chdir到该目录. 所定义的目录需要是绝对路径. 默认值: 当前目录,或者/目录(chroot时)
     
    catch_workers_output =yes
    #重定向运行过程中的stdout和stderr到主要的错误日志文件中. 如果没有设置, stdout 和 stderr 将会根据FastCGI的规则被重定向到 /dev/null . 默认值: 空.




nginx安装配置
    tar -zxvf nginx-1.4.6.tar.gz
    cd nginx-1.4.6
    ./configure --user=www --group=www --prefix=/usr/local/nginx \
    --with-http_stub_status_module \
    --with-http_ssl_module \
    --with-http_realip_module \
    --with-http_image_filter_module \
    --with-http_gzip_static_module \
    --with-http_flv_module \
    --with-pcre
    make && make install


    


检查是否安装成功
    cd  /usr/local/nginx/sbin
    ./nginx -t 
    结果显示:
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful


启动nginx 
    cd  /usr/local/nginx/sbin 目录下面 输入 ./nginx 启动 nginx
检查是否启动成功
    ps -A
停止nginx
    pkill -9 nginx


    vim /etc/init.d/nginx
    写入:
    #!/bin/sh 
    # chkconfig:345 61 61 
    # description: Nginx is an HTTP(S) server, HTTP(S) reverse\ 
    #              proxy and IMAP/POP3 proxy server 
    # processname: nginx 
    #config:     /etc/nginx/nginx.conf 
    #config:     /etc/sysconfig/nginx 
    #pidfile:    /var/run/nginx.pid 


    # Source function library. 
    . /etc/rc.d/init.d/functions


    # Source networking configuration. 
    . /etc/sysconfig/network


    # Check that networking is up. 
    [ "$NETWORKING" = "no" ] && exit0


    nginx="/usr/local/nginx/sbin/nginx"
    prog=$(basename $nginx)


    NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"


    [ -f /etc/sysconfig/nginx ] && ./etc/sysconfig/nginx


    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
    killall -9 nginx
    }


    restart() {
        configtest|| return $?
       stop
        sleep 1
       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/null2>&1
    }


    case "$1" in
       start)
           rh_status_q && exit0
       $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 755 /etc/init.d/nginx
    chkconfig --add nginx
    chkconfig nginx on


更换NGINX启动方式 测试是否成功
    service nginx start      启动
    service nginx stop       停止
    service nginx restart  重启




反向代理设置
    vim /etc/hosts
    添加:
    127.0.0.1  www.test.com
    
    vim /usr/local/apache2/conf/httpd.conf
    修改
    Listen 80
    为
    Listen 8081
    开启虚拟主机设置
    
    vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
    写入
    <VirtualHost *:8081>
        DocumentRoot "/data/web/www"
        ServerName www.test.com
        <Directory />
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order deny,allow
                Allow from all
        </Directory>
    </VirtualHost>


    vim /usr/local/nginx/conf/nginx.conf
    在http节点内写入
    upstream www.test.com {
        server 127.0.0.1:8081;
    }


    server {
        listen             80;
        server_name    www.test.com;
        charset UTF-8;
        index index.html index.htm;
        root    /data/web/www/;
        location ~ ^/NginxStatus/ {
                stub_status on;
                access_log off;
        }
        location / {
             root    /data/web/www/;
             proxy_redirect off ;
             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header REMOTE-HOST $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             client_max_body_size 50m;
             client_body_buffer_size 256k;
             proxy_connect_timeout 30;
             proxy_send_timeout 30;
             proxy_read_timeout 60;
             proxy_buffer_size 256k;
             proxy_buffers 4 256k;
             proxy_busy_buffers_size 256k;
             proxy_temp_file_write_size 256k;
             proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
             proxy_max_temp_file_size 128m;
             proxy_pass    http://www.test.com;
        }
    }


优化MySQL


    通过Tcmalloc 优化mysql性能


    # vi /etc/init.d/mysql


    添加一行


    export LD_PRELOAD=/usr/local/lib/libtcmalloc.so


    重新启动mysql


    service mysql restart


    检测是否成功,在SSH中输入:


    lsof -n|grep tcmalloc


    出现相关进程即可


整合Apache与php


    编辑 /usr/local/apache2/conf/httpd.conf


    找到AddType application/x-gzip .gz .tgz在其下加以下内容


    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps


    查找:(设置WEB默认文件)


    DirectoryIndex index.html


    改成:


    DirectoryIndex index.php index.htm index.html index.html.var


    保存退出


    以上设置完毕后,全部保存退出,然后建立一个虚拟主机做测试:


    编辑 Include conf/extra/httpd-vhosts.conf


    <VirtualHost *:81>
        ServerAdmin webmaster@example.com
        DocumentRoot "/home/www"
        ServerName 你的IP地址或域名
        ErrorLog "logs/IP-error_log"
        CustomLog "logs/IP-access_log" common
    </VirtualHost>


    保存退出,并重启Apache


    service httpd restart  或 /usr/local/apache2/bin/apachectl restart


    然后建立一个 index.php文件,放入 /home/www 目录,php文件内容为:


    <?php
        phpinfo();
    ?>


    然后在浏览器中输入:IP:81 是否成功显示了?




Apache设置:


    编辑 httpd.conf :


    vi /usr/local/apache2/conf/httpd.conf


    查找代码:


    DocumentRoot "/usr/local/apache2/htdocs"


    修改为:


    DocumentRoot "/home/www"


    查找代码:


    <Directory "/usr/local/apache2/htdocs">


    修改为:


    <Directory "/home/www">


    找到以下代码并根据提示修改


    <Directory />
        Options FollowSymLinks
        AllowOverride All
        Order deny,allow
        Deny from all        //这句改为Allow from all
    </Directory>


    找到这一段并修改,以使Apache支持rewrite(伪静态):


    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None


    更改为


    AllowOverride All


    将以下代码注释掉,禁止目录列表:


    Options Indexes FollowSymLinks


    找到以下代码,修改用户为 www


    <IfModule !mpm_netware_module>
    <IfModule !mpm_winnt_module>


    User daemon              //改为www
    Group daemon             //改为www


    </IfModule>
    </IfModule>


    设置 ServerAdmin you@example.com 改为你自己的mail地址


    查找:


    Listen 80


    改为


    Listen 81


    分别找到以下四段代码,将之前的注释#去除:


    Include conf/extra/httpd-mpm.conf


    Include conf/extra/httpd-info.conf


    Include conf/extra/httpd-vhosts.conf


    Include conf/extra/httpd-default.conf


    编辑 Include conf/extra/httpd-mpm.conf 找到如下选项,并改成对应的数值


    <IfModule mpm_prefork_module>
        StartServers          5
        MinSpareServers       5
        MaxSpareServers      10
        MaxClients          150
        MaxRequestsPerChild   1000
    </IfModule>


    编辑 conf/extra/httpd-default.conf


    Timeout 60   #与nginx的保持一至
    KeepAlive On
    MaxKeepAliveRequests 1000
    KeepAliveTimeout 5


    复制以下文件:


    cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd


    这样以后Apache 启动、关闭、重启只需要输入以下命令:


    service httpd start/stop/restart


zendopcache安装配置
    wget http://pecl.php.net/get/zendopcache-7.0.2.tgz
    tar xzf zendopcache-7.0.2.tgz
    cd zendopcache-7.0.2
    /usr/local/php/bin/phpize (此处根据实际php安装路径)
    ./configure --with-php-config=/usr/local/php/bin/php-config
    make
    make install


    如果显示Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/ 表示安装完成


    接着呢,配置下php.ini,在最后加上:
    [opcache]
    zend_extension=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
    opcache.enable=1


    重启apache




安装、配置memcache
    tar zxcf memcached-1.4.20.tar.gz
    cd memcache-1.4.20
    yum -y install libevent-devel
    ./configure
    make && make install


开启memcache
    /usr/local/bin/memcached -d -m 128 -l 192.168.x.y -p 11211 -u www


php开启memcache扩展
    cd /usr/local/php/bin
    ./pecl install memcache
    安装时会提示是否开启session支持,根据需要输入no 或者 yes,安装后路径如下:
    /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/memcache.so
    需要手动配置到php.ini中,增加如下内容,即表示启用memcache扩展:
    extension=memcache.so


    重启apache

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值