Dependent Package Installation:
Yum-y install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel OpenSSL openssl-devel pcre-devel gd kernel K Eyutils Patch perl kernel-headers compat* MPFR cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel LIBCO M_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libxpm* freetype libjpeg* libpng* php-common php-gd ncu rses* libtool* libxml2 libxml2-devel patch freetype-devel cmake zlib ncurses* openssl* cmake gcc* autoconf Bison libeven t*
#上传文件至/opt/soft/
Install Nginx:
Install Pcre, support regular:
TAR-ZXVF pcre-8.12.tar.gz
CD pcre-8.12
./configure && make && make install
To add users and user groups:
Groupadd www
Useradd-s/sbin/nologin-m-G www www
Install Nginx:
TAR-ZXVF nginx-1.2.0.tar.gz
CD nginx-1.2.0
./configure--user=www--group=www--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module- -with-http_gzip_static_module--with-ipv6--with-pcre=/opt/soft/pcre-8.12
#注意:
--with-pcre=/opt/soft/pcre-8.12 is the decompression path for Pcre, not the installation path
Make && make install
Replace the nginx.conf and fcgi.conf under/usr/local/nginx/conf/
Configure Nginx
Mkdir/opt/web
Install PHP:
To install the PHP extension module software:
Tar zxvf libiconv-1.14.tar.gz
CD libiconv-1.14/
./configure && make && make install
Tar zxvf libmcrypt-2.5.8.tar.gz
CD libmcrypt-2.5.8
./configure && make && make install
Ldconfig
CD libltdl/
./configure--enable-ltdl-install
Make && make install
Tar zxvf mhash-0.9.9.9.tar.gz
CD mhash-0.9.9.9
./configure && make && make install
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.A
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
Tar zxvf mcrypt-2.6.8.tar.gz
CD mcrypt-2.6.8
Ldconfig
./configure && make && make install
Install php5.6:
Mkdir-p/usr/local/php/etc
TAR-ZXVF php-5.6.11.tar.gz
CD php-5.6.11
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--enable-fpm--with-fpm-user=www-- With-fpm-group=www--with-mysql=mysqlnd--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--with-iconv-dir-- With-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml--disable-rpath-- Enable-magic-quotes--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization --with-curl--with-curlwrappers--enable-mbregex--enable-mbstring--with-mcrypt--enable-ftp--WITH-GD-- Enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip-- Enable-soap--without-pear--with-gettext--disable-fileinfo--with-libdir=lib64--enable-opcache--with-apxs2=/usr/ Local/apache2/bin/apxs (install HTTP is required)
echo "/usr/local/lib" >>/etc/ld.so.conf
Ldconfig
Make zend_extra_libs= '-liconv '
Make install
CP Php.ini-production/usr/local/php/etc/php.ini
Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
Vi/usr/local/php/etc/php-fpm.conf
modifying PID and User,group
Turn on Opcache cache acceleration:
PHP Optimizations:
PHP.ini Join
Zend_extension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/opcache.so
Opcache.fast_shutdown=1
Opcache.enable_cli=1
opcache.memory_consumption=128
Opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
Opcache.revalidate_freq=60
Opcache.fast_shutdown=1
Opcache.enable_cli= on
Opcache.enable= on
Attention:
If it appears: Configure:error:Don ' t know how to define struct flock on the This system, set--enable-opcache=no
Plus--with-libdir=lib64.
echo "/usr/local/lib" >>/etc/ld.so.conf
Make zend_extra_libs= '-liconv '
Error 1:
Error while loading shared Libraries:libiconv.so.2:cannot open Shared object file:no such file or directory
But you can find libiconv.so.2 under/usr/local/lib, the workaround is to add the/usr/local/lib path to the/etc/ld.so.conf file
Make install
Other reference LNMP source page document installation!
PHP Optimizations:
PHP.ini Join
Zend_extension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/opcache.so
Opcache.fast_shutdown=1
Opcache.enable_cli=1
opcache.memory_consumption=128
Opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
Opcache.revalidate_freq=60
Opcache.fast_shutdown=1
Opcache.enable_cli= on
Opcache.enable= on
You need to modify before make:
ext/iconv/.libs/iconv.o:in function ' Php_iconv_stream_filter_ctor ':
/root/php-5.2.12/ext/iconv/iconv.c:2491:undefined reference to ' Libiconv_open '
ext/xmlrpc/libxmlrpc/.libs/encodings.o:in function ' Convert ':
/root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:73:undefined reference to ' Libiconv_open '
/root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:81:undefined reference to ' Libiconv '
/root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:101:undefined reference to ' Libiconv_close '
Collect2:ld returned 1 exit status
Make: * * * [sapi/cli/php]?.. 1
Processing method:
./configure .......
VI Makefile
Find the following line:
Extra_libs =-lcrypt ... After the last add-liconv save make pass; make install passes.
2. If the extension is added in Phpini but not loaded, and there is a Loaded Configuration File (None) appears in Phpinfo
Treatment methods:
PHP.ini can be specified manually:
/usr/local/php/sbin/php-fpm-y/usr/local/php/etc/php-fpm.conf-c/usr/local/php/etc/php.ini
3. There is no libmcrypt to add directly
--with-libdir=lib64
4. There is no Iconv found
--with-iconv=/usr/local/lib changed into--with-iconv
Start:
/usr/local/php/sbin/php-fpm
PHP-FPM off:
Kill-int ' Cat/usr/local/php/var/run/php-fpm.pid '
PHP-FPM Restart:
KILL-USR2 ' Cat/usr/local/php/var/run/php-fpm.pid '
To view the number of PHP-FPM processes:
PS aux | Grep-c PHP-FPM
Install the source package:
The following error occurred while installing Lnmp,config PHP on the CentOS 6.5 64-bit version and exited
Configure:error:Cannot Find LDAP Libraries In/usr/lib
Workaround:
cp-frp/usr/lib64/libldap*/usr/lib/
Install MySQL:
Groupadd MySQL
Useradd-s/sbin/nologin-m-G MySQL MySQL
TAR-ZXVF mysql-5.6.25.tar.gz
CD mysql-5.6.25
Cmake-dcmake_install_prefix=/usr/local/mysql-dextra_charsets=all-ddefault_charset=utf8-ddefault_collation=utf8 _general_ci-dwith_readline=1-dwith_ssl=system-dwith_zlib=system-dwith_embedded_server=1-denabled_local_infile= 1
CP SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF
Vi/etc/my.cnf
Join the optimized MySQL configuration:
# # #查看mysql InnoDB 5.5 version show engine InnoDB status\g;
# # #注意: InnoDB Be sure to include the configuration file before initializing
# # #5 6 version needs to be removed #log_slow_queries=/usr/local/mysql/slow-log.log
# # #需要chmod 777/tmp
[Client]
#password = Your_password
Port = 3306
Socket =/tmp/mysql.sock
# here follows entries for some specific programs
# The MySQL server
[Mysqld]
Port = 3306
Socket =/tmp/mysql.sock
Skip-external-locking
Max_allowed_packet = 32M
Table_open_cache = 2048
Net_buffer_length = 1M
Character-set-server = UTF8
Skip-name-resolve
Ft_min_word_len = 4
# # # # performance # #
Open_files_limit = 10240
Max_connections = 800
Max_connect_errors = 6000
Thread_stack = 192K
Transaction_isolation = Repeatable-read
Tmp_table_size = 256M
Max_heap_table_size = 256M
Slow_query_log
Long_query_time = 1
#log_slow_queries =/usr/local/mysql/slow-log.log
Net_buffer_length = 1M
# # # log # # #
Log-error=/usr/local/mysql/mysqld.err
Back_log = 500
Max_binlog_cache_size = 8M
Max_binlog_size = 512M
Binlog_format=mixed
Expire_logs_days = 7
# # # buffer && Cache # # #
Read_buffer_size = 10M
Read_rnd_buffer_size = 32M
Sort_buffer_size = 2M
Join_buffer_size = 2M
Thread_cache_size = 300
Thread_concurrency = 8
Query_cache_size = 64M
Query_cache_limit = 4M
Binlog_cache_size = 4M
Key_buffer_size = 32M
Bulk_insert_buffer_size = 64M
# # # # MyISAM # #
Myisam_sort_buffer_size = 128M
Myisam_max_sort_file_size = 10G
Myisam_repair_threads = 1
Myisam_recover
Log-bin=mysql-bin
Server-id = 1
Innodb_data_home_dir =/usr/local/mysql/data
Innodb_data_file_path = Ibdata1:10m:autoextend
Innodb_log_group_home_dir =/usr/local/mysql/data
Innodb_buffer_pool_size = 1G
Innodb_additional_mem_pool_size = 16M
Innodb_log_file_size = 150M
Innodb_log_buffer_size = 16M
Innodb_flush_log_at_trx_commit =2
Innodb_lock_wait_timeout = 60
Innodb_flush_method = O_direct
Innodb_open_files = 800
Innodb_file_per_table=1
Innodb_file_io_threads=4
[Mysqldump]
Quick
Max_allowed_packet = 32M
[MySQL]
No-auto-rehash
# Remove The next comment character if you is not a familiar with SQL
#safe-updates
[Myisamchk]
Key_buffer_size = 32M
Sort_buffer_size = 32M
Read_buffer = 8M
Write_buffer = 8M
[Mysqlhotcopy]
Interactive-timeout
[Mysqld_safe]
Open-files-limit = 8196
cd/usr/local/mysql/
Chown-r MySQL.
Chgrp-r MySQL.
Initialize MySQL:
/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql --defaults-file=/etc/my.cnf
Start MySQL:
/usr/local/mysql/bin/mysqld_safe--defaults-file=/etc/my.cnf--user=mysql&
Login:
/usr/local/mysql/bin/mysql-u root-p
/usr/local/mysql/bin/mysqladmin-u root-p shutdown
/usr/local/mysql/bin/mysqladmin--socket=/tmp/mysql1.sock-u root password xxx change password
Authorizing remote connections:
Grant all privileges on * * to [E- Mail protected]"%" identified by ' xxx ' with GRANT option;
Flush privileges;
Memcache Installation:
Useradd memcache
Client:
Tar zxvf memcache-3.0.6.tgz
CD memcache-3.0.6/
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
Make && make install
Sed-i ' S#extension_dir = './' #extension_dir = '/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/' \ Nextension = "memcache.so" \n# '/usr/local/php/etc/php.ini
Service side:
Tar zxvf memcached-1.4.15.tar.gz
CD memcached-1.4.15/
./configure--prefix=/usr/local/memcached
Make &&make Install
Start:
/usr/local/memcached/bin/memcached-umemcache&
Note: Add completion cannot be found in Phpinfo memcache because the profile is pointing to/usr/local/php/lib so you need:
Cp-p/usr/local/php/etc/php.ini/usr/local/php/lib
Restart PHP OK
If an nginx error occurs:
Emerg]: Could not build the Proxy_headers_hash, you should increase either proxy_headers_hash_max_size:512 or Proxy_heade Rs_hash_bucket_size:64
Workaround
Add the following two lines of code to the configuration:
Proxy_headers_hash_bucket_size 1024;
Proxy_headers_hash_max_size 512;
PS: Due to the 51cto limit upload attachments, so the attachment to build corresponding version download, pro-Test available, has been put into the formal environment use
This article is from the "Nginx Installation Optimization" blog, please be sure to keep this source http://mrdeng.blog.51cto.com/3736360/1735313
Linux source Installation Lnmp+memcache (problem correction collation)