Install nginx PHP MySQL and related extensions in yum in redhat6.2
Reference: http://blog.s135.com/nginx_php_v6/
Reference: http://kerry.blog.51cto.com/172631/857461
Reference: http://www.cnblogs.com/sink_cup/archive/2012/09/14/web_server.html
Use the centos source to install and use the repo file of centos6 of 163.com, yum makecache
Sudo-S
Lang = C
Yum-y install GCC gcc-C ++ Autoconf libjpeg-devel libpng-devel FreeType-devel libxml2 libxml2-devel zlib-devel glibc-devel glib2 glib2-devel Bzip2 bzip2-devel ncurses- devel curl-devel e2fsprogs e2fsprogs-devel
The krb5 krb5-devel libidn-devel OpenSSL-devel OpenLDAP openldap-devel nss_ldap openldap-clients openldap-servers Gd-devel
Name of the relevant database in yum
Libcurl-devel libcurl
Zlib-devel zlib
Libxslt-devel libxslt
Libzip-devel libzip
Libxml2-devel (libxml2)
Libjpeg-devel libjpeg
Libpng-devel libpng
FreeType-devel FreeType
Bzip2-devel (Bzip2)
Libzip-devel libzip
Libxpm-devel libxpm
Redhat6.2 does not have mcrypt PHP Extension
Wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz? TS = 1, 1348197028
Wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz? TS = 1, 1348196976
Download mhash
Wget http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2? TS = 1348198184 & use_mirror = cdnetworks-kr-1
Libmcrypt
./Configure
Make & make install
/Sbin/ldconfig
Ltdl is required to use libmcrypt. If you do not compile PHP, an error is returned.
Installation path/usr/local/lib/
Http://yangsiwei.com/usr-bin-ld-cannot-find-lltdl-%E9%94%99%E8%AF%AF%E7%9A%84%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95
CD libltdl/
./Configure -- enable-ltdl-install
Make
Make install
CD ../../
Compile ImageMagick
Wget ftp://mirror.aarnet.edu.au/pub/imagemagick/ImageMagick-6.7.9-6.tar.xz
Tar xvf ImageMagick-6.7.9-6.tar.xz-C/tmp
D/tmp/ImageMagick-6.7.9-6
./Configure
Make & make install
To share the dynamic connection library with the System
To run the/sbin/ldconfig command, you can add a custome. conf file to/etc/lD. So. conf. d/and add your own library address.
CD mhash-0.9.9.9
./Configure
Make & make install
Solve the problem of finding the file path during mcrypt compilation.
Ln-S/usr/local/lib/libmcrypt. La/usr/lib/libmcrypt. La
Ln-S/usr/local/lib/libmcrypt. So/usr/lib/libmcrypt. So
Ln-S/usr/local/lib/libmcrypt. so.4/usr/lib/libmcrypt. so.4
Ln-S/usr/local/lib/libmcrypt. so.4.4.8/usr/lib/libmcrypt. so.4.4.8
Ln-S/usr/local/lib/libmhash. A/usr/lib/libmhash.
Ln-S/usr/local/lib/libmhash. La/usr/lib/libmhash. La
Ln-S/usr/local/lib/libmhash. So/usr/lib/libmhash. So
Ln-S/usr/local/lib/libmhash. so.2/usr/lib/libmhash. so.2
Ln-S/usr/local/lib/libmhash. so.2.0.1/usr/lib/libmhash. so.2.0.1
Ln-S/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
Mcrypt
./Configure -- With-libmcrypt-Prefix =/usr/local
Make & make install
**************************************** ***
Install MySQL Binary Package
**************************************** ***
Wget http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.27-linux2.6-x86_64.tar.gz/from/http://cdn.mysql.com/
/Usr/sbin/groupadd MySQL
/Usr/sbin/useradd-G MySQL
We do not fully understand mysql. Instead, we should use a compiled MySQL schema and put it in a directory we specified.
Modified the/APP directory to the/data directory.
Tar xzvf mysql-5.5.27-linux2.6-x86_64.tar.gz
Music mysql-5.5.27-linux2.6-x86_64/data/opt/MySQL
Create a data directory to separate data, BINLOG, and relaylog data in an independent directory.
Mkdir/data/databases
Mkdir/data/databases/BINLOG
CD/data/opt/MySQL
./Scripts/mysql_install_db -- basedir =/data/opt/MySQL -- datadir =/data/databases -- user = MySQL
Modify the configuration file/etc/My. CNF
[Client]
Character-set-Server = utf8
Port = 3306
Socket =/tmp/MySQL. Sock
[Mysqld]
Character-set-Server = utf8
User = MySQL
Port = 3306
Socket =/tmp/MySQL. Sock
Basedir =/data/opt/MySQL
Datadir =/data/databases
Log-error =/data/databases/mysql_error.log
PID-file =/data/databases/MySQL. PID
Open_files_limit = 1024
Back_log = 600
Max_connections = 200
Max_connect_errorrs = 200
Table_cache = 614
External-locking = false
Max_allowed_packet = 32 m
Sort_buffer_size = 1 m
Join_buffer_size = 1 m
Thread _ cache_size = 300
# Thread_concurrency = 8
# Query_cache_size = 512 m
# Query_cache_limit = 2 m
# Query_cache_min_res_unit = 2 K
# Default-storage-engine = MyISAM
# Thread_stack = 192 K
# Transaction_isolation = read-committed
# Tmp_table_size = 246 m
# Max_heap_table_size = 246 m
# Long_query_time = 3
# Log-slave-Updates
# Log-bin =/data0/MySQL/3306/BINLOG
# Binlog_cache_size = 4 m
# Binlog_format = mixed
# Max_binlog_cache_size = 8 m
# Max_binlog_size = 1g
# Relay-log-Index =/data0/MySQL/3306/relaylog
# Relay-log-Info-file =/data0/MySQL/3306/relaylog
# Relay-log =/data0/MySQL/3306/relaylog
# Expire_logs_days = 30
# Key_buffer_size = 256 m
# Read_buffer_size = 1 m
# Read_rnd_buffer_size = 16 m
# Bulk_insert_buffer_size = 64 m
# Myisam_sort_buffer_size = 128 m
# Myisam_max_sort_file_size = 10g
# Myisam_repair_threads = 1
# Myisam_recover
#
# Interactive_timeout = 120
# Wait_timeout = 120
#
# Skip-name-resolve
# Master-connect-retry = 10
# Slave-Skip-errors = 1396
#
# Master-host = 192.168.1.2
# Master-user = Username
# Master-Password = Password
# Master-ports = 3306
#
# Server-id = 1
#
# Innodb_additional_mem_pool_size = 16 m
# Innodb_buffer_pool_size = 512 m
# Innodb_data_file_path = ibdata1: 256 M: autoextend
# Innodb_file_io_threads = 4
# Innodb_thread_concurrency = 8
# Innodb_flush_log_at_trx_commit = 2
# Innodb_log_buffer_size = 16 m
# Innodb_log_file_size = 128 m
# Innodb_log_files_in_group = 3
# Innodb_max_dirty_pages_pct = 90
# Innodb_lock_wait_timeout = 120
# Innodb_file_per_table = 0
#
# Log-Slow-queries =/data0/MySQL/3306/slow. Log
# Long_query_time = 10
#
# [Mysqldump]
# Quick
# Max_allowed_packet = 32 m
MySQL connection through bin/MySQL reports an error
Bin/MySQL: Unknown variable 'character-set-Server = utf8'
We can see that some people use character_set_server = utf8 to replace default-character-set = utf8 in the online articles, which solves similar error reporting problems.
I reversed the result and solved my problem.
Grant all privileges on *. * To 'root' @ 'localhost' with grant option identified by 'mainone % 8080 ';
Grant all privileges on *. * To 'root' @ '1970. 0.0.1 'with grant option identified by 'mainone % 8080 ';
**************************************** ***
Compile and install php5.3.17
**************************************** ***
Wget http://php.net/get/php-5.3.17.tar.bz2/from/cn2.php.net/mirror
Inline compilation Optimization
Http://stackoverflow.com/questions/6791564/what-does-enable-inline-optimization-do-when-compiling-php
Precise mathematical computation
-- Enable-bcmath
PHP. ini configuration file address
With-config-file-Path
Disable passing additional Runtime Library
-- Disable-rpath
Memory sharing operation functions
-- Enable-shmop
Enable System V semaphore support compile PHP with the option
-- Enable-sysvsem
Use curl as the URL Stream Function
-- With-curlwrappers
Use wide Character Set regular match
-- Enable-mbregex
Fork sub-process function
-- Enable-pcntl
Http://blog.csdn.net/lgg201/article/details/5996444
Generating phar. phar
Chmod: unable to access "ext/phar. phar": No file or directory
Make: [EXT/phar. phar] Error 1 (ignore)
Solve the problem that the dynamic link libmysqlclient. so.18 cannot be found. The two methods are best to be soft connection.
1. Export LD_LIBRARY_PATH = "/data/opt/MySQL/lib: $ LD_LIBRARY_PATH"
2. ln-S/data/opt/MySQL/lib/libmysqlclient_r.so.18/usr/lib
. /Configure -- prefix =/data/opt/PHP -- With-config-file-Path =/data/opt/PHP -- enable-mysqlnd -- With-mysql =/data/opt/ mySQL -- With-mysqli =/data/opt/MySQL/bin/mysql_config -- With-libxml-Dir =/usr/include/libxml2 -- With-Gd =/usr/include -- -JPEG-dir -- With-PNG-Dir
-- With-bz2 -- With-FreeType-dir -- With-iconv-dir -- With-zlib -- With-mcrypt =/usr/local/lib/libmcrypt -- With-mhash -- With-curl = /usr/include/curl -- enable-Gd-native-TTF -- enable-sockets -- enable-mbstring -- With-libxml-Dir =/usr/include -- enable-XML -- disable- rpath
-- Enable-FPM -- With-curlwrappers -- enable-pcntl -- enable-soap -- With-XMLRPC -- enable-zip
Configure PHP-FPM
Http://ideas.spkcn.com/technology/php-technology/133.html
CP php5.3.17/SAPI/FPM/init. d. php-FPM/etc/init. d/PHP-FPM
CD/data/opt/PHP/etc
CP php-fpm.conf.default php-fpm.conf
Modify configuration php-fpm.conf
PID = run/php-fpm.pid
User = www-Data
Group = www-Data
PM. start_servers = 20
PM. max_children = 64
PM. start_servers = 12
PM. min_spare_servers = 3
PM. max_spare_servers = 20
Rlimit_files = 65535
Catch_workers_output = Yes
Configuration complete
Shell sets the number of opened files
Ulimit-shn 65535
Chkconfig -- add PHP-FPM
Chkconfig PHP-FPM on
Modify PHP. ini after installation
Date. timezone = "Asia/Shanghai"
Expose_php = off // disable displaying PHP information in the HTTP Header
Short_open_tag = on // enable short tag
Download PHP optimized Extension
Wget http://pecl.php.net/get/APC-3.1.9.tgz
CD APC-3.1.9
/Data/opt/PHP/bin/phpize
./Configure -- With-PHP-Config =/data/opt/PHP/bin/PHP-config
Make & make install
PHP extension path/data/opt/PHP/lib/PHP/extensions/no-debug-non-zts-20090626/
Compile ImageMagick Extension
Wget http://pecl.php.net/get/imagick-2.3.0.tgz
Tar xzvf imagick-2.3.0.tgz
CD imagick-2.3.0
The compilation and installation are the same as the above APC
Set the extension directory of PHP. ini
Extension_dir = "/data/opt/PHP/lib/PHP/extensions/no-debug-non-zts-20090626"
Configure APC and imgick
Extension = APC. So
Extension = imagick. So
Install MongoDB Extension
Wget http://pecl.php.net/get/mongo-1.2.12.tgz
Tar xvf mongo-1.2.12.tgz
Cd %
Phpize
./Configure
Make & make install
Extension = Mongo. So
Compile and install memcached
Http://www.yongblog.com/archives/386.html
Wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
Tar xvf memcached-1.4.15.tar.gz
Cd %
./Configure -- prefix =/usr/local/memcached
Make & make install
Temporary Start Plan
/Usr/local/memcached/bin/memcached-u Root
Compile and install libevent
Because the libevent in rhel6.2 is still 1.4, there is a problem when compiling libmemcached1.0series, so install a new version of Library
Wget https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
./Configure -- prefix =/usr/local/libevent
Compile and install libmemcached
Wget https://launchpad.net/libmemcached/1.0/1.0.10/+download/libmemcached-1.0.10.tar.gz
Tar xvf libmemcached-1.0.10.tar.gz
./Configure -- prefix =/usr/local/libmemcached-with-memcached
Make & make install
An error occurred while compiling the file under example when compiling libmemcached1.0.10.
Example/memcached_light.cc: 596: Undefined reference to 'event _ init', etc.
No proper solution was found, so it was replaced with version 1.0.4.
Wget https://launchpad.net/libmemcached/1.0/1.0.10/+download/libmemcached-1.0.4.tar.gz
Similar to other processes
Compile and install php_memcached
The version of the memcached-2.1.0 requires the version of the libmemcached-1.0.11
Wget http://pecl.php.net/get/memcached-2.0.1.tgz
Tar xvf memcached-2.0.1.tgz
./Configure -- With-libmemcached-Dir =/usr/local/libmemcached
Make & make install
Compilation is normal
Add extension = memcached. So to the php. ini file.
Compile and install php_memcache, which is different from the memcached extension.
This extension can be used in windows, but the function is not as good as above. If the configuration is the same, it will not be written.
**************************************** ***
Install and configure nginx
**************************************** ***
Yum installation, not compiled this time
-- The with-http_stub_status_module is used to enable nginx's nginxstatus function to monitor the current state of nginx. After the installation is successful, the/opt/nginx directory contains four subdirectories: Conf, HTML, logs, and sbin.
-- Http-client-body-temp-Path = path set path to store HTTP client request body temporary files specifies the path of the cache file storage directory of the HTTP client request
-- Http-FastCGI-temp-path set path to store HTTP FastCGI temporary files specify the path of the directory where the HTTP FastCGI cached files are stored
-- Http-proxy-temp-path set path to store HTTP Proxy temporary files specifies the directory where the HTTP reverse proxy cached files are stored
-- Http-uwsgi-temp-path set path to store HTTP uwsgi temporary files specifies the path of the directory where the HTTP uwsgi cached files are stored
-- Http-scgi-temp-path set path to store HTTP scgi temporary files specifies the path of the directory where the HTTP Sigi cached files are stored
-With-http_ssl_module enable ngx_http_ssl_module
-- With-http_realip_module enable ngx_http_realip_module when used as a proxy server, set the real IP value obtained by the backend through X-real-IP or X-forwarded-for header value
-- With-http_addition_module enable ngx_http_addition_module adds a text filter before or after the response
-- With-http_sub_module enable ngx_http_sub_module this module can search and replace text in the nginx response.
-- With-http_dav_module enable ngx_http_dav_module this module adds the HTTP and WebDAV methods put, delete, mkcol, copy and mov
-- With-http_flv_module enable ngx_http_flv_module this module provides the ability to seek within FLV (flash) files using byte-based offsets.
-- With-http_mp4_module enable ngx_http_mp4_module this module enables MP4 streaming with seeking ability
-- With-http_gzip_static_module enable ngx_http_gzip_static_module before serving a file from disk to a gzip-enabled client, this module will look for a Precompressed file in the same location that ends in ". GZ
-- With-http_random_index_module enable ngx_http_random_index_module pick a random file from a directory and use it as the index file.
-- With-http_secure_link_module enable ngx_http_secure_link_module this Module checks request URLs for a required security token
-- With-http_stub_status_module enable ngx_http_stub_status_module this module provides the ability to get some status from nginx.
-- With-Mail Enable POP3/IMAP4/SMTP proxy module mail proxy configuration
-- With-file-AIO enable file AIO support Kernel Asynchronous I/O (AIO) Support
Modify nginx. conf
User www-data www-Data
**************************************** ***
MongoDB Installation
**************************************** ***
Http://docs.mongodb.org/manual/tutorial/install-mongodb-on-redhat-centos-or-fedora-linux/
Modify dbpath =/data/Mongo