[{"data":1,"prerenderedAt":73},["ShallowReactive",2],{"article-18":3},{"code":4,"msg":5,"data":6,"count":14},200,"查询成功",{"id":7,"title":8,"keywords":9,"description":10,"category_id":11,"content":12,"body_html":13,"thumb_up":14,"clicks":15,"sort":14,"remark":16,"status":17,"is_open":17,"is_deleted":14,"is_top":14,"is_recommend":14,"create_time":18,"update_time":19,"image_id":20,"url":13,"member_id":14,"cate_name":21,"prev":22,"next":25,"tags":28,"words":44,"read_time":45,"comments":14,"cover":46,"relevant":47},18,"Centos7 安装 Nginx+PHP+Mysql","centos7,Nginx,PHP,MYSQL","Nginx 是一款免费、开源、高性能的HTTP服务器。Nginx 因性能稳定、功能丰富、配置简单、资源消耗低而著称。本文介绍如何在Linux服务器（CentOS 7）上安装Nginx、MySQL和PHP7（或者PHP5），简称LNMP。",4,"安装Nginx\n\n一、安装gcc\n\nnginx编译依赖gcc环境，centos7上没有gcc环境，则用yum安装gcc:\n\n```bash\nyum install gcc-c++\n```\n二、安装pcre pcre-devel\n\n是一个perl库，nginx的http模块视图pcre来解析正则表达式：\n\n```bash\nyum install -y pcre pcre-devel\n```\n三、安装zlib\n\nzlib库提供了很多种压缩和解压缩的方式，nginx使用zlib对http包内容进行gzip：\n\n```bash\nyum install -y zlib zlib-devel\n```\n四、安装OpenSSL\n\nOpenSSL是一个安全套接字层密码库，包括主要的密码算法，常用的密钥和证书封装管理功能以及SSL协议：\n\n```bash\nyum install -y openssl openssl-devel\n```\n五、安装nginx\n\n1、下载安装包\n\n官网下载nginx安装包.tar.gz格式，地址：http:\u002F\u002Fnginx.org\u002Fen\u002Fdownload.html\n\n2、解压\n\n依次执行如下命令：\n\n```bash\ntar -zxvf nginx-1.10.1.tar.gz\ncd nginx-1.10.1\n```\n3、配置\n\nnginx-1.10.1 版本中你就不需要去配置相关东西，默认就可以了，也可以自定义配置目录\n\na、使用默认设置：\n```bash\n.\u002Fconfigure\n```\n\nb、自定义配置：\n\n```bash\n.\u002Fconfigure \\\n--prefix=\u002Fusr\u002Flocal\u002Fnginx \\\n--conf-path=\u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.conf \\\n--pid-path=\u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.pid \\\n--lock-path=\u002Fvar\u002Flock\u002Fnginx.lock \\\n--error-log-path=\u002Fvar\u002Flog\u002Fnginx\u002Ferror.log \\\n--http-log-path=\u002Fvar\u002Flog\u002Fnginx\u002Faccess.log \\\n--with-http_gzip_static_module \\\n--http-client-body-temp-path=\u002Fvar\u002Ftemp\u002Fnginx\u002Fclient \\\n--http-proxy-temp-path=\u002Fvar\u002Ftemp\u002Fnginx\u002Fproxy \\\n--http-fastcgi-temp-path=\u002Fvar\u002Ftemp\u002Fnginx\u002Ffastcgi \\\n--http-uwsgi-temp-path=\u002Fvar\u002Ftemp\u002Fnginx\u002Fuwsgi \\\n--http-scgi-temp-path=\u002Fvar\u002Ftemp\u002Fnginx\u002Fscgi\n#建议使用第一种配置方式\n```\n4、编译安装     \n\n```bash\n make && make install\n```\n查找安装路径：\n\n```bash\nwhereis nginx\n```\n六，启动、停止nginx \n\n```bash\ncd \u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002F\n.\u002Fnginx \n.\u002Fnginx -s stop\n.\u002Fnginx -s quit\n.\u002Fnginx -s reload\n.\u002Fnginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。\n.\u002Fnginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。\n```\n查询nginx进程：\n\n```bash\nps aux|grep nginx\n```\n七、重启nginx\n\n1.先停止再启动（推荐）：\n\n对 nginx 进行重启相当于先停止再启动，即先执行停止命令再执行启动命令。如下：\n\n```bash\n.\u002Fnginx -s quit\n.\u002Fnginx\n```\n\n2.重新加载配置文件：\n\n当 ngin x的配置文件 nginx.conf 修改后，要想让配置生效需要重启 nginx，使用-s reload不用先停止 ngin x再启动 nginx 即可将配置信息在 nginx 中生效，如下：\n\n```bash\n.\u002Fnginx -s reload\n```\n\n启动成功后，可以在浏览器看到 welcome to nginx\n\n八、设置开机自启动\n\n即在rc.local 增加启动代码就行\n\n```bash\n vi \u002Fetc\u002Frc.local\n```\n\n在最后添加代码：\n\n```bash\n \u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx\n```\n\n设置执行权限\n\n```bash\n chmod 755 rc.local\n```\n安装php-fpm\n\nNginx本身不能处理PHP，作为web服务器，当它接收到请求后，不支持对外部程序的直接调用或者解析，必须通过FastCGI进行调用。\n\n如果是PHP请求，则交给PHP解释器处理，并把结果返回给客户端。PHP-FPM是支持解析php的一个FastCGI进程管理器。\n\n提供了更好管理PHP进程的方式，可以有效控制内存和进程、可以平滑重载PHP配置。\n\n一、安装依赖包\n\n```bash\nyum install libmcrypt libmcrypt-devel mhash mhash-devel libxml2 libxml2-devel bzip2 bzip2-devel\n```\n二、安装php\n\n1、下载安装包\n```bash\n地址：http:\u002F\u002Fwww.php.net\u002Fdownloads.php\n```\n2、解压安装包\n\n```bash\ntar xvf php-7.2.5.tar.bz2 -C \u002Fvar\u002Fsrc\n```\n3、配置\n\n```bash\ncd \u002Fvar\u002Fsrc\u002Fphp-7.2.5\n.\u002Fconfigure --prefix=\u002Fusr\u002Flocal\u002Fphp7 \\\n--with-config-file-scan-dir=\u002Fetc\u002Fphp.d \\\n--with-config-file-path=\u002Fetc \\\n--with-mysql=\u002Fusr\u002Flocal\u002Fmysql \\\n--with-mysqli=\u002Fusr\u002Flocal\u002Fmysql\u002Fbin\u002Fmysql_config \\\n--enable-mbstring \\\n--with-freetype-dir \\\n--with-jpeg-dir \\\n--with-png-dir \\\n--with-zlib \\\n--with-libxml-dir=\u002Fusr \\\n--with-openssl \\\n-enable-xml \\\n--enable-sockets \\\n--enable-fpm \\\n--with-mcrypt \\\n--with-bz2\n```\n4、编译安装\n\n```bash\nmake && make install\n```\n5、添加php和php-fpm配置文件\n\n```bash\ncp \u002Fusr\u002Flocal\u002Fsrc\u002Fphp-7.2.5\u002Fphp.ini-production \u002Fetc\u002Fphp.ini\ncd \u002Fusr\u002Flocal\u002Fphp7\u002Fetc\u002F\ncp php-fpm.conf.default php-fpm.conf\nsed -i 's@;pid = run\u002Fphp-fpm.pid@pid = \u002Fusr\u002Flocal\u002Fphp7\u002Fvar\u002Frun\u002Fphp-fpm.pid@' php-fpm.conf\n```\n6、添加php-fpm启动脚本\n\n```bash\ncp \u002Fusr\u002Flocal\u002Fsrc\u002Fphp-7.2.5\u002Fsapi\u002Ffpm\u002Finit.d.php-fpm \u002Fetc\u002Finit.d\u002Fphp-fpm\nchmod +x \u002Fetc\u002Finit.d\u002Fphp-fpm\n```\n7、添加php-fpm至服务列表并设置开机自启\n\n```bash\nchkconfig --add php-fpm     \nchkconfig --list php-fpm     \nchkconfig php-fpm on\n```\n8、启动服务\n\n```bash\nservice php-fpm start\n```\n三、配置nginx对fastcgi的支持\n1、备份默认的配置文件\n\n```bash\ncp \u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.conf.default \u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.conf\n```\n\n2、修改配置，支持php格式文件\n\n```bash\nvi \u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.conf\n```\n将如下代码的#号删除\n\n```bash\n#default_type  application\u002Foctet-stream;\n#log_format  main  '$remote_addr - $remote_user [$time_local] \"$request\" '\n#                  '$status $body_bytes_sent \"$http_referer\" '\n#                  '\"$http_user_agent\" \"$http_x_forwarded_for\"';\n#access_log  logs\u002Faccess.log  main;\n```\n将如下代码\n\n```bash\nlocation \u002F {\n    root   html;\n    index  index.html index.htm;\n}\n```\n改为：\n\n```bash\nlocation \u002F {\n    root   html;\n    index  index.php index.html index.htm;\n}\n```\n将如下代码改为\n\n```bash\n#location ~ \\.php$ {\n#    root           html;\n#    fastcgi_pass   127.0.0.1:9000;\n#    fastcgi_index  index.php;\n#    fastcgi_param  SCRIPT_FILENAME  \u002Fscripts$fastcgi_script_name;\n#    include        fastcgi_params;\n#}\n```\n改为：\n\n```bash\nlocation ~ \\.php$ {\n    root           html;\n    fastcgi_pass   127.0.0.1:9000;\n    fastcgi_index  index.php;\n    #fastcgi_param  SCRIPT_FILENAME  \u002Fscripts$fastcgi_script_name;\n    #include        fastcgi_params;\n    include         fastcgi.conf;\n}\n```\n重新载入nginx的配置文件\n\n```bash\ncd \u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\n.\u002Fnginx -s reload\n```\n浏览器测试效果\n\n在 \u002Fusr\u002Floacl\u002Fnginx\u002Fhtml新建index.php,内容如下\n\n```bash\n$conn=mysqi_connect('127.0.0.1','root','root');\nif ($conn){\n  echo \"LNMP platform connect to mysql is successful!\";\n}else{\n  echo \"LNMP platform connect to mysql is failed!\";\n}\nphpinfo();\n```\n在浏览器访问测试：\n\n可以输出php配置信息，则配置成功\n",null,0,485,"",1,"2019-01-17 22:33:20","2026-04-19 15:13:58",128,"Linux",{"id":23,"title":24},17,"URL设置原则",{"id":26,"title":27},19,"关闭apache自动目录列表功能的三种方法",[29,32,35,38,41],{"id":30,"name":31},35,"服务器",{"id":33,"name":34},36,"Nginx",{"id":36,"name":37},37,"Centos7",{"id":39,"name":40},25,"PHP",{"id":42,"name":43},26,"MySQL",3395,8,"https:\u002F\u002Ftp.myong.top\u002Fstorage\u002Farticle\u002F87\u002F675ea24d1392f61fb3cd682702835d.jpg",[48,53,58,63,68],{"id":49,"title":50,"create_time":51,"description":52},53,"Linux环境下Apahce的调优","2019-05-21 14:04:03","整理了部分有关Apahce调优的配置说明，后续陆续的将所有调优方式更新。",{"id":54,"title":55,"create_time":56,"description":57},50,"虚拟机安装Centos7后配置网络","2019-03-26 20:37:33","VMware虚拟机上安装min版的Centos7，并配置网络。虚拟机和centos7的安装在本文不做相关的介绍。",{"id":59,"title":60,"create_time":61,"description":62},85,"Linux环境PHP解压缩ZipArchive中的extractTo()方法，解压zip时文件丢失的问题","2020-04-30 17:17:44","在实际项目中要用ZipArchive解压ZIP文件，起初測试环境在Win环境中，測试通过，换到 LINUX 的环境中时  就出问题了（ZIP包中有文件和目录，包含带汉字的文件名称）\r\n\r\n问题的现象是：不带汉字的文件解压没有问题，另外有部分带汉字和数字字母的文件解压没有问题，然后其它纯文字的文件名称就丢失了，也没有报错，最后把问题定位到了extractTo()方法，这种方法是个封装的方法，看不到实际的源码。 \r\n\r\n经Google一番后，发现使用` getNameIndex `和` numFiles `",{"id":64,"title":65,"create_time":66,"description":67},78,"Centos7安装Docker","2019-12-28 14:17:23","### 安装docker\n\n安装命令\n\n``` bash\nyum install docker\n```\n\n启动docker并设置为开机启动\n\n``` bash\nservice docker start\nchkconfig docker on\n```\n\nLCTT 译注：此处采用了旧式的 sysv 语法，如采用CentOS 7中支持的新式 systemd 语法，如下：\n\n``` bash\nsystemcty start docker.service\nsystemcty enable docker.s",{"id":69,"title":70,"create_time":71,"description":72},21,"Cenos7.2下安装Apache2.4，MySQL5.7和PHP7.1","2019-01-17 22:48:15","一、主要软件：1、SecureCRT 5.1：是一款支持SSH（SSH1和SSH2）的终端仿真程序，简单地说是Windows下登录UNIX或Linux服务器主机的软件。2、WinSCP：是一个Windows环境下使用SSH的开源图形化SFTP客户端。同时支持SCP协议。它的主要功能就是在本地与远程计算机间安全的复制文件。winscp也可以链接其他系统,比如linux系统。以上两款软件的具体使用可以通过搜索引擎分分钟查到。",1783431671198]