龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

CentOS 6 編譯安裝Nginx1.3.9+PHP5.4

2015.09.10 | 1622閱讀 | 0條評論 | 服務(wù)器配置

[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位系統(tǒng)==


1 # ln -s /usr/lib64/mysql/ /usr/lib/mysql


==64位系統(tǒng)==


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


如果直接編譯出錯,執(zhí)行以下兩行在進行編譯

# 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


贊 (

發(fā)表評論