{"id":119,"date":"2016-04-26T22:48:42","date_gmt":"2016-04-26T14:48:42","guid":{"rendered":"http:\/\/pony.blog.myhz.com\/?p=119"},"modified":"2017-03-21T20:47:26","modified_gmt":"2017-03-21T12:47:26","slug":"centos6-4-64bitnginxmysqlphp%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/lnmp.ivan.xin\/?p=119","title":{"rendered":"centos6.4 64bit+nginx+mysql+php\u73af\u5883\u642d\u5efa"},"content":{"rendered":"<h2>\u89c4\u5212\uff1a<\/h2>\n<p>\u786c\u76d80 \uff1a20GB\uff0c\u786c\u76d81 \uff1a20GB\uff0c\u786c\u76d82\uff1a 5GB<br \/>\n\u7f51\u53610\uff1a host-only\uff0c\u7f51\u53611\uff1a bridge<br \/>\n\u58f0\u5361\uff0cUSB\u7b49\u5220\u9664<br \/>\nCPU 2*2<br \/>\n\u5185\u5b581.5GB\u6216\u80051GB<br \/>\n\u5e26\u5bbd\u65e0\u9650\u5236\u6216\u800510Mbps<br \/>\n\u8f6f\u4ef6\uff1acentos 6.4 64bit+nginx 1.6.0+mysql 5.6.13+php 5.4.20+zend 2.5.0+php-fpm<\/p>\n<h2>\u7cfb\u7edf\u5b89\u88c5\uff1a<\/h2>\n<p>\u5b89\u88c5\u7cfb\u7edf\u65f6\u533a\u9009\u6210\u4e0a\u6d77\uff0c\u683c\u5f0f\u5316\u6574\u4e2a\u786c\u76d8\uff0c\u5176\u4ed6\u9ed8\u8ba4<br \/>\n\u5b89\u88c5\u5b8cCentOS-6.4-x86_64-minimal.iso<\/p>\n<h2>\u7f51\u7edc\u914d\u7f6e\uff1a<\/h2>\n<p>vi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \u7f16\u8f91\u4e3a\u5982\u4e0b\u5185\u5bb9\uff08\u53ef\u6dfb\u52a0\u591a\u4e2a\u7f51\u5361\uff0c\u5982 ifcfg-eth1, ifcfg-eth1:0\uff09<br \/>\nDEVICE=\"eth0\"<br \/>\nBOOTPROTO=\"static\"<br \/>\nHWADDR=\"00:0C:29:2F:80:60\"<br \/>\nNM_CONTROLLED=\"no\"<br \/>\nONBOOT=\"yes\"<br \/>\nTYPE=\"Ethernet\"<br \/>\nUUID=\"72050b68-cb84-4d83-a616-7b0ed37883d9\"<br \/>\nIPADDR=142.91.131.63<br \/>\nPREFIX=24<br \/>\nGATEWAY=142.91.131.1<br \/>\nDEFROUTE=NO<br \/>\nIPV6INIT=NO<br \/>\nIPV6_AUTOCONF=NO<br \/>\nDNS1=8.8.8.8<\/p>\n<p># service network restart<\/p>\n<h2>\u7528\u6237\u73af\u5883\u914d\u7f6e\uff1a<\/h2>\n<p># hwclock --set --date=\"11\/17\/12 09:10:30\" \/\/\u66f4\u65b0\u65f6\u95f4<br \/>\n# hwclock --hctosys\/\/\u628a\u786c\u4ef6\u65f6\u949f\u540c\u6b65\u5230\u7cfb\u7edf\u65f6\u949f<br \/>\n# vi \/etc\/sysconfig\/clock \/\/\u66f4\u6539\u65f6\u533a<br \/>\nZONE=Asia\/Shanghai<br \/>\nUTC=false<br \/>\nARC=false<br \/>\n# rm \/etc\/localtime<br \/>\n# ln -sf \/usr\/share\/zoneinfo\/Asia\/Shanghai \/etc\/localtime<\/p>\n<p># \/usr\/sbin\/groupadd www<br \/>\n# \/usr\/sbin\/useradd -g www www<br \/>\n# passwd www #\u4fee\u6539\u5bc6\u7801\u4e3a\u5ba2\u6237VPS\u7684\u5bc6\u7801<br \/>\n# echo \"AllowUsers www\" &gt;&gt; \/etc\/ssh\/sshd_config<br \/>\n# service sshd restart<br \/>\n# \/usr\/sbin\/groupadd mysql<br \/>\n# \/usr\/sbin\/useradd -g mysql mysql<br \/>\n# mkdir -p \/wwwroot\/htdocs \/\/\u4ee5\u4e0b\u6302\u8f7d\u76ee\u5f55\uff0c\u6839\u636e\u5b9e\u9645\u89c4\u5212\u548c\u786c\u76d8\u540d\u5b57\u6765\u8fdb\u884c\u64cd\u4f5c<br \/>\n# mkdir -p \/wwwroot\/mysql<br \/>\n# mkfs -t ext4 \/dev\/sdb<br \/>\n# mkfs -t ext4 \/dev\/sdc<br \/>\n# mount \/dev\/sdb \/wwwroot\/htdocs<br \/>\n# mount \/dev\/sdc \/wwwroot\/mysql<br \/>\n# chown -R www:www \/wwwroot\/htdocs<br \/>\n# chown -R mysql:mysql \/wwwroot\/mysql<br \/>\n# echo \"mount \/dev\/sdb \/wwwroot\/htdocs\" &gt;&gt; \/etc\/rc.local<br \/>\n# echo \"mount \/dev\/sdc \/wwwroot\/mysql\" &gt;&gt; \/etc\/rc.local<\/p>\n<h2>\u5b89\u88c5\u5305\u4e0b\u8f7d\uff1a<\/h2>\n<p># yum -y install yum-fastestmirror<br \/>\n# yum clean all<br \/>\n# yum list<br \/>\n# yum -y install wget vixie-cron crontabs<br \/>\n# service crond start<br \/>\n# chkconfig --level 2345 crond on<br \/>\n# wget http:\/\/cdn.mysql.com\/Downloads\/MySQL-5.6\/MySQL-server-5.6.13-1.el6.x86_64.rpm<br \/>\n# wget http:\/\/cdn.mysql.com\/Downloads\/MySQL-5.6\/MySQL-client-5.6.13-1.el6.x86_64.rpm<br \/>\n# wget http:\/\/cn2.php.net\/get\/php-5.4.20.tar.gz\/from\/am1.php.net\/mirror<br \/>\n# yum -y install vsftpd ftp telnet<br \/>\n# cd \/etc\/vsftpd\/<br \/>\n# vi ftpusers \/\/\u6ce8\u91ca\u6389root\uff0c\u5982\u679c\u662f\u53ea\u5f00\u901awww\u7528\u6237\u7684\u8bdd\uff0c\u5c31\u4e0d\u7528\u5904\u7406<br \/>\n# vi vsftpd.conf \/\/\u4fee\u6539\u4e3aanonymous_enable=NO \u6dfb\u52a0 local_root=\/wwwroot\/backup<br \/>\n# vi user_list \/\/\u6ce8\u91ca\u6389root<br \/>\n# setsebool -P allow_ftpd_full_access 1<br \/>\n# setsebool -P ftp_home_dir 1 \/\/Centos\u4e0b\u56e0\u4e3aSElinux\u9650\u5236\u4e86vsftpd\u7528\u6237\u4e0a\u4f20\u6587\u4ef6\u5230\u4e3b\u76ee\u5f55\uff0c\u6240\u4ee5\u9700\u8981\u6267\u884c\u6b64\u547d\u4ee4\u3002\u53ef\u4ee5\u7528\u547d\u4ee4getsebool -a | grep ftp\u6765\u68c0\u67e5\u3002<br \/>\n# service vsftpd\u00a0 restart<br \/>\n# yum list | grep openjdk \/\/\u641c\u7d22\u5230\u7c7b\u4f3c\u4e0b\u8fb9\u7684\u5b89\u88c5\u5305\uff0c\u7136\u540e\u5b89\u88c5<br \/>\n# yum install java-1.7.0-openjdk.x86_64 -y<\/p>\n<h2>\u5b89\u88c5mysql\uff1a<\/h2>\n<p># yum install perl libaio -y<br \/>\n# cd ~<br \/>\n# yum remove mysql-libs-5.1.66-2.el6_3.x86_64 -y<br \/>\n# yum remove mysql-libs-5.1.67-1.el6_3.x86_64 -y<br \/>\n# rpm -i MySQL-server-5.6.13-1.el6.x86_64.rpm<br \/>\n# rpm -i MySQL-client-5.6.13-1.el6.x86_64.rpm<br \/>\n\u66f4\u6539mysql\u8def\u5f84<br \/>\n# mv \/var\/lib\/mysql\/* \/wwwroot\/mysql<br \/>\n# rm -fr \/var\/lib\/mysql<br \/>\n# ln -s \/wwwroot\/mysql \/var\/lib\/mysql<br \/>\nvi \/etc\/my.cnf\u5982\u4e0b\uff1a<br \/>\n[mysqld]<br \/>\ndatadir=\/wwwroot\/mysql<br \/>\nsocket=\/wwwroot\/mysql\/mysql.sock<br \/>\nuser=mysql<br \/>\n[mysqld_safe]<br \/>\nlog-error=\/var\/log\/mysqld.log<br \/>\npid-file=\/var\/run\/mysqld\/mysqld.pid<br \/>\n\u4fee\u6539vi \/etc\/init.d\/mysql\u7684datadir\u4e3adatadir=\"\/wwwroot\/mysql\"<br \/>\nvi \/etc\/selinux\/config \u4fee\u6539 SELINUX=enforcing<br \/>\n# chcon\u00a0 -t var_lib_t \/wwwroot<br \/>\n# chcon -R -t mysqld_db_t \/wwwroot\/mysql<br \/>\n# chown mysql:mysql \/wwwroot\/mysql<br \/>\n# service mysql start<br \/>\n# chkconfig --level 2345 mysql on<br \/>\n# more \/root\/.mysql_secret \/\/\u67e5\u770broot\u5bc6\u7801<br \/>\n# \/usr\/bin\/mysql_secure_installation \/\/\u521d\u59cb\u5316\u6570\u636e\u5e93<\/p>\n<h2>\u5b89\u88c5nginx\uff1a<\/h2>\n<p>\u8be6\u89c1<a href=\"http:\/\/pony.hk\/?p=101\" target=\"_blank\">\u300anginx\u5b89\u88c5\u3001\u914d\u7f6e\u53cd\u5411\u4ee3\u7406\u914d\u7f6e\u548c\u5b57\u7b26\u66ff\u6362\u673a\u5236\u300b<\/a><\/p>\n<h2>\u5b89\u88c5php\uff1a(php 5.5\u8fd0\u884cCRM\u4f1a\u51fa\u73b0\u90ae\u4ef6\u65e0\u6cd5\u663e\u793a\u7684\u73b0\u8c61\uff0c\u5e76\u4e14\u4e0d\u652f\u6301xcache\uff0c\u6240\u4ee5\u5b89\u88c5php 5.4)<\/h2>\n<p># yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel gd-devel make unzip patch<\/p>\n<p># tar -zxf php-5.4.20.tar.gz<br \/>\n# cd php-5.4.20<br \/>\n# .\/configure --prefix=\/usr\/local\/php --with-config-file-path=\/usr\/local\/php\/etc --with-config-file-scan-dir=\/usr\/local\/php\/etc\/php.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-pcre-regex --with-zlib --with-bz2 --enable-calendar --with-curl --enable-dba --with-libxml-dir --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-mhash --enable-mbstring --with-mysql --with-mysql-sock --with-mysqli --enable-pcntl --with-pdo-mysql --enable-shmop --enable-sockets --enable-zip --with-pear<br \/>\n# dd if=\/dev\/zero of=\/swap bs=1024 count=1M<br \/>\n# mkswap \/swap<br \/>\n# swapon \/swap<br \/>\n# echo \"\/swap swap swap sw 0 0\" &gt;&gt; \/etc\/fstab \/\/\u589e\u52a0swap\uff0c\u9632\u6b62\u51fa\u73b0\u865a\u62df\u5185\u5b58\u4e0d\u591f\u7684\u62a5\u9519<\/p>\n<p># make &amp;&amp; make install<br \/>\n# cp php.ini-production \/usr\/local\/php\/etc\/php.ini<br \/>\n# mkdir -p \/usr\/local\/php\/etc\/php.d<\/p>\n<h2>\u914d\u7f6ephp-fpm\uff1a<\/h2>\n<p># cp sapi\/fpm\/init.d.php-fpm \/etc\/init.d\/php-fpm<br \/>\n# mv \/usr\/local\/php\/etc\/php-fpm.conf.default \/usr\/local\/php\/etc\/php-fpm.conf<br \/>\n# chmod +x \/etc\/init.d\/php-fpm<br \/>\n# chkconfig --add php-fpm<br \/>\n# chkconfig --level 2345 php-fpm on<br \/>\nvi \/usr\/local\/php\/etc\/php-fpm.conf\u4fee\u6539\u4ee5\u4e0b\u53c2\u6570\uff1a<br \/>\nrequest_terminate_timeout = 30s<br \/>\npm.max_children = 50<br \/>\npm.start_servers = 16<br \/>\npm.min_spare_servers = 16<br \/>\npm.max_spare_servers = 50<\/p>\n<h2>\u5b89\u88c5xcache 3.0.3\uff1a<\/h2>\n<p># cd ~<br \/>\n# wget http:\/\/xcache.lighttpd.net\/pub\/Releases\/3.0.3\/xcache-3.0.3.tar.gz<br \/>\n# gunzip xcache-3.0.3.tar.gz; tar -xf xcache-3.0.3.tar; cd xcache-3.0.3<br \/>\n# \/usr\/local\/php\/bin\/phpize --clean<br \/>\n# \/usr\/local\/php\/bin\/phpize<br \/>\n#.\/configure --enable-xcache -enable-xcache-coverager --enable-xcache-optimizer --with-php-config=\/usr\/local\/php\/bin\/php-config<br \/>\n# make &amp;&amp; make install<br \/>\n# echo -n \"123456\" | md5sum<br \/>\n# e10adc3949ba59abbe56e057f20f883e \/\/\u8fd9\u4e2a\u5b57\u7b26\u4e32\u540e\u8fb9\u8981\u7528\u5230\uff0c\u662f\u7f51\u9875\u8bbf\u95ee\u9700\u8981\u7684\u52a0\u5bc6\u8fc7\u7684\u5bc6\u7801123456<br \/>\n# touch \/tmp\/xcache<br \/>\n# chmod 777 \/tmp\/xcache<br \/>\n# vi \/usr\/local\/php\/etc\/php.d\/xcache.ini \u4e3a\u5982\u4e0b\u5185\u5bb9<br \/>\n[xcache-common]<br \/>\nextension = \"\/usr\/local\/php\/lib\/php\/extensions\/no-debug-non-zts-20100525\/xcache.so\"<br \/>\n[xcache.admin]<br \/>\n; Change xcache.admin.user to your preferred login name<br \/>\nxcache.admin.user = \"admin\"<br \/>\n; Change xcache.admin.pass to the MD5 fingerprint of your password<br \/>\n; Use md5 -s \"your_secret_password\" to find the fingerprint<br \/>\nxcache.admin.pass = \"5a826e6cb0418ad239d4c79915e28cd5\"<br \/>\n[xcache]<br \/>\n; Change xcache.size to tune the size of the opcode cache<br \/>\nxcache.size = 128M<br \/>\nxcache.shm_scheme = \"mmap\"<br \/>\nxcache.count = 2<br \/>\nxcache.slots = 8K<br \/>\nxcache.ttl = 0<br \/>\nxcache.gc_interval = 0<br \/>\n; Change xcache.var_size to adjust the size of variable cache<br \/>\nxcache.var_size = 32M<br \/>\nxcache.var_count = 1<br \/>\nxcache.var_slots = 8K<br \/>\nxcache.var_ttl = 0<br \/>\nxcache.var_maxttl = 0<br \/>\nxcache.var_gc_interval = 300<br \/>\nxcache.test = Off<br \/>\nxcache.readonly_protection = On<br \/>\nxcache.mmap_path = \"\/tmp\/xcache\"<br \/>\nxcache.coredump_directory = \"\"<br \/>\nxcache.cacher = On<br \/>\nxcache.stat = On<br \/>\nxcache.optimizer = On<br \/>\n[xcache.coverager]<br \/>\nxcache.coverager = Off<br \/>\nxcache.coveragedump_directory = \"\"<\/p>\n<h2>\u5b89\u88c5mcrypt<\/h2>\n<p># rpm -ivh http:\/\/dl.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-8.noarch.rpm<br \/>\n# yum install php-mcrypt libmcrypt libmcrypt-devel mcrypt mhash -y<br \/>\n# cd ~\/php-5.4.20\/ext\/mcrypt\/<br \/>\n# \/usr\/local\/php\/bin\/phpize<br \/>\n# .\/configure --with-php-config=\/usr\/local\/php\/bin\/php-config<br \/>\n# make &amp;&amp; make install<br \/>\n# cd \/usr\/local\/php\/etc\/php.d<br \/>\n# vi mcrypt.ini<br \/>\n\u5185\u5bb9\u4e3aextension=\"\/usr\/local\/php\/lib\/php\/extensions\/no-debug-non-zts-20100525\/mcrypt.so\"<\/p>\n<h2>\u5b89\u88c5openssl<\/h2>\n<p># yum install openssl openssl-devel -y<br \/>\n# ln -s \/usr\/lib64\/libssl.so \/usr\/lib\/<br \/>\n# cd ~\/php-5.4.20\/ext\/openssl\/<br \/>\n# cp\u00a0config0.m4\u00a0config.m4<br \/>\n# \/usr\/local\/php\/bin\/phpize<br \/>\n# .\/configure --with-openssl \u00a0--with-php-config=\/usr\/local\/php\/bin\/php-config<br \/>\n# make &amp;&amp; make install<br \/>\n# cd \/usr\/local\/php\/etc\/php.d<br \/>\n# vi openssl.ini<br \/>\n\u5185\u5bb9\u4e3aextension=\"\/usr\/local\/php\/lib\/php\/extensions\/no-debug-non-zts-20100525\/openssl.so\"<\/p>\n<h2>\u8c03\u6574mysql, php, nginx\u914d\u7f6e\u6587\u4ef6\u4f4d\u7f6e\uff1a<\/h2>\n<p># mkdir -p \/wwwroot\/htdocs\/script<br \/>\n# mv \/etc\/my.cnf \/wwwroot\/htdocs\/script\/mysql.my.cnf<br \/>\n# ln -s \/wwwroot\/htdocs\/script\/mysql.my.cnf \/etc\/my.cnf<br \/>\n# chcon -t etc_t \/wwwroot\/<br \/>\n# chcon -u system_u \/wwwroot\/<br \/>\n# chcon -t etc_t \/wwwroot\/htdocs<br \/>\n# chcon -u system_u \/wwwroot\/htdocs<br \/>\n# chcon -t etc_t \/wwwroot\/htdocs\/script<br \/>\n# chcon -u system_u \/wwwroot\/htdocs\/script<br \/>\n# service mysql restart<br \/>\n# mv \/etc\/nginx\/conf.d \/wwwroot\/htdocs\/script\/nginx.conf.d<br \/>\n# ln -s \/wwwroot\/htdocs\/script\/nginx.conf.d \/etc\/nginx\/conf.d<br \/>\n# service nginx restart<br \/>\n# mv \/usr\/local\/php\/etc \/wwwroot\/htdocs\/script\/php.etc<br \/>\n# ln -s \/wwwroot\/htdocs\/script\/php.etc \/usr\/local\/php\/etc<br \/>\n# service php-fpm restart<br \/>\n# echo \"service mysql restart\" &gt;&gt; \/etc\/rc.local<br \/>\n# echo \"service php-fpm restart\" &gt;&gt; \/etc\/rc.local<br \/>\n# echo \"service nginx restart\" &gt;&gt; \/etc\/rc.local<br \/>\n# echo \"service vsftpd restart\" &gt;&gt; \/etc\/rc.local<br \/>\n# \/sbin\/iptables -F<br \/>\n# service iptables save<br \/>\n# service iptables restart<br \/>\n# reboot<\/p>\n<h2>\u914d\u7f6e\u6d4b\u8bd5\u7f51\u7ad9\uff1a<\/h2>\n<p># su - www<br \/>\n# cd \/wwwroot\/htdocs<br \/>\n# wget http:\/\/download.comsenz.com\/DiscuzX\/3.0\/Discuz_X3.0_SC_GBK.zip<br \/>\n# unzip Discuz_X3.0_SC_GBK.zip<br \/>\n# rm -fr Discuz_X3.0_SC_GBK.zip readme utility<br \/>\n# mv upload discuz<br \/>\n# mysql -u root -p<br \/>\n# mysql&gt; create database discuz;<br \/>\n# mysql&gt; exit<br \/>\n# su -<br \/>\n\u5728\/etc\/nginx\/conf.d\/\u76ee\u5f55\u91cc\u8fb9\u6dfb\u52a0discuz.conf\u6587\u4ef6<\/p>\n<p>\u786e\u8ba4\u7f51\u7ad9\u7684\u6c34\u5370\u548cURL\u8f6c\u53d1\u6ca1\u6709\u95ee\u9898\u540e\uff0c\u5220\u9664\u7f51\u7ad9\uff1a<br \/>\n# rm -rf \/wwwroot\/htdocs\/discuz<br \/>\n# rm -rf \/etc\/nginx\/conf.d\/discuz.conf<br \/>\n# mysql -u root -p<br \/>\n# mysql&gt; drop database discuz;<br \/>\n# mysql&gt; exit<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89c4\u5212\uff1a \u786c\u76d80 \uff1a20GB\uff0c\u786c\u76d81 \uff1a20GB\uff0c\u786c\u76d82\uff1a 5GB \u7f51\u53610\uff1a host-only\uff0c\u7f51\u53611\uff1a br...<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19510,7,15330,15329,15331],"tags":[],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-lnmp","category-linux","category-mysql","category-nginx","category-php"],"_links":{"self":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=119"}],"version-history":[{"count":0,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/posts\/119\/revisions"}],"wp:attachment":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}