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

Source: Internet
Author: User
Tags gmp install openssl ldap mcrypt xslt zts
Centos + nginx1.3.9 + php5.4.9 + mysql5.5.28 + memcached 1: install Nginx 1 and add a user who cannot log on and does not have a home directory:
# Useradd www-M-s/sbin/nologin (nginx can be used for www, indicating nginx users)
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 there is an error message:

./Configure: error: the HTTP rewrite module requires the PCRE library.

Follow the steps below to install pcre-devel and openssl-devel to solve the problem.

yum -y install pcre-devel openssl openssl-devel)

MGB, a problem occurs during installation. make: *** No rule to make targetbuild ', needed bydefault'. Stop. it is an inexplicable wonder;

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 and install nginx
# Tar-zxvf nginx-1.3.9.tar.gz # D 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 -- The path after with-pcre is the path after the source code package is decompressed, instead of the installation path. Otherwise, an error is reported!
[2]. install PHP 1 and install 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 and can be downloaded through other methods) # 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 and install php
# 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 '--- gd -- enable-gd-native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap --- 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

Troubleshooting:

Checking for cURL in default path... not found

Configure: error: Please reinstall the libcurl distribution-easy. h shoshould be in/include/curl/

In fact, the dev package of curl is not installed. Solution: under the terminal

# yum -y install curl-devel

Then you can continue.

When you compile PHP5 in CentOS, you may encounter the following errors. basically, you can install the corresponding libraries using yum. The following are some specific solutions:

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 shocould use cURL for url streams... No checking for cURL in default path... Not found configure: error: Please reinstall the libcurl distribution? Easy. h shoshould 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 NDBM support... No configure: error: DBA: cocould not find necessary header file (s ).

Fix: yum install db4-devel

Checking for fabsf... Yes checking for floopen-end... Yes configure: error: Invalid Lib. h not found.

Fix: yum install libjpeg-devel

Checking for fabsf... Yes checking for floopen-end... Yes checking for pai_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 signature, but U8T_CANONICAL is missing. This shocould 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 checking for Oracle Database OCI8 support... No checking for unixODBC support... Configure: error: ODBC header file '/usr/include/sqlext. 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 implements des... (Cached)/usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path... Not found configure: error: Please reinstall 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 checking for snmp_parse_oid in-lsnmp... No checking for init_snmp in-lsnmp... No configure: error: SNMP sanity check failed. Please check 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: cocould 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 is not 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: cocould 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 the php configuration file
# 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 whether the 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 = 5. max_spare_servers = 35 (cannot be greater than max_children) pm. max_requests = 500
4. add a 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
3. install Mysql 3.1 and create the mysql installation directory.
mkdir -p /opt/mysql/
3.2. create a data storage directory
mkdir -p /data/mysql/
3.3 Create users and user groups and grant data storage directory permissions
# useradd mysql -M -s /sbin/nologin# chown mysql.mysql -R /data/mysql/
3.4 install 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 the installation, the mysql server runs normally, but the gbk character set cannot be used. The system has Chinese support installed, and mysql cannot be reinstalled several times.

There is no gbk in the show character set;

If set names gbk is set, an error is returned. #1115-Unknown character set: 'gbk'

Solution:

The preceding compilation parameter-DWITH_EXTRA_CHARSETS: STRING = utf8, the gbk parameter causes problems. Method 1. remove this parameter, the default value is charset that supports all. Method 2: directly change to-DWITH_EXTRA_CHARSETS = all. after the-DDEFAULT_COLLATION = utf8_general_ci option is added, mysql may be started. add the cnf file [mysqld] to character_set_server = utf8

3.6 initialize the database
# cd /opt/mysql# scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/data/mysql/
3.7. configure the environment
# Cp support-files/my-medium.cnf/etc/my. cnf (my. the memory size of the cnf reference server is generally 256 M in my-medium.cnf and 512 M in my-large.cnf) # 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 the environment variable
3.8. start and set the initial password
# /etc/init.d/mysql start# mysqladmin -uroot password '123123'

Statement for modifying the password

1: UPDATE mysql. user SET Password = PASSWORD ('newpwd') WHERE User = 'root'; (New Password) 2: flush privileges; (refresh permission)

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

4. install 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. install libevent
tar -zxvf libevent-2.0.18-stable.tar.gzcd libevent-2.0.18-stable./configure --prefix=/usr/local/libeventmake && make installcd ../
3. install 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 extension for Memcache

(1). select the memcache version you want to download in the http://pecl.php.net/package/memcache. (2) install the memcache extension of PHP

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 make install

(3) after the above installation is complete, a message similar to this will be displayed:

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

(4) modify extension_dir = "./" in php. ini

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 add a 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 for automatic start next time * Note: User-u must be specified. In this example, the WEB user www is used.

6. use telnet to view the status
Telnet 192.168.1.2 12000 stats # view the running status quit # exit
Note:
Php5.4.9 startup command:/opt/php/sbin/php-fpm check php running process ps aux | grep php-fpmphp-fpm close: after kill-INT 'cat/usr/local/php/var/run/php-fpm.pid 'is disabled,/opt/php/sbin/php-fpm is required to start; create with touch without a php-fpm.pid. Php-fpm restart: kill-USR2 'cat/usr/local/php/var/run/php-fpm.pid 'Nginx service startup command: /opt/nginx/sbin/nginx syntax check/opt/nginx/sbin/nginx-t check nginx. conf file syntax;

Php startup error:

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

Change user = fpm group = fpm to nginx on php-fpm (for nginx installation)

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.