tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
cd libltdl/
./configure --enable-ltdl-install
make
make install
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
## 让支持包加入到内存中,使其别的软件能够找到
vi /etc/ld.so.conf
添加:
/usr/local/lib 这行
ldconfig 命令一下
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make
make install
4.编译安装 MySQL
mysql-5.5.3以前可以用
./configure --prefix=/usr/local/mysql --without-debug --enable-thread-safe-client --with-pthread --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-extra-charsets=all --with-plugins=all --with-mysqld-user=mysql --without-embedded-server --with-server-suffix=-community --with-unix-socket-path=/tmp/mysql.sock
mysql5.5.3之后用cmake来安装
1).安装cmake
yum -y install cmake.i686
2).安装mysql
#建立mysql用户
useradd -s /sbin/nologin mysql
# cmake测试
cmake -DMYSQL_USER=mysql -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.6 -DINSTALL_DATADIR=/data/mysql/data -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
#这之后步骤一样
make
make install
#设置权限
setfacl -m u:mysql:rxw -R /usr/local/mysql5.6
setfacl -m d:u:mysql:rxw -R /usr/local/mysql5.6
# 安装mysql和test数据库
/usr/local/mysql5.6/scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql5.6/ --datadir=/usr/local/mysql5.6/data
# 启动mysql服务
/usr/local/mysql5.6/bin/mysqld_safe --user=mysql & 或
cp 源码包/support-files/mysql.server /etc/init.d/mysqld
chkconfig --level 345 mysqld on
service mysqld start
# 修改msyql登陆root的密码
/usr/local/mysql5.6/bin/mysqladmin -uroot -password "123456"
# 用mysql登录
/usr/local/mysql5.6/bin/mysql -uroot -p123
#准备 mysql 配置文件
cp /usr/local/mysql5.6/share/mysql/my-medium.cnf /etc/my.cnf 或
cp 源码包/support-files/my-default.cnf /etc/my.cnf
vi /etc/my.cnf
#修改客户端和连接字符集 [client]
default-character-set=utf8
[mysqld]
#修改服务器和数据库字符集
character-set-server=utf8
#修改服务器校验字符集
collation-server=utf8
#重启 mysql 服务让字符集生效
pkill mysqld
/usr/local/mysql5.6/bin/mysqld_safe --user=mysql &
5. 编译安装 PHP(FastCGI 模式)
cd php-5.2.14/
./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=/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 --enable-opcache
make ZEND_EXTRA_LIBS='-liconv'
make install
cp 源码包/php.ini-production /usr/local/php/etc/php.ini
,,,,,,
6.准备编译安装 PHP5 扩展模块
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
ar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make
make install
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
7. 修改 php.ini 文件,让 php 模块生效
cp /lnmp/php-5.2.14/php.ini-dist /usr/local/php/etc/php.ini
vi php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
再查找 output_buffering = Off
修改为 output_buffering = On
再查找; cgi.fix_pathinfo=0
修改为 cgi.fix_pathinfo=0,防止 Nginx 文件类型错误解析漏洞
8.在 php.ini中配置 eAccelerator加速 PHP
mkdir -p /usr/local/eaccelerator_cache
#准备 eaccelerator缓存目录
Vi php.ini
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
9.准备 php-cgi 和 nginx进程执行者用户
Useradd nginx
10. 创建 php-fpm 配置文件- php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
<value name="display_errors">0</value>#0 改成 1,页面上会输出错误日志
<value name="user">nginx</value>
<value name="group">nginx</value>
<value name="max_children">128</value>#最大子进程数 128,如果内存小于 2G,则 64 个最佳
<value name="rlimit_files">65535</value>
# Set open file desc rlimit,同时打开的文件数,linux 系统允许同时打开的文件数为 1024,修改
linux 系统中允许同时打开的文件,ulimit -SHn 65535,而且这个参数重启后还能生效,加到/etc/profile 全局配置文件的最后,开机就会生效,ulimit -a 查看 open files 65535
<value name="max_requests">1024</value>
#最大请求数, How much requests each process should execute before respawn.一个子进程能够
回应 1042 个请求
11. 启动 php-cgi(fastcgi)进程,监听 127.0.0.1 的 9000 端口,进程数为 128(如果服务器内
存小于 3GB,可以只开启 64个进程),用户和组为 nginx:
#启动 php-cgi
/usr/local/php/sbin/php-fpm start 也可以用 /usr/local/php/sbin/php-fpm
#重新加载配置文件
/usr/local/php/sbin/php-fpm reload
#关闭 php-fpm,此时 nginx肯定不上 php
/usr/local/php/sbin/php-fpm stop 或 pkill php-fpm
12. 安装 Nginx 所需的 pcre 库
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install
13. 安装 Nginx
tar zxvf nginx-0.8.46.tar.gz
cd nginx-0.8.46/
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
14. 修改 Nginx 配置文件
vi /usr/local/nginx/conf/nginx.conf
user nginx nginx;
worker_processes 8; #相当于 cpu个数
error_log logs/nginx_error.log
pid /usr/local/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;
安装库文件
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make && make install
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
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make && make install
## 让支持包加入到内存中,使其别的软件能够找到
vi /etc/ld.so.conf
添加: /usr/local/lib 这行
/sbin/ldconfig
tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make && make install
【2】编译Nginx
安装pcre
tar zxvf pcre-8.32.tar.gz
cd pcre-8.32/
./configure --prefix=/usr/local/pcre
make && make install
安装nginx
tar zxvf nginx-1.0.15.tar.gz
cd nginx-1.0.15/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6
make && make install