CentOS 5.5 Installation mysql5.1.57+php5.2.17 (FastCGI) +nginx1.0.1 high Performance Web server [reprint]

Source: Internet
Author: User
Tags fpm install php imagemagick ldap openssl stop script zts openldap

CentOS 5.5 Installation mysql5.1.57+php5.2.17 (FastCGI) +nginx1.0.1 high Performance Web server [reprint]September 05, 2012 ⁄linux Technology ⁄ a total of 12362 characters ⁄ font size small big ⁄ no comments ⁄ read the page

As the production environment is the FreeBSD platform, before also wrote a FreeBSD under the installation of mysql5.1.56+php5.2.17 (FastCGI) +nginx1.0.1 high-performance Web server, have children's shoes want to help write an installation of CentOS under the tutorial , in fact, there are many online, but many are not too complete, more or less a few problems, so wrote a CentOS 5.5 installation mysql5.1.57+php5.2.17 (FastCGI) +nginx1.0.1 high-performance Web server

In the case of high concurrent connection, Nginx is a good substitute for Apache server. Nginx can also be used as a 7-tier load balancer server. According to my test results, Nginx 1.0.1 + PHP 5.2.17 (FastCGI) can withstand more than 30,000 concurrent connections, equivalent to 10 times times Apache in the same environment.
First step: Install the software required for the system environment

Yum install-y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-deve L zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs E2 Fsprogs-devel krb5-libs krb5-devel krb5-server libidn libidn-devel OpenSSL openssl-devel openldap openldap-devel Nss_ LDAP openldap-clients Openldap-servers

Step two: Compile the libraries required to install PHP

Mkdir-p/data/softmkdir-p/data/srccd/data/srcwget Http://lcmp.googlecode.com/files/libiconv-1.13.1.tar.gztar zxvf LIBICONV-1.13.1.TAR.GZCD libiconv-1.13.1./configure--prefix=/usr/localmake && make INSTALLCD. wget Http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/downloadtar ZXVF LIBMCRYPT-2.5.8.TAR.GZCD libmcrypt-2.5.8/./configuremake && make INSTALL/SBIN/LDCONFIGCD libltdl/./ Configure--enable-ltdl-installmake && make INSTALLCD. /.. /wget Http://sourceforge.net/projects/mhash/files/mhash/ JXVF MHASH- mhash- && make Installecho "/usr/local/lib" >>/etc/ LD.SO.CONF/SBIN/LDCONFIGCD. wget Http://vps.googlecode.com/files/mcrypt-2.6.8.tar.gztar zxvf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8/sbin/ldconfig. /configuremake && make Install

Step three: Compile and install MySQL

Cd/data/srcwget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.57.tar.gz/from/http:// Mirror.services.wisc.edu/mysql/tar zxvf MYSQL-5.1.57.TAR.GZCD Mysql-5.1.57/usr/sbin/groupadd mysql/usr/sbin/ useradd-g MySQL mysql./configure--prefix=/data/soft/mysql--enable-assembler--with-extra-charsets=complex-- Enable-thread-safe-client--with-big-tables--with-readline--with-ssl--with-embedded-server-- Enable-local-infilemake && make installchown-r mysql:mysql/data/soft/mysqlchmod u+w/data/soft/mysqlmkdir-p/ Data/databasechown-r Mysql:mysql/data/database

Create a data table as a MySQL user account:


Create a MySQL configuration file

RM-RF/DATA/SOFT/MYSQL/MY.CNFVI/DATA/SOFT/MYSQL/MY.CNF is as follows: [client]port = 3306socket =/tmp/mysql.sock[mysql] No-auto-rehash[mysqld]user = Mysqlport = 3306socket =/tmp/mysql.sockbasedir =/data/soft/mysqldatadir =/data/ Databaseopen_files_limit = 600back_log = 20max_connections = 1000max_connect_errors = 200table_cache = 60external-locking = Falsemax_allowed_packet = 16msort_buffer_size = 128kjoin_buffer_size = 128Kthread_cache_size = 10thread_concurrency = 8query_cache_size = 2mquery_cache_limit = 2mquery_cache_min_res_unit = 2kdefault_table_type = Myisamthread_stack = 192ktransaction_isolation = Read-uncommittedtmp_table_size = 512kmax_heap_table_size = 32M/data/ Soft/mysql/logs/slow.log/data/soft/mysql/logs/error.loglong_query_time = 1log_long_formatserver-id = 1#log-bin =/ Data/soft/mysql/binlogbinlog_cache_size = 2mmax_binlog_cache_size = 4mmax_binlog_size = 512Mexpire_logs_days = 7key_ Buffer_size = 4mread_buffer_size = 1mread_rnd_buffer_size = 2mbulk_insert_buffer_size = 2Mmyisam_Sort_buffer_size = 4mmyisam_max_sort_file_size = 10gmyisam_max_extra_sort_file_size = 10Gmyisam_repair_threads = 1myisam_recover[mysqldump]quickmax_allowed_packet = 16M Modify Mysqld script cp/data/soft/mysql/share/mysql/mysql.server/etc /init.d/mysqldvi/etc/init.d/mysqld Modify Basedir=/data/soft/mysqldatadir=/data/databaseln-s/data/soft/mysql/my.cnf/ etc/my.cnf start Mysqlservice mysqld startlsof-i:3306netstat-ntupl |grep 3306 Test login Mysql/data/soft/mysql/bin/mysql-u root- pmysql> createdatabase hello;chkconfig--add mysqldchkconfig mysqld onchkconfig--list |grep mysqldservice mysqld Rest Art Step Fourth: Compiling and installing PHP (FastCGI)

1, install php-5.2.17

Cd/data/srcwget Http://cn.php.net/get/php-5.2.17.tar.gz/from/this/mirrorwget http://php-fpm.org/downloads/ Php-5.2.17-fpm-0.5.14.diff.gztar ZXVF PHP-5.2.17.TAR.GZGZIP-CD php-5.2.17-fpm-0.5.14.diff.gz | patch-d php-5.2.17-p1cd php-5.2.17sed-i "S/\!png_check_sig (SIG, 8)/png_sig_cmp (SIG, 0, 8)/" EXT/GD/LIBGD/GD_PNG.CCP. ./fopen_wrappers.c main/here refer to the FreeBSD PHP modified source code to resolve the Nginx virtual host Webshell cross-directory./configure--prefix=/data/soft/php-- With-config-file-path=/data/soft/php/etc--with-mysql=/data/soft/mysql--with-mysqli=/data/soft/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-soapmake zend_extra_libs= '-liconv ' make INSTALLCP php.ini-dist/data/soft/php/etc/php.inicd.

2. Compile and install the PHP5 extension module

wget Http://pecl.php.net/get/memcache-2.2.6.tgztar zxvf MEMCACHE-2.2.6.TGZCD memcache-2.2.6//data/soft/php/bin/ Phpize./configure--with-php-config=/data/soft/php/bin/php-configmake && make INSTALLCD. wget Http://lcmp.googlecode.com/files/eaccelerator- JXVF EACCELERATOR- Eaccelerator- Soft/php/bin/php-config--without-eaccelerator-use-inodemake && make INSTALLCD. wget Http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgztar zxvf PDO_MYSQL-1.0.2.TGZCD pdo_mysql-1.0.2/data/soft/php/bin/ Phpize./configure--with-php-config=/data/soft/php/bin/php-config--with-pdo-mysql=/data/soft/mysqlmake & & Make INSTALLCD. wget Http://launchpadlibrarian.net/73608965/ImageMagick-6.7.0-8.tar.gztar ZXVF IMAGEMAGICK-6.7.0-8.TAR.GZCD Imagemagick-6.7.0-8./configuremake && make INSTALLCD. wget Http://pecl.php.net/get/imagick-3.0.1.tgztar zxvf imagick-3.0.1.TGZCD imagick-3.0.1/data/soft/php/bin/phpize./configure--with-php-config=/data/soft/php/bin/php-configmake & & Make INSTALLCD.

3. Modify the php.ini file

Sed-i "s/output_buffering = off/output_buffering = on/"/data/soft/php/etc/php.inised-i "S/extension_dir =/; Extension_dir =/"/data/soft/php/etc/php.inised-i" s/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/"/data/soft/php/etc/php.inised-i ' s%;open_basedir =%open_basedir ="/tmp/:/ data/www/"% '/data/soft/php/etc/php.inised-i" s/disable_functions =/disable_functions = Popen,pentl_exec,passthru, EXEC,SYSTEM,SCANDIR,CHGRP,CHOWN,SHELL_EXEC,PROC_OPEN,PROC_GET_STATUS,INI_ALTER,INI_ALTER,INI_RESTORE,DL, Pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,show_source,escapeshellcmd, escapeshellarg,curl_exec,curl_multi_exec,parse_ini_file,assert/"/data/soft/php/etc/php.inised-i" s/expose_php = on/expose_php = off/"/data/soft/php/etc/php.inised-i" s/display_errors = On/display_errors = Off/"/data/soft/php/etc/ Php.inised-i "s/log_errors = Off/log_errors = on/"/data/soft/php/etc/php.ini

At the end of the php.ini add the following:

Extension_dir = "/data/soft/php/lib/php/extensions/no-debug-non-zts-20060613/" extension = "memcache.so" extension = " pdo_mysql.so "extension =" imagick.so "[eaccelerator]zend_extension="/data/soft/php/lib/php/extensions/ No-debug-non-zts-20060613/eaccelerator.so "eaccelerator.shm_size=" 1 "eaccelerator.cache_dir="/data/soft/ 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" Eaccelerator.keys = "disk_only" eaccelerator.sessions = "disk_only" eaccelerator.content = "Disk_only"

4. Create Eaccelerator Cache Directory


5. Create a php-fpm.conf file

Rm/data/soft/php/etc/php-fpm.confvi/data/soft/php/etc/php-fpm.conf is as follows: All relative paths in this config is relative to PHP ' s install prefixpid file/data/soft/php/logs/php-fpm.piderror log File/data/soft/php/logs/php-fpm.loglog Levelnoticewhen This amount of PHP processes exited with SIGSEGV or sigbus ... than this interval of time, a graceful restart would be initiated. Useful to work around accidental curruptions in accelerator ' s GKFX memory.1mtime limit on waiting child's reaction on Si Gnals from Master5sset to "no" to debug fpmyes name of pool. Used in logs and stats.defaultaddress to accept fastcgi requests on. Valid syntax is ' ip.ad.re.ss:port ' or just ' port ' or '/path/to/unix/socket ' set listen (2) Backlog-1set Permissions for UNIX socket, if one used. In Linux Read/write permissions must is set in order to allow connections from Web server. Many bsd-derrived systems allow connections regardless of permissions.0666additional PHP.ini defines, sPecific to this pool of workers./usr/sbin/sendmail-t-i1unix user of Processeswwwunix Group of Processeswwwprocess Manage R settingssets style of controling worker process count. Valid values is ' static ' and ' Apache-like ' staticsets the limit on the number of simultaneous requests that would be served . Equivalent to Apache maxclients directive. Equivalent to Php_fcgi_children environment in original php.fcgiused with any pm_style.8settings group for ' Apache-like ' p M stylesets the number of server processes created on startup. Used only if ' apache-like ' Pm_style is selected20sets the desired minimum number of idle server processes. Used only if ' apache-like ' Pm_style is selected5sets the desired maximum number of idle server processes.  Used only when ' Apache-like ' Pm_style was selected35  the timeout (in seconds) for serving a single request after which the worker process would be terminatedshould is used when ' max_execution_time ' ini option does not stop script Execu tion for someReason ' 0s ' means ' off ' 0sThe timeout (in seconds) for serving of single request after which a PHP backtrace would be dumped to slow.log file ' 0s ' means ' off ' 0sThe log file for slow Requestslogs/slow.logset open file desc rlimit65535set Max Core Si Ze rlimit0chroot to this directory at the start, absolute pathchdir to this directory at the start, absolute pathredirect Workers ' stdout and stderr into main error log. If not set, they'll is redirected to/dev/null, according to FastCGI Specsyeshow much requests each process should EXECU Te before respawn. Useful to work around memory leaks in 3rd party libraries. For endless request processing/specify 0Equivalent to Php_fcgi_max_requests1024comma separated list of IPv4 address Es of FastCGI clients that allowed to connect. Equivalent to Fcgi_web_server_addrs environment in original php.fcgi (5.2.2+) makes sense only with af_inet listening Socke T. Environment variables like ld_library_path/usr/local/bin:/usr/bin:/bin/tmp/tmp/tmp$ostype$machtype2  

6. Create WWW user and start php-fpm and join startup script

/usr/sbin/groupadd www/usr/sbin/useradd-g www wwwmkdir-p/data/wwwchown-r www:www/data/wwwchmod +w/data/wwwulimit-sh n 65535/data/soft/php/sbin/php-fpm startecho "Ulimit-shn 65535" >>/etc/rc.localecho "/data/soft/php/sbin/ PHP-FPM start ">>/etc/rc.local

Fifth step, compile and install Nginx-1.0.1

1. Install the Pcre library required by Nginx

wget Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gztar zxvf PCRE-8.12.TAR.GZCD pcre-8.12./ Configuremake && make INSTALLCD.

2. Installing Nginx

wget http://nginx.org/download/nginx-1.0.1.tar.gztar zxvf nginx-1.0.1.tar.gzcd nginx-1.0.1./configure--user=www-- Group=www--prefix=/data/soft/nginx--with-http_ssl_module--with-http_stub_status_module--with-http_gzip_static_ Module--with-http_realip_module--with-http_dav_module--with-http_flv_module--with-http_addition_module-- With-http_sub_modulemake && make INSTALLCD.

3. Create Nginx configuration file

Rm-f/data/soft/nginx/conf/nginx.confvi/data/soft/nginx/conf/nginx.conf as follows: User www www;worker_processes 1;error_ Log/data/soft/nginx/logs/error.log crit;pid/data/soft/nginx/conf/nginx.pid; #Specifies the value for maximum file Descriptors that can is opened by this process.worker_rlimit_nofile 65535;events{use epoll;worker_connections 10240;} Http{include mime.types;default_type application/octet-stream; #charset gb2312;server_names_hash_bucket_size 128; Client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 8m;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 128k;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; #limit_zone crawler $binary _remoTe_addr 10m;include server/*.txt;server{listen 80;server_name default;index index.php;root/data/www/test;location ~. *\. (PHP|PHP5) ${fastcgi_pass;fastcgi_index index.php;include fastcgi.conf;}}

4. Start the Nginx and test

/data/soft/nginx/sbin/nginx-t/data/soft/nginx/sbin/nginxmkdir-p/data/www/testecho "" >/data/www/test/ Index.phpecho "/data/soft/nginx/sbin/nginx" >>/etc/rc.local

Transferred from: http://wangxun.me/index.php/archives/309

CentOS 5.5 Installation mysql5.1.57+php5.2.17 (FastCGI) +nginx1.0.1 high Performance Web server [reprint]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.