(系统要求:Linux 2.6+ 内核,本文中的Linux操作系统为CentOS 6.5 64位)
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/webserver/libiconv
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.7 /usr/lib/libmcrypt.so.4.4.7
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
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
tar zxvf cmake-2.8.5.tar.gz
cd cmake-2.8.5
./bootstrap
gmake
gmake install
cd ../
安装OpenSSL
yum install openssl-devel
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar xvf mysql-5.6.20.tar.gz
cd mysql-5.6.20
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/webserver/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_SSL=system \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1
(cmake 出错后,如果重新cmake编译须rm CMakeCache.txt文件 )
make
make install
chmod +w /usr/local/webserver/mysql
(添加mysql 服务访问权限后,mysql可以正常启动)
chown -R mysql:mysql /usr/local/webserver/mysql
ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16
Cd /usr/local/webserver/mysql/scripts/
cd /usr/local/webserver/mysql /support-files/
cp my-default.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内容)
chkconfig --add mysqld
chkconfig --level 345 mysqld on
service mysqld start
cd ../..
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/webserver/zlib
make
make install
cd ..
tar –jxvf libpng-1.4.3.tar.bz2
cd libpng-1.4.3
cd scripts/
cp makefile.linux ../makefile //注意,这里的makefile不是用./configure生成,而是直接从scripts/里拷一个
cd ..
vi ./makefile
找到
prefix=
exec_prefix=$(prefix)
将prefix=改为:prefix=/usr/local/webserver/libpng
保存退出
make
make install
cd ..
tar -jxvf freetype-2.4.8.tar.bz2
cd freetype-2.4.8
./configure --prefix=/usr/local/webserver/freetype
(这一步如果出现”make: Nothing to be done for ‘UNIX’”,则使用rpm –ql freetype查看系统中是否已有freetype,如果有,则跳过freetype的安装)
make
make install
cd ..
tar -zxvf jpegsrc.v7.tar.gz
cd jpeg-7
./configure --prefix=/usr/local/webserver/jpeg --enable-shared //这里configure一定要带--enable-shared参数,不然,不会生成共享库
make
make test
make install
cd ..
tar -zxf gettext-0.18.1.1.tar.gz
cd gettext-0.18.1.1
./configure --prefix=/usr/local/webserver/gettext
make
make install
tar -zxvf libgd-2.1.0.tar.gz
cd libgd-2.1.0
./configure --prefix=/usr/local/webserver/libgd --with-png --with-freetype=/usr/local/webserver/freetype --with-jpeg=/usr/local/webserver/jpeg --with-gettext=/usr/local/webserver/gettext
(如果使用系统自带而非手动安装的freetype,则—with-freetype后面的路径不需要填写)
make
make install
cd ..
(
安装libxml2 依赖与python库
使用命令安装yum install python-devel
)
tar -zxvf libxml2-2.9.1.gz
cd libxml2-2.9.1
./configure --prefix=/usr/local/webserver/libxml2
make
make install
cd ..
2.安装一下支持PHP模块库
yum -y install curl-devel
error:
yum install openldap-devel
error:
cp -frp /usr/lib64/libldap* /usr/lib/
error
tar zxvf php-5.5.tar.gz
cd php-5.5.15/
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-openssl --with-curl --with-mysql=/usr/local/webserver/mysql --enable-opcache=no --with-pdo-mysql=/usr/local/webserver/mysql --enable-mbstring=all --with-freetype-dir=/usr/local/webserver/freetype --with-jpeg-dir=/usr/local/webserver/jpeg --with-png-dir=/usr/local/webserver/libpng --with-zlib-dir=/usr/local/webserver/zlib --enable-mbstring --enable-sockets --with-iconv-dir=/usr/local/webserver/iconv --with-libxml-dir=/usr/local/webserver/libxml2 --enable-soap --with-mcrypt=/usr/local/include --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config
Make
(如出现”error while loading shared libraries:libpng14.so.14:cannot open shared object file:No such file or directory”则执行如下步骤:
vi /etc/ld.so.conf
在最后加入一行:/data0/software/libpng-1.4.4
保存退出后执行ldconfig)
make install
cp php.ini-development /usr/local/webserver/php/etc/php.ini
cd ../
安装 php gd 扩展
cd /data/soft/php-5.5.15/ext/gd
/usr/local/webserver/php/bin/phpize
./configure --with-gd --with-jpeg-dir=/usr/local/webserver/jpeg --with-freetype-dir=/usr/local/webserver/freetype --enable-gd-native-ttf --with-php-config=/usr/local/webserver/php/bin/php-config --with-png-dir=/usr/local/webserver/libpng --with-zlib-dir=/usr/local/webserver/zlib
make
make install
修改php.ini文件(若没有php.ini文件从php的源码包中复制一个)
vi /usr/local/webserver/php/etc/php.ini
手工修改:查找/usr/local/webserver/php/etc/php.ini中的extension_dir = "./"
修改为
extension_dir=" /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20121212”
并在此行后增加以下几行,然后保存:
extension = gd.so
查找output_buffering
结合实际情况将其设置为On或者Off
添加php-fpm 配置文件
cp /usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf
启动php
/usr/local/webserver/php/sbin/php-fpm
将php加入开机自启
vi /etc/rc.d/rc.local
加入一行:/usr/local/webserver/php/sbin/php-fpm
重启php
或者先杀死php进程
killall php-fpm
然后启动php进程
/usr/local/webserver/php/sbin/php-fpm
tar zxvf pcre-8.20.tar.gz
cd pcre-8.20/
./configure
make && make install
cd ../
tar zxvf nginx-1.6.1.tar.gz
cd nginx-1.6.1 /
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../
mkdir -p /data/mginx//logs
chmod +w /data/nginx/logs
chown -R www:www /data/nginx/logs
创建Nginx配置文件
①、在/usr/local/webserver/nginx/conf/目录中创建nginx.conf文件:
rm -f /usr/local/webserver/nginx/conf/nginx.conf
vi /usr/local/webserver/nginx/conf/nginx.conf
输入以下内容:
#user nobody;
worker_processes 8;
error_log /data/error_log/nginx_error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
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;
autoindex on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /data/www/code/linksusyii;
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
#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;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /data/www/code/linksusyii;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www/code/linksusyii$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
}
/usr/local/webserver/nginx/sbin/nginx
/usr/local/webserver/nginx/sbin/nginx –s reload
vi /etc/rc.d/rc.local
加入一行:/usr/local/webserver/nginx/sbin/nginx
tar zxf redis-2.8.13.tar.gz
cd redis-2.8.13
make PREFIX=/usr/local/webserver/redis install
vi /etc/sysctl.conf
加入一行:vm.overcommit_memory=1
sysctl vm.overcommit_memory=1
mkdir /usr/local/webserver/redis/etc
cp /data/ redis-2.8.13/redis.conf /usr/local/webserver/redis/etc/redis.conf
vi /usr/local/webserver/redis/etc/redis.conf
下列为redis.conf主要配置参数的意义,根据需要自行配置
daemonize <yes|no>:是否以后台daemon方式运行,默认为no
pidfile <*.pid>:pid文件的位置,daemonize为yes时才起作用,默认为/var/run/redis.pid
bind <IP>:绑定主机IP,默认值为127.0.0.1
port <port>:监听端口号,默认为6379
timeout <seconds>:请求超时时间,默认为0(用不超时)
loglevel <debug|verbose|notice|warning>:日志信息级别,默认为verbose
logfile <filename>:日志记录方式,默认为stdout
database <number>:开启数据库数量,默认为16,默认数据库为0
save <seconds> <changes>:指出在多长时间内,有多少次更新操作,就将数据同步到数据文件。这个可以多个条件配合,比如默认配置文件中的设置,就设置了三个条件。
save 900 1 900秒(15分钟)内至少有1个key被改变
save 300 10 300秒(5分钟)内至少有300个key被改变
save 60 10000 60秒内至少有10000个key被改变
rdbcompression <yes|no>:存储至本地数据库时是否压缩数据,默认为yes
dbfilename <filename>:本地数据库文件名,默认值为dump.rdb
dir <path>:本地数据库存放路径,默认值为 /data/redis/data
slaveof <masterip> <masterport>:当本机为从服务时,设置主服务的IP及端口
masterauth <master-password>:当本机为从服务时,设置主服务的连接密码
requirepass <password>:连接密码
maxclients <number>:最大客户端连接数,默认不限制
maxmemory <bytes>:设置最大内存,达到最大内存设置后,Redis会先尝试清除已到期或即将到期的Key,当此方法处理后,任到达最大内存设置,将无法再进行写入操作。
appendonly <yes|no>:是否在每次更新操作后进行日志记录,如果不开启,可能会在断电时导致一段时间内的数据丢失。因为redis本身同步数据文件是按上面save条件来同步的,所以有的数据会在一段时间内只存在于内存中。默认值为no
appendfilename <filename>:更新日志文件名,默认值为appendonly.aof
appendfsync <no|always|everysec>:更新日志条件,共有3个可选值。no表示等操作系统进行数据缓存同步到磁盘,always表示每次更新操作后手动调用fsync()将数据写到磁盘,everysec表示每秒同步一次(默认值)。
vm-enabled <yes|no>:是否使用虚拟内存,默认值为no
vm-swap-file <path>:虚拟内存文件路径,默认值为/tmp/redis.swap,不可多个Redis实例共享
vm-max-memory :将所有大于vm-max-memory的数据存入虚拟内存,无论vm-max-memory设置多小,所有索引数据都是内存存储的(Redis的索引数据就是keys),也就是说,当vm-max-memory设置为0的时候,其实是所有value都存在于磁盘。默认值为0。
/usr/local/webserver/redis/bin/redis-server /usr/local/webserver/redis/etc/redis.conf
将redis加入开机自启
vi /etc/rc.d/rc.local
加入一行:/usr/local/webserver/redis/bin/redis-server /usr/local/webserver/redis/etc/redis.conf
unzip phpredis-master.zip
cd phpredis-master
/usr/local/webserver/php/bin/phpize
./configure –-with-php-config=/usr/local/webserver/php/bin/php-config
make && make install
vi /usr/local/webserver/php/etc/php.ini
(在extension=gd.so的下一行加入extension=redis.so)
安装php Opcache扩展
wget http://pecl.php.net/get/zendopcache-7.0.2.tgz
cd zendopcache-7.0.2
或者
cd /data/soft/php-5.5.15/ext/opcache
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
Make
Make install
opcache.enable_cli=1
opcache.memory_consumption=64
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.force_restart_timeout=180
opcache.fast_shutdown=1
(在php.ini 文件中加入zend_extension=opcache.so)
重启php
Killall php-fpm
/usr/local/webserver/php/sbin/php-fpm