{"id":6001,"date":"2016-07-12T22:05:09","date_gmt":"2016-07-12T14:05:09","guid":{"rendered":"http:\/\/rmohan.com\/?p=6001"},"modified":"2016-07-12T22:05:09","modified_gmt":"2016-07-12T14:05:09","slug":"centos-6-8-to-compile-and-install-lnmp","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6001","title":{"rendered":"CentOS 6.8 to compile and install LNMP"},"content":{"rendered":"<p>CentOS 6.8?nginx 1.9.14?mysql 5.6.23?php 5.6.17<\/p>\n<p>service iptables stop<br \/>\nchkconfig iptables off<br \/>\nsetenforce 0 <\/p>\n<p>vi \/etc\/sysconfig\/selinux<br \/>\nSELINUX=disabled <\/p>\n<p>yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers make  libtool* git tree bison pcre-devel perl gd gd-devel<\/p>\n<p>mkdir software<br \/>\ncd software <\/p>\n<p>wget http:\/\/ftp.gnu.org\/pub\/gnu\/libiconv\/libiconv-1.14.tar.gz<\/p>\n<p>tar xf libiconv-1.14.tar.gz<br \/>\ncd libiconv-1.14\/<br \/>\n.\/configure &#8211;prefix=\/usr\/local<br \/>\nmake &#038;&#038; make install<\/p>\n<p>wget http:\/\/heanet.dl.sourceforge.net\/project\/mhash\/mhash\/0.9.9.9\/mhash-0.9.9.9.tar.gz<br \/>\n  tar -zxvf mhash-0.9.9.9.tar.gz<br \/>\n  cd mhash-0.9.9.9<br \/>\n  .\/configure<br \/>\n  make &#038;&#038; make install<\/p>\n<p>wget http:\/\/downloads.sourceforge.net\/project\/mcrypt\/Libmcrypt\/2.5.8\/libmcrypt-2.5.8.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fmcrypt%2Ffiles%2FLibmcrypt%2F2.5.8%2F&#038;ts=1468310750&#038;use_mirror=freefr<\/p>\n<p>tar xf libmcrypt-2.5.8.tar.gz<br \/>\ncd libmcrypt-2.5.8<br \/>\n.\/configure<br \/>\nmake &#038;&#038; make install<br \/>\ncd libltdl\/<br \/>\n.\/configure &#8211;enable-ltdl-install<br \/>\nmake &#038;&#038; make install<\/p>\n<p>wget http:\/\/pkgs.fedoraproject.org\/repo\/pkgs\/mcrypt\/mcrypt-2.6.8.tar.gz\/md5\/97639f8821b10f80943fa17da302607e\/mcrypt-2.6.8.tar.gz<br \/>\ntar zxvf mcrypt-2.6.8.tar.gz<br \/>\ncd mcrypt-2.6.8\/<br \/>\nexport LD_LIBRARY_PATH=\/usr\/local\/lib:$LD_LIBRARY_PATH<br \/>\n.\/configure<br \/>\nmake &#038;&#038; make install<\/p>\n<p>ln -s \/usr\/local\/lib\/libmcrypt.la \/usr\/lib\/libmcrypt.la<br \/>\nln -s \/usr\/local\/lib\/libmcrypt.so \/usr\/lib\/libmcrypt.so<br \/>\nln -s \/usr\/local\/lib\/libmcrypt.so.4 \/usr\/lib\/libmcrypt.so.4<br \/>\nln -s \/usr\/local\/lib\/libmcrypt.so.4.4.8 \/usr\/lib\/libmcrypt.so.4.4.8<br \/>\nln -s \/usr\/local\/lib\/libmhash.a \/usr\/lib\/libmhash.a<br \/>\nln -s \/usr\/local\/lib\/libmhash.la \/usr\/lib\/libmhash.la<br \/>\nln -s \/usr\/local\/lib\/libmhash.so \/usr\/lib\/libmhash.so<br \/>\nln -s \/usr\/local\/lib\/libmhash.so.2 \/usr\/lib\/libmhash.so.2<br \/>\nln -s \/usr\/local\/lib\/libmhash.so.2.0.1 \/usr\/lib\/libmhash.so.2.0.1<br \/>\nln -s \/usr\/local\/bin\/libmcrypt-config \/usr\/bin\/libmcrypt-config<\/p>\n<p>wget https:\/\/cmake.org\/files\/v3.6\/cmake-3.6.0.tar.gz<br \/>\ntar xf cmake-3.6.0.tar.gz<br \/>\ncd cmake-3.6.0<br \/>\n.\/bootstrap<br \/>\nmake &#038;&#038; make install<\/p>\n<p>wget http:\/\/pkgs.fedoraproject.org\/repo\/pkgs\/community-mysql\/mysql-5.6.30.tar.gz\/md5\/ac8ba1db4454d2c144c7d892185a9328\/mysql-5.6.30.tar.gz<\/p>\n<p>tar -xf mysql-5.6.30.tar.gz<br \/>\ngroupadd -r mysql<br \/>\nuseradd -r -g mysql mysql<\/p>\n<p>mkdir -p \/usr\/local\/mysql<br \/>\nmkdir -p \/data\/mysqldb<\/p>\n<p>cd mysql-5.6.30<br \/>\ncmake -DCMAKE_INSTALL_PREFIX=\/usr\/local\/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1-DMYSQL_DATADIR=\/data\/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1-DSYSCONFDIR=\/etc -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0<br \/>\nmake&#038;&#038; make install<\/p>\n<p>cd \/usr\/local\/mysql<br \/>\nchown -R mysql:mysql .<br \/>\ncd \/data\/mysqldb<br \/>\nchown -R mysql:mysql .<\/p>\n<p>vi \/etc\/my.cnf<br \/>\n[mysqld]<br \/>\ndatadir=\/var\/lib\/mysql<br \/>\nsocket=\/var\/lib\/mysql\/mysql.sock<br \/>\nuser=mysql<br \/>\n# Disabling symbolic-links is recommended to prevent assorted security risks<br \/>\nsymbolic-links=0<\/p>\n<p>[mysqld_safe]<br \/>\nlog-error=\/var\/log\/mysqld.log<br \/>\npid-file=\/var\/run\/mysqld\/mysqld.pid<\/p>\n<p># CLIENT #<br \/>\nport                          =3306<br \/>\nsocket                        =\/data\/mysqldb\/mysql.sock <\/p>\n<p>[mysqld] <\/p>\n<p># GENERAL #<br \/>\nuser                          =mysql<br \/>\ndefault-storage-engine        =InnoDB<br \/>\nsocket                        =\/data\/mysqldb\/mysql.sock<br \/>\npid-file                      =\/data\/mysqldb\/mysql.pid <\/p>\n<p># MyISAM #<br \/>\nkey-buffer-size               =32M<br \/>\nmyisam-recover                =FORCE,BACKUP <\/p>\n<p># SAFETY #<br \/>\nmax-allowed-packet            =16M<br \/>\nmax-connect-errors            =1000000 <\/p>\n<p># DATA STORAGE #<br \/>\ndatadir                        =\/data\/mysqldb\/<\/p>\n<p># BINARY LOGGING #<br \/>\nlog-bin                        =\/data\/mysqldb\/mysql-bin<br \/>\nexpire-logs-days              =14<br \/>\nsync-binlog                    =1 <\/p>\n<p># REPLICATION #<br \/>\nskip-slave-start              =1<br \/>\nrelay-log                      =\/data\/mysqldb\/relay-bin<br \/>\nslave-net-timeout              =60 <\/p>\n<p># CACHES AND LIMITS #<br \/>\ntmp-table-size                =32M<br \/>\nmax-heap-table-size            =32M<br \/>\nquery-cache-type              =0<br \/>\nquery-cache-size              =0<br \/>\nmax-connections                =500<br \/>\nthread-cache-size              =50<br \/>\nopen-files-limit              =65535<br \/>\ntable-definition-cache        =4096<br \/>\ntable-open-cache              =4096 <\/p>\n<p># INNODB #<br \/>\ninnodb-flush-method            =O_DIRECT<br \/>\ninnodb-log-files-in-group      =2<br \/>\ninnodb-log-file-size          =64M<br \/>\ninnodb-flush-log-at-trx-commit =1<br \/>\ninnodb-file-per-table          =1<br \/>\ninnodb-buffer-pool-size        =592M <\/p>\n<p># LOGGING #<br \/>\nlog-error                      =\/data\/mysqldb\/mysql-error.log<br \/>\nlog-queries-not-using-indexes  =1<br \/>\nslow-query-log                =1<br \/>\nslow-query-log-file            =\/data\/mysqldb\/mysql-slow.log<\/p>\n<p>cp support-files\/mysql.server \/etc\/init.d\/mysqld<br \/>\nservice mysqld start<br \/>\nchkconfig  mysqld on<\/p>\n<p>drop user &#8221;@localhost;<br \/>\ndrop user &#8221;@hostname;<br \/>\nupdate mysql.user set password=password(&#8216;*******&#8217;);<br \/>\nflush privileges;<\/p>\n<p>wget  http:\/\/nginx.org\/download\/nginx-1.9.14.tar.gz <\/p>\n<p>groupadd -r nginx<br \/>\nuseradd -g nginx -r nginx<\/p>\n<p>mkdir -pv \/var\/tmp\/nginx\/client<\/p>\n<p>nginx<br \/>\ntar xf nginx-1.9.14.tar.gz<br \/>\ncd nginx-1.9.14<br \/>\n.\/configure &#8211;prefix=\/usr\/local\/nginx &#8211;sbin-path=\/usr\/local\/nginx\/sbin\/nginx &#8211;conf-path=\/etc\/nginx\/nginx.conf &#8211;error-log-path=\/var\/log\/nginx\/error.log &#8211;http-log-path=\/var\/log\/nginx\/access.log &#8211;pid-path=\/var\/run\/nginx\/nginx.pid &#8211;lock-path=\/var\/lock\/nginx.lock &#8211;user=nginx &#8211;group=nginx &#8211;with-http_ssl_module &#8211;with-http_flv_module &#8211;with-http_stub_status_module &#8211;with-http_gzip_static_module &#8211;http-client-body-temp-path=\/var\/tmp\/nginx\/client\/ &#8211;http-proxy-temp-path=\/var\/tmp\/nginx\/proxy\/ &#8211;http-fastcgi-temp-path=\/var\/tmp\/nginx\/fcgi\/ &#8211;http-uwsgi-temp-path=\/var\/tmp\/nginx\/uwsgi &#8211;http-scgi-temp-path=\/var\/tmp\/nginx\/scgi &#8211;with-pcre<br \/>\nmake &#038;&#038; make install<\/p>\n<p>vim \/etc\/rc.d\/init.d\/nginx<\/p>\n<p>#!\/bin\/sh<br \/>\n#<br \/>\n# nginx &#8211; this script starts and stops the nginx daemon<br \/>\n#<br \/>\n# chkconfig:  &#8211; 85 15<br \/>\n# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \\<br \/>\n#              proxy and IMAP\/POP3 proxy server<br \/>\n# processname: nginx<br \/>\n# config:      \/etc\/nginx\/nginx.conf<br \/>\n# config:      \/etc\/sysconfig\/nginx<br \/>\n# pidfile:    \/var\/run\/nginx.pid    <\/p>\n<p># Source function library.<br \/>\n. \/etc\/rc.d\/init.d\/functions  <\/p>\n<p># Source networking configuration.<br \/>\n. \/etc\/sysconfig\/network  <\/p>\n<p># Check that networking is up.<br \/>\n[ &#8220;$NETWORKING&#8221; = &#8220;no&#8221; ] &#038;&#038; exit 0    <\/p>\n<p>nginx=&#8221;\/usr\/local\/nginx\/sbin\/nginx&#8221;<br \/>\nprog=$(basename $nginx)    <\/p>\n<p>NGINX_CONF_FILE=&#8221;\/etc\/nginx\/nginx.conf&#8221; <\/p>\n<p>[ -f \/etc\/sysconfig\/nginx ] &#038;&#038; . \/etc\/sysconfig\/nginx  <\/p>\n<p>lockfile=\/var\/lock\/subsys\/nginx  <\/p>\n<p>make_dirs() {<br \/>\n  # make required directories<br \/>\n  user=`nginx -V 2>&#038;1 | grep &#8220;configure arguments:&#8221; | sed &#8216;s\/[^*]*&#8211;user=\\([^ ]*\\).*\/\\1\/g&#8217; -`<br \/>\n  options=`$nginx -V 2>&#038;1 | grep &#8216;configure arguments:&#8217;`<br \/>\n  for opt in $options; do<br \/>\n      if [ `echo $opt | grep &#8216;.*-temp-path&#8217;` ]; then<br \/>\n          value=`echo $opt | cut -d &#8220;=&#8221; -f 2`<br \/>\n          if [ ! -d &#8220;$value&#8221; ]; then<br \/>\n              # echo &#8220;creating&#8221; $value<br \/>\n              mkdir -p $value &#038;&#038; chown -R $user $value<br \/>\n          fi<br \/>\n      fi<br \/>\n  done<br \/>\n}    <\/p>\n<p>start() {<br \/>\n    [ -x $nginx ] || exit 5<br \/>\n    [ -f $NGINX_CONF_FILE ] || exit 6<br \/>\n    make_dirs<br \/>\n    echo -n $&#8221;Starting $prog: &#8221;<br \/>\n    daemon $nginx -c $NGINX_CONF_FILE<br \/>\n    retval=$?<br \/>\n    echo<br \/>\n    [ $retval -eq 0 ] &#038;&#038; touch $lockfile<br \/>\n    return $retval<br \/>\n}    <\/p>\n<p>stop() {<br \/>\n    echo -n $&#8221;Stopping $prog: &#8221;<br \/>\n    killproc $prog -QUIT<br \/>\n    retval=$?<br \/>\n    echo<br \/>\n    [ $retval -eq 0 ] &#038;&#038; rm -f $lockfile<br \/>\n    return $retval<br \/>\n}    <\/p>\n<p>restart() {<br \/>\n    configtest || return $?<br \/>\n    stop<br \/>\n    sleep 1<br \/>\n    start<br \/>\n}    <\/p>\n<p>reload() {<br \/>\n    configtest || return $?<br \/>\n    echo -n $&#8221;Reloading $prog: &#8221;<br \/>\n    killproc $nginx -HUP<br \/>\n    RETVAL=$?<br \/>\n    echo<br \/>\n}    <\/p>\n<p>force_reload() {<br \/>\n    restart<br \/>\n}    <\/p>\n<p>configtest() {<br \/>\n  $nginx -t -c $NGINX_CONF_FILE<br \/>\n}    <\/p>\n<p>rh_status() {<br \/>\n    status $prog<br \/>\n}    <\/p>\n<p>rh_status_q() {<br \/>\n    rh_status >\/dev\/null 2>&#038;1<br \/>\n}    <\/p>\n<p>case &#8220;$1&#8243; in<br \/>\n    start)<br \/>\n        rh_status_q &#038;&#038; exit 0<br \/>\n        $1<br \/>\n        ;;<br \/>\n    stop)<br \/>\n        rh_status_q || exit 0<br \/>\n        $1<br \/>\n        ;;<br \/>\n    restart|configtest)<br \/>\n        $1<br \/>\n        ;;<br \/>\n    reload)<br \/>\n        rh_status_q || exit 7<br \/>\n        $1<br \/>\n        ;;<br \/>\n    force-reload)<br \/>\n        force_reload<br \/>\n        ;;<br \/>\n    status)<br \/>\n        rh_status<br \/>\n        ;;<br \/>\n    condrestart|try-restart)<br \/>\n        rh_status_q || exit 0<br \/>\n            ;;<br \/>\n    *)<br \/>\n        echo $&#8221;Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}&#8221;<br \/>\n        exit 2<br \/>\nesac<\/p>\n<p>chmod +x \/etc\/rc.d\/init.d\/nginx<br \/>\nchkconfig &#8211;add nginx<br \/>\nchkconfig nginx on<br \/>\nservice nginx start<\/p>\n<p>?PHP<br \/>\np<\/p>\n<p>cp -frp \/usr\/lib64\/libldap* \/usr\/lib\/<br \/>\necho \/usr\/local\/mysql\/lib >> \/etc\/ld.so.conf.d\/mysql-x86_64.conf<br \/>\nldconfig -v<\/p>\n<p>php<br \/>\ntar xf php-5.6.17.tar.gz<br \/>\ncd php-5.6.17<br \/>\n.\/configure &#8211;prefix=\/usr\/local\/php &#8211;with-mysql=\/usr\/local\/mysql &#8211;with-mysqli=\/usr\/local\/mysql\/bin\/mysql_config &#8211;with-iconv-dir=\/usr\/local &#8211;with-openssl &#8211;enable-mbstring &#8211;with-freetype-dir &#8211;with-jpeg-dir &#8211;with-png-dir &#8211;with-zlib &#8211;with-libxml-dir=\/usr &#8211;enable-xml &#8211;disable-rpath &#8211;enable-bcmath &#8211;enable-shmop &#8211;enable-sysvsem &#8211;enable-inline-optimization &#8211;enable-mbregex &#8211;enable-mbstring &#8211;with-gd &#8211;enable-gd-native-ttf &#8211;with-mhash &#8211;enable-pcntl &#8211;enable-sockets &#8211;with-mcrypt &#8211;with-ldap &#8211;with-ldap-sasl&#8211;with-xmlrpc &#8211;enable-zip &#8211;enable-soap &#8211;with-bz2 &#8211;with-config-file-path=\/etc &#8211;enable-fpm &#8211;with-config-file-scan-dir=\/etc\/php.d &#8211;enable-maintainer-zts<br \/>\nmake ZEND_EXTRA_LIBS=&#8217;-liconv&#8217;<br \/>\nmake install<\/p>\n<p>PHP<br \/>\ncp php.ini-production \/etc\/php.ini<\/p>\n<p>php-fpm<br \/>\ncp \/usr\/local\/php\/etc\/php-fpm.conf.default \/usr\/local\/php\/etc\/php-fpm.conf<\/p>\n<p>php-fpm<br \/>\ncp sapi\/fpm\/init.d.php-fpm  \/etc\/rc.d\/init.d\/php-fpm<br \/>\nchmod +x \/etc\/rc.d\/init.d\/php-fpm<br \/>\nchkconfig &#8211;add php-fpm<br \/>\nchkconfig php-fpm on<br \/>\nservice php-fpm start<\/p>\n<p>web<br \/>\nnginx,php<br \/>\nvim \/etc\/nginx\/nginx.conf<br \/>\n#location ~ \\.php$ {<br \/>\n#    root          html;<br \/>\n#    fastcgi_pass  127.0.0.1:9000;<br \/>\n#    fastcgi_index  index.php;<br \/>\n#    fastcgi_param  SCRIPT_FILENAME  \/scripts$fastcgi_script_name;<br \/>\n#    include        fastcgi_params;<br \/>\n#}<br \/>\n#???<br \/>\nlocation ~ \\.php$ {<br \/>\n    fastcgi_pass  127.0.0.1:9000;<br \/>\n    fastcgi_index  index.php;<br \/>\n    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;<br \/>\n    include        fastcgi_params;<br \/>\n}<\/p>\n<p>LNMP<\/p>\n<p>vim \/usr\/local\/nginx\/html\/test.php<br \/>\n<?php \n$link = mysql_connect('127.0.0.1','root','you_passwd'); \nif($link) \necho \"It's OK,Frank\"; \nelse\necho \"Failed,Frank\"; \nmysql_close; \nphpinfo(); \n?><\/p>\n<p>nginx<br \/>\nservice nginx reload<\/p>\n<p> http:\/\/ip\/test.php,LNMP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CentOS 6.8?nginx 1.9.14?mysql 5.6.23?php 5.6.17<\/p>\n<p>service iptables stop chkconfig iptables off setenforce 0 <\/p>\n<p>vi \/etc\/sysconfig\/selinux SELINUX=disabled <\/p>\n<p>yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel openldap-clients [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,73,70],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6001"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6001"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6001\/revisions"}],"predecessor-version":[{"id":6002,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6001\/revisions\/6002"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}