Centos+nginx1.3.9+php5.4.9+mysql5.5.28+memcached

Source: Internet
Author: User
Tags gmp install php install openssl ldap snmp xslt zts server memory

One: Install Nginx

1. Add a user who cannot log on and does not have a home directory:

# useradd www-m-s/sbin/nologin (www can use Nginx, description is Nginx user)

2, necessary components

# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.zip# unzip pcre-8.13.zip# CD pcre-8.13#./ configure# make && make install

(If you have an error message:

./configure:error:the HTTP Rewrite module requires the PCRE library.

Please follow the installation method below: Install Pcre-devel and openssl-devel to solve the problem

Yum-y install pcre-devel OpenSSL openssl-devel)

MGB, there is a problem with the installation make: * * * No rule to make targetbuild ', needed Bydefault '. Stop., inexplicable marvelous;

Install Make:

Yum-y install gcc automake autoconf libtool make

Install g++:

Yum install gcc gcc-c++yum-y install OpenSSL openssl-devel

3, compile nginx and install

# TAR-ZXVF nginx-1.3.9.tar.gz# cd nginx-1.3.9#./configure--prefix=/opt/nginx--user=www--group=www--with-http_stub_ Status_module--with-http_ssl_module  --with-pcre=/usr/local/src/pcre-8.34# make && make install-- With-pcre after the path is the source package decompression path, not the installation path, otherwise it will error!

[2]. Install PHP

1. Install the necessary components

# yum-y Install libjpeg-devel libpng-devel# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/ libmcrypt-2.5.8.tar.gz (Download, this path is not necessarily correct, can be downloaded by other means) # TAR-ZXVF libmcrypt-2.5.8.tar.gz# cd libmcrypt-2.5.8#./configure# Make && make install

==64 bit system = =

Ln-s/usr/lib64/mysql//usr/lib/mysql

==64 bit system = =

2, compile PHP and install

# CD php-5.4.9#./configure--prefix=/opt/php--with-iconv--with-zlib--enable-xml--disable-rpath--enable-safe-mode- -enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curl--with-curlwrappers-- Enable-mbregex--enable-mbstring--with-mcrypt = ' installation directory for Libmcrypt '--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--enable-sqlite-utf8--with-pdo-mysql--enable-ftp--with-jpeg-dir--with-freetype-dir--with-png-dir-- ENABLE-FPM--with-fpm-user=www--with-fpm-group=www# make && make install

Related Error Resolution:

Checking for CURL in default path ... not found

Configure:error:Please Reinstall the Libcurl distribution-easy.h should be in/include/curl/

In fact, Curl's dev pack is not installed, solution: under Terminal

# yum-y Install Curl-devel

And then we can move on.

Some of the following error messages are sometimes encountered in the CentOS compilation PHP5, which can basically be solved by using Yum to install the appropriate libraries. Here are some specific workarounds:

Checking for BZIP2 support ... yes checking for BZIP2 in default path ... not found configure:error:Please reinstall the BZIP2 Distribution

Fix:yum Install Bzip2-devel

Checking for Curl support ... yes checking if we should use the Curl for URL streams ... no checking for curl in default path ... not f Ound configure:error:Please Reinstall the Libcurl distribution? Easy.h should be in/include/curl/

Fix:yum Install Curl-devel

Checking for Curl_multi_strerror In-lcurl ... yes checking for qdbm support ... no checking for gdbm support ... no checking for N DBM support ... no configure:error:DBA:Could not find necessary header file (s).

Fix:yum Install Db4-devel

Checking for FABSF ... yes checking for Floorf ... yes configure:error:jpeglib.h not found.

Fix:yum Install Libjpeg-devel

Checking for FABSF ... yes checking for Floorf ... yes checking for Jpeg_read_header in-ljpeg ... yes configure:error:png.h not Found.

Fix:yum Install Libpng-devel

Checking for png_write_image in-lpng ... yes If configure fails try? with-xpm-dir= configure:error:freetype.h not found.

Fix:reconfigure your PHP with the following option. --with-xpm-dir=/usr

Checking for png_write_image in-lpng ... yes configure:error:libXpm. (A|SO) not found.

Fix:yum Install Libxpm-devel

Checking for Bind_textdomain_codeset in-lc ... yes checking for GNU MP support ... yes configure:error:Unable to locate Gmp.h

Fix:yum Install Gmp-devel

Checking for Utf8_mime2text signature ... new checking for u8t_decompose ... configure:error:utf8_mime2text () has new Signatur E, but u8t_canonical is missing. This should is not happen. Check Config.log For additional information.

Fix:yum Install Libc-client-devel

Checking for LDAP support ... yes, shared checking for LDAP Cyrus SASL support ... yes Configure:error:Cannot find Ldap.h

Fix:yum Install Openldap-devel

Checking for Mysql_set_character_set in-lmysqlclient ... yes checking for Mysql_stmt_next_result in-lmysqlclient ... no Checki ng for Oracle Database OCI8 support ... no checking for UnixODBC support ... configure:error:ODBC header file '/usr/include/sq Lext.h ' Not found!

Fix:

Yum Install Unixodbc-devel

Checking for PostgreSQL support for PDO ... yes, shared checking for pg_config ... not found Configure:error:Cannot find LIBPQ -fe.h. Please specify correct PostgreSQL installation path

Fix:yum Install Postgresql-devel

Checking for SQLite 3 support for PDO ... yes, shared checking for PDO includes ... (cached)/usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path ... not found Configure:error:Please reins Tall the sqlite3 distribution

Fix:yum Install Sqlite-devel

Checking for utsname.domainname ... yes checking for Pspell support ... yes Configure:error:Cannot find Pspell

Fix:yum Install Aspell-devel

Checking whether to enable UCD SNMP hack ... yes checking for default_store.h ... no checking for Kstat_read in-lkstat ... no chec King for Snmp_parse_oid In-lsnmp ... no checking for Init_snmp in-lsnmp ... no Configure:error:SNMP sanity check failed. Please check the Config.log for more information.

Fix:yum Install Net-snmp-devel

Checking whether to enable XMLWriter support ... yes, shared checking for Xml2-config path ... (cached)/usr/bin/xml2-config checking whether Libxml build works ... (cached) Yes checking for XSL support ... yes, shared configure:error:xslt-config not found. Please reinstall the LIBXSLT >= 1.1.0 distribution

Fix:yum Install Libxslt-devel

Configure:error:xml2-config not found. Please check your LIBXML2 installation.

Fix:yum Install Libxml2-devel

Checking for PCRE headers location ... configure:error:Could not find pcre.h in/usr

Fix:yum Install Pcre-devel

Configure:error:Cannot find MySQL header files under Yes. Note that the MySQL client library isn't bundled anymore!

Fix:yum Install Mysql-devel

Checking for UnixODBC support ... configure:error:ODBC header file '/usr/include/sqlext.h ' not found!

Fix:yum Install Unixodbc-devel

Checking for pg_config ... not found Configure:error:Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

Fix:

Yum Install Postgresql-devel

Configure:error:Cannot Find Pspell

Fix:yum Install Pspell-devel

Configure:error:Could not find Net-snmp-config binary. Please check your NET-SNMP installation.

Fix:yum Install Net-snmp-devel

Configure:error:xslt-config not found. Please reinstall the LIBXSLT >= 1.1.0 distribution

Fix:yum Install Libxslt-devel

3. Copy and modify PHP configuration files

# CP Php.ini-production/opt/php/lib/php.ini or/usr/local/lib/php.ini# cp/opt/php/etc/php-fpm.conf.default/opt/php/ etc/php-fpm.conf#/opt/php/bin/php--ini   //test INI file is loaded

Modify PHP.ini

[Php]safe_mode = Onregister_globals = OFFMAGIC_QUOTES_GPC = Offallow_url_fopen = Offallow_url_include = Offexpose_php= Offdisable_functions = Shell_exec,system,exec,passthru,show_source,curl_exec,curl_multi_exec,get_cfg_var[date] Date.timezone = "Asia/shanghai"

Modify Php-fpm.conf

[global]pid = Run/php-fpm.piderror_log = Log/php-fpm.loglog_level = Noticeemergency_restart_threshold = 0emergency_ Restart_interval = 0[www]pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35 (cannot be greater than Max_children) Pm.max_requests = 500

4. Add service startup script

# CP nginx/etc/init.d/nginx# CP php-fpm/etc/init.d/php-fpm# chmod 755/etc/init.d/nginx# chmod 755/etc/init.d/php-fpm# Chkconfig--add nginx# chkconfig--add php-fpm# chkconfig nginx on# chkconfig php-fpm on

Three: Install MySQL

3.1. Create MySQL installation directory

Mkdir-p/opt/mysql/

3.2. Create a data storage directory

Mkdir-p/data/mysql/

3.3. Create user and user groups with permissions to assign data to directory

# useradd mysql-m-s/sbin/nologin# chown mysql.mysql-r/data/mysql/

3.4. Install the necessary components

# yum-y Install cmake# yum-y Install Ncurses-devel

3.5, compile and install MySQL

TAR-ZXVF mysql-5.5.28.tar.gz CD Mysql-5.5.28cmake. -dcmake_install_prefix=/opt/mysql-dmysql_unix_addr=/data/mysql/mysql.sock-ddefault_charset=utf8-ddefault_ Collation=utf8_general_ci-dwith_extra_charsets:string=utf8,gbk-dwith_myisam_storage_engine=1-dwith_innobase_ storage_engine=1-dwith_memory_storage_engine=1-dwith_readline=1-denabled_local_infile=1-dmysql_datadir=/data/ mysql-dmysql_user=mysql-dmysql_tcp_port=3306# make && make install

After installing the MySQL server is working properly, but cannot use the GBK character set, the system loaded with Chinese support, MySQL re-installed a few times not.

There is no GBK in show character set;

Set names GBK prompt error #1115-unknown character set: ' GBK '

Solution:

The above compiler parameter-DWITH_EXTRA_CHARSETS:STRING=UTF8,GBK This parameter causes the problem method One, removes this parameter, the default value is supports all the CharSet method second, changes directly to-dwith_extra_charsets =all after joining the-DDEFAULT_COLLATION=UTF8_GENERAL_CI option, you may have a problem starting MySQL, you must be in the my.cnf file [mysqld] to join Character_set_server=utf8

3.6, initializing the database

# cd/opt/mysql# scripts/mysql_install_db--user=mysql--basedir=/opt/mysql--datadir=/data/mysql/

3.7, configuring the environment

# CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF (here the MY.CNF reference server memory size general my-medium.cnf is 256m,my-large.cnf is 512M) # CP support-files/mysql.server/etc/init.d/mysql# chmod 755/etc/init.d/mysql# chkconfig mysql on# export PATH=/opt/mysql/ Bin: $PATH//SET environment variable

3.8. Start and set the initial password

#/etc/init.d/mysql start# mysqladmin-uroot password ' 123123 '

A statement to re-modify the password

1:update Mysql.user Set Password = Password (' newpwd ') WHERE user = ' root ';(new setup password) 2:flush privileges; (Refresh permissions)

Note: The MySQL log file is saved under/data/mysql/and corresponds to the path saved by the data file (for example,. err).

Four: Installation memcached

1. Download Libevent and memcached

http://memcached.googlecode.com/files/memcached-1.4.13.tar.gzhttps://github.com/downloads/libevent/libevent/ Libevent-2.0.18-stable.tar.gz

2. Installing Libevent

TAR-ZXVF libevent-2.0.18-stable.tar.gzcd libevent-2.0.18-stable./configure--prefix=/usr/local/libeventmake & & Make INSTALLCD. /

3. Installing memcached

TAR-ZXVF memcached-1.4.13.tar.gzcd memcached-1.4.13./configure--prefix=/usr/local/memcached--with-libevent=/usr/ Local/libevent/make && make INSTALLCD.

4: Install PHP extensions for Memcache

(1). Select the Memcache version you want to download in the Http://pecl.php.net/package/memcache. (2). Install PHP memcache Extensions

Tar vxzf memcache-2.2.6.tar.gz cd memcache-2.2.6/usr/local/php/bin/phpize./configure? enable-memcache? With-php-config=/usr/local/php/bin/php-config? with-zlib-dir make do Install

(3). There will be a hint like this after the installation is complete:

Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/

(4). Change the Extension_dir in php.ini = "./" To

Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/"

(5). Add a row to load the memcache extension: extension=memcache.so

5. Start and join the startup item

/usr/local/memcached/bin/memcached-d-L 192.168.1.2-u www-m 512-c 10240-p 12000-p/tmp/memcached.pid

Add the above to/etc/rc.local to facilitate the next automatic start * Note: User-U must be specified, where the example is used by the Web user www

6. Use Telnet to view the status

Telnet 192.168.1.2 12000stats #查看运行状态quit #退出

Note:

php5.4.9 Start command:/OPT/PHP/SBIN/PHP-FPM detect PHP Running process PS Aux|grep php-fpmphp-fpm off: Kill-int ' cat/usr/local/php/var/run/ Php-fpm.pid ' off, requires/opt/php/sbin/php-fpm to start; no php-fpm.pid is created with touch. PHP-FPM restart: kill-usr2 ' cat/usr/local/php/var/run/php-fpm.pid ' Nginx service start command:/opt/nginx/sbin/nginx syntax detection/opt/nginx/sbin /nginx-t    detection nginx.conf file syntax;

PHP Startup error:

ERROR: [Pool www] cannot get uid for user ' fpm '

Need to change user=fpm group=fpm fpm to Nginx on PHP-FPM (user installed Nginx)

  • 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.