[1].安装Nginx
1,添加一个不能登录且没有主目录的用户:
1 # useradd www -M -s /sbin/nologin
2,必要的组件
# yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel 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 libtool-ltdl-devel pcre-devel
3,编译nginx并安装
# wget http://www.nginx.com.cn/download/nginx-1.3.9.tar.gz
# tar -zxvf nginx-1.3.9.tar.gz
# cd nginx-1.3.9
# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module
# make
# make install
[2].安装PHP
1,安装必要的组件
# yum -y install libjpeg-devel libpng-devel
# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
# tar -zxvf libmcrypt-2.5.7.tar.gz
# cd libmcrypt-2.5.7
# ./configure
# make
# make install
==64位系统==
1 # ln -s /usr/lib64/mysql/ /usr/lib/mysql
==64位系统==
2,编译php并安装
# wget http://cn2.php.net/get/php-5.4.13.tar.gz/from/this/mirror
# tar -zxvf php-5.4.13.tar.gz
# cd php-5.4.13
#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/lib--with-iconv --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-mysql --with-mysqli --with-pdo-mysql --enable-ftp --with-jpeg-dir --with-freetype-dir --with-png-dir --enable-fpm --with-fpm-user=www --with-fpm-group=www
如果在32位机器上装到时候可能会碰到checking size of char... configure: error: cannot compute sizeof (char)这个问题。需要去掉--disable-rpath
如果直接编译出错,执行以下两行在进行编译
# mv configure configure.bak
# ./buildconf --force
#make
#make install
3,拷贝和修改php配置文件
# cp php.ini-production /usr/local/php/lib/php.ini 或是/usr/local/lib/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# /usr/local/php/bin/php --ini //测试ini文件是否加载
修改php.ini
[PHP]
safe_mode = On
register_globals = Off
magic_quotes_gpc = Off
allow_url_fopen = Off
allow_url_include = Off
expose_php=Off
disable_functions = shell_exec,system,exec,passthru,show_source,curl_exec,curl_multi_exec,get_cfg_var
[Date]
date.timezone = "Asia/Shanghai"
修改php-fpm.conf
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
emergency_restart_threshold = 0
emergency_restart_interval = 0
[www]
pm.max_children = 256
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 256
pm.max_requests = 500
发表评论