2017LinuxPHP+Mysql+nginx最详尽配置学习手册包括优化

来源:互联网 发布:高校教学软件租赁 编辑:程序博客网 时间:2024/06/07 11:32
==========================郭朵朵大叔学习速查手册============================
自动更新系统,yum update
修改密码:passwd xxxxxx即可   查看系统版本:lsb_release -a


查看IP和修改:contos 7 使用ip link  ip addr  而非传统ifconfig
============================让新用户获得root权限==========================
修改/etc/passwd文件,找到如下行,把用户ID修改为0
bookso:x:500:50::/usr/www/dcigo:/sbin/nologin  
改为
bookso:x:0:50::/usr/www/dcigo:/sbin/nologin




添加自启动服务:
在/etc/rc.local文件最后一行添加启动服务,如:service mysqld start


复制文件


=============================卸载桌面提高系统的运行速度======================
显示系统已经安装的组件,和可以安装的组件:
   yum grouplist
如果系统安装之初采用最小化安装,没有安装xwindow,那么先安装:
   yum groupinstall "X Window System"
安装GNOME桌面环境
   yum groupinstall "GNOME Desktop Environment"    Games and Entertainment
安装KDE桌面环境
   yum groupinstall "KDE (K Desktop Environment)"  KDE (K Desktop Environment)
卸载GNOME桌面环境
   yum groupremove "GNOME Desktop Environment"  GNOME Software Development
卸载KDE桌面环境
   yum groupremove "KDE (K Desktop Environment)"


=================================主机Linux基本命令=============================
cat /proc/cpuinfo 查看cpu信息,processor 0 为一个U,1为2个U,flags 超线程


lspci 查看主板信息


free 查内存


df -h 查硬盘


du -sh 查看文件夹大小


top 比较安全,内存 进程 负载 都有
top命令进阶
d:指定每两次屏幕信息刷新之间的时间间隔。当然用户可以使用s交互命令来改变之。
q:退出 


uptime 查运行时间 负载情况


ps 查看进程,当前进程
ps aux | less  显示所有运行中的进程
ps -U root -u root -N   查看非root运行的进程


启动服务service mysqld start          ========用户centos 5.x系列


systemctl start mysqld        ========用于centos 7.0以上互不通用

=========================查看端口占用情况=============================
没有的话:安装yum install net-tools工具
netstat -nat

=========================修改SSH中文显示,系统篇=====================
编辑:/etc/sysconfig/i18N
修改:   LANG="zh_CN.UTF-8"(原)
     
LANG="zh_CN.GB18030"
SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"


=========================查看服务======================
chkconfig --list(系统运行级别注释:
                  0停机,
                  1:单用户模式[类似安全模式],
                  2:多用户模式没有NFS
                  3:正常模式(系统正常运行)
                  4:没有用到
                  5:-x11 进入x-window模式时
                  6:重新启动时
设置某服务
chkconfig --level 3 xxx服务 off/on


查看分组列表:yum grouplist (用于查看系统安装了那些软件)


LINUX文件创建与删除
rm -rf *.*  删除这个目录下所有的文件
rm -rf *关键字*  删除和关键字有关的所有文件
删除目录 rm -rf xxx目录    (强行删除不提示)
创建文件夹:mkdir xxx目录   


1、使用 service 启动:service mysqld start
2、 使用 service 启动:service mysqld restart


============================yum源添加及设置================================
yum:配置yum源
yum install yum-priorities   优先级添加插件工具
首先备份CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载对应版本的CentOS-Base.repo, 放入/etc/yum.repos.d/
运行yum makecache生成缓存


添加第三方源 :权级自己设置,一般1-10系统的,10以外的是自己的以防第三方的抢着跟新
在【base】最后一行添加,priority=1


epel 源http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm   这个好使
添加源到rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
更改权限为11;


remi源:http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
yum --enablerepo=remi makecache使用


rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi将这个的权级设为一addons 的权级设为最低
安装软件yum --enablerepo=remi install mysql


=============================RPM命令使用=========================
rpm 命令:
查看软件 
    rpm -qpi xxx.rpm 软件
软件安装
    rpm -ivh (强制安装-replacepkgs) xxxx.rpm 
直接在线安装
    rpm -i ftp://xxx.com/xxx.rpm
卸载某个软件
    rpm -e xxx软件名 --nodeps(强制删除)
查找损坏的文件
    rpm -Va
差列出所有符合改软件
    rpm -qa|grep -i xxxxx软件名


============================FTP安装及防火墙设置==============================


FTP 服务器设置:如果没安装FTP,运行yum install vsftpd命令即可      
    
vsftpd 服务service vsftpd start                                        


systemctl                                                              


将root从/etc/vsftpd/user_list 和 ftpusers文件中注释掉
执行命令 
开启防火墙:setsebool -P ftpd_disable_trans=1      好像是解除什么限制之类的(不执行试试看)


修改vsftpd.config添加一行:loacl_root=/   (本地用户默认访问地址为根目录)


添加FTP用户:
adduser -d /tmp/xxxx(用户只能访问到的空间) -g ftp -s /sbin/nologin(限制其不能登录系统) xxxx新用户名


设置密码
passwd xxxx用户
修改FTP用户目录
编辑  vi /etc/passwd  找到你的用户名修改其路径即可


修改文件权限:
1.更改文件夹所属用户:chown -R xxx用户 xxxx文件/* 
2.更改文件夹权限:chmod 775 xxx文件夹/*   


SElinux防火墙检查及关闭    
关闭SElinux 需要重启服务器 修改/etc/selinux/config文件中设置SELINUX=disabled ,然后重启服务器。
查看selinux的状态:getsebool -a|grep ftp (有哪些关闭中的)
setsebool -P ftpd_disable_trans=1 指定开启的防火墙服务


FTP限制用户目录,不得改变目录到上级
注释去掉
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list(手动创建)  用户名单(vi chroot_list)即可


//搞定了....哈哈哈
=============================防火墙=======================
很多不能访问都是这个的问题
CentOS 7.0默认使用的是firewall作为防火墙  


systemctl start firewalld.service#启动firewall
systemctl stop firewalld.service#停止firewall
systemctl disable firewalld.service#禁止firewall开机启动


=======================添加http访问============================
firewall-cmd --permanent --zone=public --add-service=http  
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload


传统的是iptables  防火墙//SElinux防火墙           centos常用
======================Centos 7配置防火墙======================
firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --reload
查找FTP相关的SELinux bool值,给FTP访问放行
getsebool -a | grep ftp
setsebool -P ftpd_full_access on


==============================MySql安装及使用==============================
Mysql 下载地址:       


yum在线rpm安装:yum -y install mysql-server 即可


以下版本根据自己的自己的实际情况来但是必要文件要下载全
       
http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.12-1.rhel5.i386.rpm
http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.12-1.rhel5.i386.rpm
http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.12-1.rhel5.i386.rpm


http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-shared-compat-5.6.12-1.rhel5.i386.rpm

http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.32.rhel5.i386.rpm
http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.32-1.rhel5.i386.rpm
http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.32-1.rhel5.i386.rpm


64位下载地址:
http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-server-5.7.11-1.el7.x86_64.rpm
http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-devel-5.7.11-1.el7.x86_64.rpm
http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-client-5.7.11-1.el7.x86_64.rpm
http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-libs-5.7.11-1.el7.x86_64.rpm
http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-common-5.7.11-1.el7.x86_64.rpm

http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-community-server-5.7.10-1.el5.i686.rpm
http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-community-devel-5.7.10-1.el5.i686.rpm
http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-community-client-5.7.10-1.el5.i686.rpm
默认密码/root/.mysql_secret    (有点号)
需要下载安装三个文件
    MySQL-server-5.5.16-1.rhel4.i386.rpm 
    MySQL-client-5.5.16-1.rhel4.i386.rpm 
    MySQL-devel-5.5.16-1.rhel4.i386.rpm


解压zip:unzip xxx.zip文件
    tar:tar -xzf all.tar.gz
       tar -xvf xxxx.gz


    xz:xz -d glib-2.34.3.tar.xz


删除命令:rm xxx.zip   
         -d 删除可能仍有数据的目录 
         -f 强制删除
         -r 同时删除该目录下的所有目录层


数据库操作


修改密码:[root@test1 local]# /usr/bin/mysqladmin -u root -p password 123456
   注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。 


新装的修改密码二:
      mysql>set password =password('你的密码');
      mysql>flush privileges;




忘记密码:
1.修改配置   vi /usr/my.cnf  
添加 skip-grant-tables   (意思是无需密码和帐户登录)
然后修改:mysql>use mysql;
          mysql>update mysql.user set password=password('123456789') where user='root';
               >flush privileges; 
          跳转到(修改密码步骤)    必须的
          


管理进入:mysql -u root(用户名) -p 回车即可


进入:mysql -u root -p/mysql -h localhost -u root -p databaseName;
退出:mysql>quit;
  列出数据库:show databases;
  删除数据库:drop database xxxx库;
  选择数据库:use databaseName;
  列出表格:show tables;
  显示表格列的属性:show columns from tableName;
  建立数据库:source fileName.txt;
  匹配字符:可以用通配符_代表任何一个字符,%代表任何字符串;
  增加一个字段:alter table tabelName add column fieldName dateType;
  增加多个字段:alter table tabelName add column fieldName1 dateType,add columns fieldName2 dateType;


=========================关于MySql数据插入错误提示========================
老版本Mysql使用'TYPE=MyISAM '  (5.5以下版本)以上版本被禁用,会导致很多CMS系统无法安装
而在MySql 5.5 以上版本则用   'ENGINE=MyISAM'  
不懂的自己百度

==============================nginx安装及使用============================
nginx 
平滑重启:nginx -s reload  即可
验证配置文件正确性:nginx -t 以防止加载错误的配置文件造成服务器奔溃
ps -ef | grep nginx  查看nginx进程ID号
nginx -c /etc/nginx/nginx.conf重新加载配置      默认配置文件在conf.d文件夹下一个网站对应一个xxx.conf
下载地址:
  http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm    此为yum源不是安装包
  http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.8.1-1.el7.ngx.x86_64.rpm               centos 7 64位
单独安装包:GeoIP,gd,gperftools-libs,libxslt,nginx-filesystem
安装: yum install nginx    可安装其他的安装包
 查看配置文件位置:
  nginx -t
 默认配置文件地址:/etc/nginx/config/default.conf
 默认网站位置:/usr/share/nginx/html
 
 关于空主机头(他人为我做流量)
 server { 
  listen 80 default; 
  rewrite ^(.*) http://www.mobantu.com permanent; 
 } 


/bin/systemctl start httpd.service    centos 7启动选项,新增
启动nginx服务器:::::systemctl start nginx    centos7  =============systemctl Centos7 专用启动命令      


=================支持TinkPHP之类框架,开启INFO==============
首先php.ini的配置中把
cgi.fix_pathinfo=0   改为   cgi.fix_pathinfo=1
在nginx原有配置文件的位置上添加
location ~ \.php/?.*$ {
    fastcgi_param PATH_INFO $real_script_name;
}


例如设置nginx防盗链:
location ~* \.(gif|jpg|png|swf|flv)$ {
valid_referers none blocked http://www.jefflei.com/http://www.leizhenfang.com/;
if ($invalid_referer) {
return 404;
}
}

===================解锁nginx限制------》解除POST文件超过2M的文件会提示出错问题


打开nginx配置文件nginx.conf,找到http{}段,添加
client_max_body_size 8m;到该段中


=================Nginx配置文档,可以自己根据实际情况做调整,============
直接复制过来,,,,,,,,用默认配置文件在conf.d文件夹下一个网站对应一个xxx.conf
server {
    listen       80;
    server_name  www.xxxxxx.com;


    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;


    location / {
        root   /usr/www/xxxxxx; =================记得改成自己的网站地址
        index  index.php index.html index.htm;
        try_files $uri /index.php$uri;
    }


    #error_page  404              /404.html;


    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }


    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #\.php?.*$
    location ~ .+\.php($|/) {
        #root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;             =============php-fpm的端口地址,根据自己设置的来,,如果照我的方法可以不用改
        fastcgi_index  index.php;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        fastcgi_param  PATH_INFO $fastcgi_path_info;
        fastcgi_param  SCRIPT_FILENAME /usr/www/xxxxxxx$fastcgi_script_name;   #/usr/www/加自己的网站地址
        include        fastcgi_params;
    }




    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}


====================================PHP 安装=====================================
PHP 安装
需要下载的编译安装包 
检查系统包是否完善:   (devel也是安装包,分开来,devel客户端)
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,libidn/libidn-devel,openssl/openssl-devel,openldap/openldap-devel,libmcrypt/libmcrypt-devel

每个包都需要检查一下,如果系统有了,就不用安装了



============================额外包也可用系统yum来安装只是版本低点===========================
libiconv: http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz(最新版请根据实际清空来)


libmcrypt:http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz  (此用系统的yum装)


mcrypt:http://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz (此用系统yum装)
 
mhash:http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2
      http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz


=================================安装包下载===========================
下载地址:http://hk2.php.net/distributions/php-5.4.8.tar.gz


http://us1.php.net/distributions/php-5.3.18.tar.gz


http://us3.php.net/distributions/php-5.3.26.tar.gz   (php5.3.26)


http://www.php.net/get/php-5.4.16.tar.gz/from/us3.php.net/mirror   (php-5.4.16.tar.gz)
yum方法安装,只需要:yum install -y php-cgi php-mysql


PHP 5.6.2版本:http://cn2.php.net/distributions/php-5.6.20.tar.gz


==============================PHP7新安装=============================
安装:
下载:https://downloads.php.net/~ab/php-7.0.0RC6.tar.gz


解压zip:unzip xxx.zip文件
    tar:tar -xzf all.tar.gz
       tar zxvf xxxx.gz


查找未知软件安装位置
find / -name xxx软件名 -print


gd默认安装地址=


libjpeg默认安装地址:


freetype默认安装地址:/usr/include/freetype2/freetype


=====================================可选=====================
用spawn-fcgi启动PHP里面的fastcgi引擎 
源码安装的方式启动方法:/data/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nobody -f /usr/bin/php-cgi -C 20
rpm安装的启动方法:spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -d /tmp -f php-cgi -C 10


这个程序在nginx里没有提供,可以在
最新下载地址:http://dl.fedoraproject.org/pub/epel/5/i386/spawn-fcgi-1.6.3-1.el5.i386.rpm
无需配置

http://www.sudone.com/download/spawn-fcgi
将软件放入nginx的sbin目录下
======================================必须====================
php 编译:   (--with-mysql=xx/mysql 头文件请以mysql.h为准  查找获得)    /usr/share/mysql    正对5.4.x支持mysqlnd 意思是直接用php的访问引擎

//范列,,,慎用,
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=mysqlnd --with-mysql-sock --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap


configure: error: Cannot find ldap libraries in /usr/lib
解决办法:
cp -frp /usr/lib64/libldap* /usr/lib/


=========================配置二适合5.3===========================含FPM服务常用可用用于以上版本不适合7.0以上
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/include/mysql --with-mysqli=/usr/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap


===========================配置三  PHP7.0含FPM服务一起开启====================
第一种  不开启-fpm的,,如果以后想开启直接在编译一次
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip


第二种开启了所有服务的
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --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 --enable-maintainer-zts

每段之间没有断开的

添加配置文件 cp php.ini-production /usr/local/php/etc/php.ini   (php.ini-production)用户线上另一个用于开发测试使用

===========================PHP编辑之后的信息:===============
Installing PHP SAPI module:       fpm
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/man/man1/
Installing PHP FPM binary:        /usr/local/php/sbin/
Installing PHP FPM config:        /usr/local/php/etc/
Installing PHP FPM man page:      /usr/local/php/man/man8/
Installing PHP FPM status page:   /usr/local/php/share/php/fpm/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:          /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php/lib/php/
[PEAR] Archive_Tar    - installed: 1.3.7
[PEAR] Console_Getopt - installed: 1.3.0
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util       - installed: 1.2.1
[PEAR] PEAR           - installed: 1.9.4
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/root/php-5.3.18/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/


================php.ini设置===================
时区  ;data.timezone="UTC"
开启框架支持 cgi.fix_pathinfo=0   改为   cgi.fix_pathinfo=1
开启错误提示:display_errors = On 


==============================php-fpm无需单独下载,PHP5.1以上就自带了======================
PHP php-fpm参数   


1.修改文件
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf


2.添加php-fpm到服务列表里面:   (在php安装目录中操作)
  服务脚本  
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm  
# chmod +x /etc/rc.d/init.d/php-fpm 




开启:pid = run/php-fpm.pid 选项   (php-fpm.conf配置文件里面开启)


启动:/usr/local/php/sbin/php-fpm start


5.6.2启动:/usr/local/php/sbin/php-fpm start即可   


7.0启动: systemctl start php-fpm.service


-----------------------------5.3.3以后的PHP不支持start|stop|restart命令-------------------------
INT, TERM 立刻终止
QUIT 平滑终止
USR1 重新打开日志文件
USR2 平滑重载所有worker进程并重新载入配置和二进制模块
示例:
php-fpm 关闭:
kill -INT `cat /usr/local/php/var/run/php-fpm.pid`
php-fpm 重启:
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
查看php-fpm进程数:
ps aux | grep -c php-fpm




配置修改:/usr/local/php/etc/
     pm.max_children = 50   最多多少子进程  
     pm.start_servers = 5   刚开始启动多少进程  
     pm.min_spare_servers = 2  最少多少空闲进程  
     pm.max_spare_servers = 8  最多多少空闲进程  
     user  www
     group www    (必须创建独立的用户和组来运行,不然就要纠结)      创建组;groupadd webrun组  useradd -g webrun(指定某个组) xxx用户


重新加载PHP配置文件:/usr/local/php/sbin/php-fpm reload
max_children :10 进程数


StartServers :5 启动服务数量
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profiler
  -h               This help
  -i               PHP information
  -m               Show compiled in modules
  -v               Version number
  -p, --prefix <dir>
                   Specify alternative prefix path to FastCGI process manager (default: /usr/local/php).
  -g, --pid <file>
                   Specify the PID file location.
  -y, --fpm-config <file>
                   Specify alternative path to FastCGI process manager config file.
  -t, --test       Test FPM configuration and exit
  -D, --daemonize  force to run in background, and ignore daemonize option from config file
  -F, --nodaemonize
                   force to stay in foreground, and ignore daemonize option from config file
  -R, --allow-to-run-as-root
==========================memcached安装及使用============================


memcached配置和使用
服务器:http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
    tar xvf  xxxxx
    libevent/-devel  库  用最新版


  安装  ./configure --prefix=/usr/local/memcached      --with-libevent=/dir/


启动Memcached:# /usr/local/memcached/bin/memcached -d -m 30 -l 127.0.0.1 -p 11211 -u root
关闭Memcache :




"""""""""""""""""""""""""""""""""""""""""""说明""""""""""""""""""""""""""""""""""""""""""""
 -d 选项是启动一个守护进程,
 -m 是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,
 -u 是运行Memcache的用户,我这里是root,
 -l 是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.0.200,
 -p 是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口,
 -c 选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
 -P 是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
libmemcached安装  下载https://launchpad.net/libmemcached/+download 【最新版】     【注意】g++编辑器安装 yum -y install gcc+ gcc-c++    安装 gcc44 gcc44-c++ libstdc++44-devel   坑爹
                                                                                   
                
./configure --prefix=/usr/local/libmemcached --with-memcached  


如果是32位系统:
./configure --prefix=/usr/local/libmemcached --with-memcached --disable-64bit CFLAGS="-O3 -march=i686"


php客户端下载地址:http://pecl.php.net/get/memcache-3.0.8.tgz
                   http://pecl.php.net/get/memcached-2.1.0.tgz


                   http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz
         mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so /usr/local/php/lib/php/extensions


扩展安装
# /usr/local/php/bin/phpize    用于编译PHP扩展的软件,,Linux不是window,
# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcached和memcache   二选一
  make   make install


;;;;;;;;;;;;;;;;;;;;;;;;
;      Memcache       ;
;;;;;;;;;;;;;;;;;;;;;;;;
extension = memcache.so




========================================Xcahe  PHP 加速器或Zend OpCache官方自带加速器(见下文)=========================================
网站优化:js文件压缩,尽量减少请求,在头文件中添加
设置Http缓存头子
<META HTTP-EQUIV="Cache-Control" CONTENT="private">
<META HTTP-EQUIV="expires" CONTENT="43200">




 yum install autoconf  安装
 下载地址:http://xcache.lighttpd.net/pub/Releases/3.0.3/xcache-3.2.0.tar.gz   最新版本请自查
           http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz
           tar xvzf xxxx.gz


进入到解压后的目录里复制:/usr/local/php/bin/phpize   编译php模块用于安装生产.so文件就这么简单 


./configure --enable-xcache --enable-xcache-coverager --with-php-config=/usr/local/php/bin/php-config


mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xcache.so /usr/local/php/lib/php/extensions
/usr/local/php/lib/php/extensions/


设置php.ini  
   开启插件地址(默认关闭中)    extension_dir="/usr/local/php/lib/php/extensions"


"/tmp/xcache" 无需创建,由系统生成文件,(注:不是文件夹)复制就可以了


;;;;;;;;;;;;;;;;;;;;;;;;
;      Xcache          ;复制就可以了
;;;;;;;;;;;;;;;;;;;;;;;;


extension = xcache.so
; xcache
xcache.admin.user = "admin"
xcache.admin.pass = "password"
;
xcache.size = 25M
xcache.shm_scheme = "mmap"
xcache.count = 2
xcache.slots = 8k
xcache.ttl = 0
xcache.gc_interval = 0


xcache.var_size = 10M
xcache.var_count = 1
xcache.var_slots = 8k
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
xcache.readonly_protection = On
xcache.mmap_path = "/tmp/xcache"
xcache.coredump_directory = ""
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off
;
xcache.coverager = On
xcache.coveragedump_directory = ""


====================================添加自启动==========================
找到vi /etc/rc.local
添加 启动php-fpm:/usr/local/php/sbin/php-fpm start






注意  iwebshop:NOT found  问题解决
/lib/core/application_class.php   67行
//设为if true为了标注以后要再解决cli模式下的basePath
//if(!isset($_SERVER['DOCUMENT_ROOT']))
//{
//if(isset($_SERVER['SCRIPT_FILENAME']))
//{
$_SERVER['DOCUMENT_ROOT'] = dirname( $_SERVER['SCRIPT_FILENAME'] );
//}
//elseif(isset($_SERVER['PATH_TRANSLATED']))
//{
//$_SERVER['DOCUMENT_ROOT'] =  dirname( rtrim($_SERVER['PATH_TRANSLATED'],"/\\"));
//}
//}




=================================Zend OpCache官方自带==================以后可以不用Xcahe了===========
注意PHP7的Zend OpCache 与PHP5不同,不需要专门安装扩展,只需要在php.ini中加入如下三行配置即可。 
zend_extension=opcache.so 
opcache.enable=1 
opcache.enable_cli=1


===============================Node.Js安装 Linux==================================
下载安装包,,,解压
进入目录中找到bin进入
设置全局变量
ln -s /root/node-v0.10.28-linux-x64/bin/node /usr/local/bin/node
ln -s /root/node-v0.10.28-linux-x64/bin/npm /usr/local/bin/npm


查看版本,,node -v 
//=======================使用node xxx.js执行
//===========使用supervisor xxx.js当修改了一个文件时会自动加载,,调试方便


=============================node.js Linux安装=============================



0 0
原创粉丝点击