varnish+nginx+php (FastCGI) +mysql5+mencache+mencachedb (2)

Source: Internet
Author: User
Tags chmod curl install php zts server memory varnish

Two.) Install MySQL
Install mysql-5.0.45.tar.gz, the following is the overall compilation file
1.-static 13%
--with-client-ldflags=-all-static
--with-mysqld-ldflags=-all-static
Static linking improves performance by 13%

2.-PGCC 1%
cflags= "-o3-mpentiumpro-mstack-align-double" CXX=GCC \
cxxflags= "-o3-mpentiumpro-mstack-align-double \
-felide-constructors-fno-exceptions-fno-rtti "
If it is a inter processor, use PGCC to improve 1% performance

3. Unix Socket 7.5%
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
Improved 7.5% performance with UNIX socket links, so MySQL performance under Windows must be inferior to UNIX

4.--enable-assembler
Allow assembly mode (optimize performance)


[[email protected]] #tar ZXVF mysql-5.0.45.tar.gz
[Email protected]]#./configure--prefix=/usr/local/mysql/--without-debug--with-unix-socket-path=/tmp/mysql.sock --with-client-ldflags=-all-static--with-mysqld-ldflags=-all-static--enable-assembler--WITH-EXTRA-CHARSETS=GBK, Gb2312,utf8--with-pthread--enable-thread-safe-client
[[email protected]] #make-j && make install
[[email protected]] #groupadd MySQL
[[email protected]] #useradd-g MySQL MySQL
[[email protected]] #bin/mysql_install_db--user=mysql
[[email protected]] #chown-R root.
[[email protected]] #chown-r MySQL Data
[[email protected]] #chgrp-R MySQL.
[[email protected]] #bin/mysqld_safe--user=mysql &
[[email protected]] #cd bin
[[Email Protected]]#/usr/local/mysql/share/mysql/mysql.server stop
[[email protected]] #cp/usr/local/mysql/share/mysql/mysql.server/etc/init.d/mysql
[[email protected]] #chmod 755/etc/init.d/mysql
[[email protected]] #chkconfig--level 345 MySQL on

--------------------------------------------------------------------------------------------------------------- ----------


Three,) Install PHP 5.2.5 (fastcgi mode)
1. Compile and install the required support libraries for PHP 5.2.5:

[[email protected]] #tar ZXVF libiconv-1.11.tar.gz
[[email protected]] #cd libiconv-1.11/
[[Email Protected]]#./configure--prefix=/usr/local/webserver/lib/libiconv
[[email protected]] #make && make install
[[email protected]] #cd. /

[[email protected]] #tar ZXVF freetype-2.3.5.tar.gz
[[email protected]] #cd freetype-2.3.5/
[[Email Protected]]#./configure--prefix=/usr/local/webserver/lib/freetype
[[email protected]] #make && make install
[[email protected]] #cd. /

[[email protected]] #tar ZXVF libpng-1.2.20.tar.gz
[[email protected]] #cd libpng-1.2.20/
[[Email Protected]]#./configure
[[email protected]] #make && make install
[[email protected]] #cd. /

[[email protected]] #tar ZXVF jpegsrc.v6b.tar.gz
[[email protected]] #cd jpeg-6b/
[Email protected]]#./configure--enable-static--enable-shared
[[email protected]] #make && make install
[[email protected]] #cd. /

T[[email protected]] #ar ZXVF gd-2.0.35.tar.gz
[[email protected]] #cd gd-2.0.35/
[Email protected]]#./configure--prefix=/usr/local/webserver/lib/gd--with-freetype=/usr/local/webserver/lib/ FreeType--with-jpeg--with-png
[[email protected]] #make
[[email protected]] #make install
[[email protected]] #cd. /

[[email protected]] #tar ZXVF libxml2-sources-2.6.30.tar.gz
[[email protected]] #cd libxml2-2.6.30/
[[Email Protected]]#./configure--prefix=/usr/local/webserver/lib/libxml
[[email protected]] #make && make install
[[email protected]] #cd. /


-------------------------------------------------------------------------------------------------------------
2. Compile and install PHP (fastcgi mode)

[[email protected]] #tar ZXVF php-5.2.4.tar.gz
[[email protected]] #cd php-5.2.4/
[[Email protected]]#./configure--prefix=/usr/local/php--with-mysql=/usr/local/mysql--enable-ftp-- with-config-file-path=/usr/local/php--enable-zip--with-zlib--with-curl--without-iconv--with-iconv=/usr/local/ Lib--with-libxml-dir=/usr--enable-xml--with-xmlrpc--enable-mbregex-backtrack--with-gettext--with-gd=/usr/lib-- Enable-gd-native-ttf--with-ttf--enable-gd-jis-conv--with-jpeg-dir=/usr/local--with-png-dir=/usr/local-- With-freetype-dir=/usr/local/php/lib/freetype--with-curl--with-curlwrappers--enable-mbregex--enable-fastcgi-- Enable-force-cgi-redirect--enable-dom--enable-safe-mode--enable-discard-path--disable-debug--disable-rpath   --enable-bcmath--enable-shmop--enable-sysvsem--with-ldap--enable-sockets--enable-soap-- Enable-inline-optimization--enable-mbstring=all--with-ming=/usr--with-pdo-sqlite--enable-pdo--with-pdo-mysql=/ Usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config

[[email protected]] #cp Php.ini-dist/usr/local/php/etc/php.ini
[[email protected]] #cd. /

--------------------------------------------------------------------------------------------------------------- --
3. Modify the php.ini file
Manual modification: Find Extension_dir = "./" in/usr/local/php/etc/php.ini
Modified to Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
and add the following lines after this line, and then save:
Extension = "memcache.so"
Extension = "gd.so"

4. Automatic modification: If the trouble of manual modification, you can execute the following shell command, automatically complete the modification of the php.ini file:
[email protected]]sed-i ' S#extension_dir = './' #extension_dir = '/usr/local/php/lib/php/extensions/ no-debug-non-zts-20060613/"\nextension =" memcache.so "\nextension =" gd.so "\n# '/usr/local/php/etc/php.ini


--------------------------------------------------------------------------------

5. Attached: After compiling PHP, add the extension method to PHP. (This step is optional)

[[email protected]] #cd php-5.2.4/pcntl
[[Email Protected]]#/usr/local/php/bin/phpize
[[Email Protected]]#./configure--with-php-config=/usr/local/php/bin/php-config
[[email protected]] #make && make install
[[email protected]] #cd. /.. /.. /

[[email protected]] #cd php-5.2.5/ext/gd/
[[Email Protected]]#/usr/local/php/bin/phpize
[Email protected]]#./configure--with-jpeg-dir--with-png-dir--with-zlib-dir--with-ttf--with-freetype-dir-- With-php-config=/usr/local/php/bin/php-config
[[email protected]] #make-j 50
[[email protected]] #make install

The

uses Memcached to process real-time data reads and writes; MySQL is the biggest bottleneck that can affect performance, and is solved with a MySQL master library (write-only) + multiple MySQL secondary libraries (read-only) for the primary and secondary library clusters. In addition, the access count and other real-time very strong things with memcache cache.  
     
[[email protected]] #tar zxvf memcache-2.2.1.tgz      
[[email protected]] #cd memcache-2.2.1/      
[[ email protected]]#/usr/local/php/bin/phpize     
[[Email protected]]#./ Configure--with-php-config=/usr/local/php/bin/php-config 
[[email protected]] #make-j 50        
[[email protected]] #make install 
  
Install support for MySQL PDO driver

[[email protected]] #tar XZVF pdo-1\[1\].0.3.tgz                         
[[email  Protected]] #cd pdo-1.0.3/                                       
[[email protected]]#/usr/local/php/bin/phpize                            
[[Email protected]]#./configure--with-php-config=/usr/local/php/bin/ Php-config--with-pdo-mysql=/usr/local/mysql/   
[[email protected]] #make-j         
[[email protected]] #make install 

-------------------------------------------------------------------------------------------------------------

6. Install the spawn-fcgi included in the lighttpd to start the php-cgi

Note: The SPAWN-FCGI program in the compact package is a version that has been compiled into binary.

[[email protected]] #cp Spawn-fcgi/usr/local//php/bin
[[email protected]] #chmod +x/usr/local/php/bin/spawn-fcgi

7, start the php-cgi process, listen to 127.0.0.1 10080 ports, the number of processes is 250 (if the server memory is less than 3GB, can only open 25 processes), the user is www:

/usr/local/php/bin/spawn-fcgi-a 127.0.0.1-p 10080-c 250-u www-f/usr/local/php/bin/php-cgi

8. Set Boot start

[[email protected]] #echo "/usr/local/mysql/share/mysql/mysql.server start" >>/etc/rc.local
[[email protected]] #echo "/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf" >>/etc/rc.local
[[email protected]] #echo "/usr/local/php/bin/spawn-fcgi-a 127.0.0.1-p 10080-c 250-u www-f/usr/local/php/bin/php-cgi" >>/etc/rc.local

-------------------------------------------------------------------------

varnish+nginx+php (FastCGI) +mysql5+mencache+mencachedb (2)

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.