Install nginx + php5.3 on Centos. Click here to view details. # View system version information catetcissueuname-a # set the time zone rm-rfetclocaltimeln-susr#zoneinfoasiashanghaietclocaltime # Use ntpdate to synchronize time yuminstall-yntpntpdate-upool.ntp.orgdate #
Install nginx + php5.3 on Centos. Click here to view details. # View system version information cat/etc/issue uname-a # set the time zone rm-rf/etc/localtime ln-s/usr/share/zoneinfo/Asia/Shanghai/etc/localtime # Use ntpdate to synchronize time yum install-y ntp ntpdate-u pool.ntp.org date #
Install nginx + php5.3 on Centos. Click here to view details.
# View system version information cat/etc/issue uname-a # set the time zone rm-rf/etc/localtime ln-s/usr/share/zoneinfo/Asia/Shanghai/etc/localtime # Use ntpdate synchronization time yum install-y ntp ntpdate-u pool.ntp.org date # search and delete the rpm package rpm-qa | grep httpd # [search for whether the specified rpm package is installed] -- all search * httpd * rpm-e httpd # [delete an rpm package] rpm-qa | grep phprpm-e phpyum-y remove httpd * yum-y remove php-mysql # automatically select the fastest yum source yum-y install yum-fastestmirror # disable SELinuxvi/etc/selinux/config # Change SELINUX = enforcing to SELINUX = disabled # yum install dependency library yum-y install gcc-c ++ gcc-g77 flex bison file libtool-libs autoconf kernel-devel libjpeg-devel libpng-devel libpng10 libpng10-devel gd-devel freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel kernel-devel ncurses-devel curl-devel kernel e2fsprogs-devel krb5 krb5-devel libidn-devel openssl-devel vim-minimal nano fonts-chinese gettext -devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils
# Download and install the dependency library wget-c http://soft.vpser.net/web/libiconv/libiconv-1.14.tar.gzwget -C http://soft.vpser.net/web/libmcrypt/libmcrypt-2.5.8.tar.gzwget -C http://soft.vpser.net/web/mhash/mhash-0.9.9.9.tar.gzwget -C http://soft.vpser.net/web/mcrypt/mcrypt-2.6.8.tar.gzwget -C http://soft.vpser.net/lib/autoconf/autoconf-2.13.tar.gz#autoconftar Zxf autoconf-2.13.tar.gzcd autoconf-2.13 /. /configure -- prefix =/usr/local/autoconf-2.13make & make installcd .. /# libiconvtar zxf libiconv-1.14.tar.gzcd libiconv-1.14 /. /configuremake & make installcd .. /# libmcrypttar zxf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8 /. /configuremake & make install/sbin/ldconfigcd libltdl /. /configure -- enable-ltdl-installmake & make installcd .. /.. /# mhashtar zxf mhash-0.9.9.9.tar.gzcd /. /configuremake & make installcd .. /ln-s/usr/local/lib/libmcrypt. la/usr/lib/libmcrypt. la1-s/usr/local/lib/libmcrypt. so/usr/lib/libmcrypt. soln-s/usr/local/lib/libmcrypt. so.4/usr/lib/libmcrypt. so.4ln-s/usr/local/lib/libmcrypt. so.4.4.8/usr/lib/libmcrypt. so.4.4.8ln-s/usr/local/lib/libmhash. a/usr/lib/libmhash. a1-s/usr/local/lib/libmhash. la/usr/lib/libmhash. la1-s/usr/local/lib/libmhash. so/usr/lib/libmhash. soln-s/usr/local/lib/libmhash. so.2/usr/lib/libmhash. so.2ln-s/usr/local/lib/libmhash. so.2.0.1/usr/lib/libmhash. so.2.0.1ldconfig # mcrypttar zxf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8 /. /configuremake & make installcd .. /# For a 64-bit system, run ln-s/usr/lib64/libpng. */usr/lib/ln-s/usr/lib64/libjpeg. */usr/lib/ldconfig # modify ld. so. confcat/etc/ld. so. confecho "/lib">/etc/ld. so. confecho "/usr/lib">/etc/ld. so. confecho "/usr/lib64">/etc/ld. so. confecho "/usr/local/lib">/etc/ld. so. conf # update library cache ldconfig
# Kernel Optimization for High-load linux servers
# Modify limits
Ulimit-v unlimited
# Optimized maximum number of opened files in the system
? ? By default, the system allows a maximum of 1024 files to be opened, which is far from enough for web servers with large traffic volumes. You can use ulimit to modify and query the maximum number of opened files in the system.
Generally, you can use ulimit-n to view the maximum number of opened files allowed by the system. For example:
Ulimit-n
1024 # system return
? ? Modify this parameter permanently. Modify/etc/security/limits. conf.
Run:
Cat>/etc/security/limits. conf <eof * soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard nofile 65535eof # Modify/etc/sysctl. conf. Run echo "fs. file-max = 65535">/etc/sysctl. conf # Run the following command to make the parameter take effect after modification:/sbin/sysctl-p
============================== Install PHP5.3.28 ============ ====================================
# Install PHP
# Set the environment variable export PHP_AUTOCONF =/usr/local/autoconf-2.13/bin/autoconfexport PHP_AUTOHEADER =/usr/local/autoconf-2.13/bin/autoheader # download the PHP installation package wget-c http://soft.vpser.net/web/php/php-5.3.28.tar.gz# Install tar zxf php-5.3.28.tar.gzcd php-5.3.28 /. /configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc -- enable-fpm -- with-fpm-user = www -- with-fpm-group = www -- with-mysql = mysqlnd -- with-mysqli = mysqlnd -- with-pdo-mysql = mysqlnd -- with-iconv-dir -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir =/usr -- enable-xml -- disable-rpath -- enable-magic-quotes -- enable-safe-mode -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curl -- enable-mbregex -- enable-mbstring -- with-mcrypt -- enable-ftp -- with-gd -- enable-gd-native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- without-pear -- with-gettext -- disable-fileinfomake ZEND_EXTRA_LIBS = '-liconv' make installrm-f/usr/bin/phpln-s/usr/local/php/ bin/php/usr/bin/phpln-s/usr/local/php/bin/phpize/usr/bin/phpizeln-s/usr/local/php/sbin/php- fpm/usr/bin/php-fpmldconfig
# Copy the php configuration file mkdir-p/usr/local/php/etccp php. ini-production/usr/local/php/etc/php. ini # php extensions modify php. inised-I's/post_max_size = 8 M/post_max_size = 50 M/G'/usr/local/php/etc/php. inised-I's/upload_max_filesize = 2 M/upload_max_filesize = 50 M/G'/usr/local/php/etc/php. inised-I's/; date. timezone =/date. timezone = PRC/G'/usr/local/php/etc/php. inised-I's/short_open_tag = Off/short_open_tag = On/G'/usr/local/php/etc/php. inised-I's/; cgi. fix_pathinfo = 1/cgi. fix_pathinfo = 0/G'/usr/local/php/etc/php. inised-I's/; cgi. fix_pathinfo = 0/cgi. fix_pathinfo = 0/G'/usr/local/php/etc/php. inised-I's/; cgi. fix_pathinfo = 1/cgi. fix_pathinfo = 0/G'/usr/local/php/etc/php. inised-I's/max_execution_time = 30/max_execution_time = 300/G'/usr/local/php/etc/php. inised-I's/register_long_arrays = On/; register_long_arrays = On/G'/usr/local/php/etc/php. inised-I's/magic_quotes_gpc = On/; magic_quotes_gpc = On/G'/usr/local/php/etc/php. inised-I's/disable_functions =. */disable_functions = passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_get_status, ini_alter, ini_restore, dl, openlog, syslog, readlink, symlink, stream_socket_server/G'/usr/local/php/etc/php. ini
#Install ZendGuardLoader for PHP 5.3
64-bit system execution:
Wget-c? Http://soft.vpser.net/web/zend/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
Tar zxf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
Mkdir-p/usr/local/zend/
Cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader. so/usr/local/zend/
32-bit system execution:
Wget-c? Http://soft.vpser.net/web/zend/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
Tar zxf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
Mkdir-p/usr/local/zend/
Cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader. so/usr/local/zend/
# Write ZendGuardLoader to php. ini ......
cat >>/usr/local/php/etc/php.ini<<EOF;eaccelerator;ionCube[Zend Optimizer]zend_extension=/usr/local/zend/ZendGuardLoader.sozend_loader.enable=1zend_loader.disable_licensing=0zend_loader.obfuscation_level_support=3zend_loader.license_path=EOF
Echo "Creating new php-fpm configure file ......"
cat >/usr/local/php/etc/php-fpm.conf<<EOF[global]pid = /usr/local/php/var/run/php-fpm.piderror_log = /usr/local/php/var/log/php-fpm.loglog_level = notice[www]listen = /tmp/php-cgi.socklisten.backlog = -1listen.allowed_clients = 127.0.0.1listen.owner = wwwlisten.group = wwwlisten.mode = 0666user = wwwgroup = wwwpm = dynamicpm.max_children = 10pm.start_servers = 2pm.min_spare_servers = 1pm.max_spare_servers = 6request_terminate_timeout = 100request_slowlog_timeout = 0slowlog = /var/log/slow.logEOF
# Copy the php-fpm init. d File
Cp./php-5.3.28/sapi/fpm/init. d. php-fpm/etc/init. d/php-fpm
Chmod + x/etc/init. d/php-fpm
============================================ PHP installation end ========== ====================================
================================ Install Nginx 1.6.0 ========== ====================================
# Install Nginx
# Create user group and user groupadd wwwuseradd-s/sbin/nologin-g www # download and install the PCRE Library wget-c http://soft.vpser.net/web/pcre/pcre-8.12.tar.gztar zxf pcre-8.12.tar.gzcd /. /configuremake & make installcd .. /ldconfig # download and install nginxwget-c http://soft.vpser.net/web/nginx/nginx-1.6.0.tar.gztar zxf nginx-1.6.0.tar.gzcd /. /configure -- user = www -- group = www -- prefix =/usr/local/nginx -- with-http_stub_status_module -- with-http_ssl_module -- with-http_gzip_static_module -- with-ipv6make & make installcd .. // # Set the soft connection ln-s/usr/local/nginx/sbin/nginx/usr/bin/nginxldconfig # create the website directory and set the permission mkdir-p/data0/wwwrootchmod + w /data0/wwwrootchown-R www: www/data0/wwwroot # create a log directory and set the permission mkdir-p/data0/wwwlogschmod 777/data0/wwwlogs
# Nginx configuration file
Replace/usr/local/nginx/conf/nginx. conf with the following text:
user www www;worker_processes auto;error_log /data0/wwwlogs/nginx_error.log crit;pid /usr/local/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.worker_rlimit_nofile 51200;events{use epoll;worker_connections 51200;multi_accept on;}http{include mime.types;default_type application/octet-stream;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 50m;sendfile on;tcp_nopush on;keepalive_timeout 60;tcp_nodelay on;fastcgi_connect_timeout 300;fastcgi_send_timeout 300;fastcgi_read_timeout 300;fastcgi_buffer_size 64k;fastcgi_buffers 4 64k;fastcgi_busy_buffers_size 128k;fastcgi_temp_file_write_size 256k;gzip on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_http_version 1.0;gzip_comp_level 2;gzip_types text/plain application/x-javascript text/css application/xml;gzip_vary on;gzip_proxied expired no-cache no-store private auth;gzip_disable "MSIE [1-6]\.";#limit_conn_zone $binary_remote_addr zone=perip:10m;##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.server_tokens off;#log formatlog_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for';include vhost/*.conf;}
Mkdir-p? /Usr/local/nginx/conf/vhost
# Creating a virtual machine
# If the website domain name is www.xxx.com, create a website directory
Mkdir-p/data0/wwwroot/www.xxx.com
Chown-R? Www: www/data0/wwwroot/www.xxx.com
#, And in/usr/local/nginx/conf/vhost? Under the Create File www.xxx.com. conf, the file content is below, www.xxx.com with the actual domain name.
server{listen 80;server_name www.xxxx.com;index index.html index.htm index.php default.html default.htm default.php;root /data0/wwwroot/www.xxxx.com;#error_page 404 /404.html;location ~ [^/]\.php(/|$){# comment try_files $uri =404; to enable pathinfotry_files $uri =404;fastcgi_pass unix:/tmp/php-cgi.sock;fastcgi_index index.php;include fastcgi.conf;#include pathinfo.conf;}location /nginx_status {stub_status on;access_log off;}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires 30d;}location ~ .*\.(js|css)?${expires 12h;}access_log /data0/wwwlogs/www.xxxx.com.log access;}
# Run the test
Cat>/data0/wwwroot/www.xxx.com/phpinfo.php < Phpinfo ();
?>
Eof
# Access http://www.xxx.com/phpinfo.php
# Set Nginx auto-start upon startup
Http://soft.vpser.net/lnmp/ext/init.d.nginx wget-c
Cp init. d. nginx/etc/init. d/nginx
Chmod + x/etc/init. d/nginx
Chkconfig-add php-fpm
Chkconfig-add nginxchkconfig-level 345 php-fpm on
Chkconfig-level 345 nginx onchkconfig-list
/Etc/init. d/php-fpm start
/Etc/init. d/nginx start
# Add a firewall to set an open port (depending on your situation)
Vi/etc/sysconfig/iptables
-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 80-j ACCEPT
# Restarting the Firewall
Service iptables restart
# Save the firewall settings
Service iptables save
========================================== Nginx installation end ============ ====================================
Original article address: Install nginx + php5.3 on Centos. Thank you for sharing it with me.