LNMP是Linux、Nginx、MySQL、PHP的缩写,是指在Linux环境下由Nginx、MySQL、PHP构建的Web后台运行环境,是一种流行先进、便捷轻便、高性能的一后台环境。
我们今天介绍如何在支持yum源安装的系统上部署LNMP环境。
Nginx安装和启动
安装
yuminstallnginx
启动和停止
servicenginxstartservicenginxstop#或者systemctlstartnginxsystemctlstopnginx
目录位置
运行文件: /usr/sbin/nginx
配置文件目录: /etc/nginx
日志文件目录: /var/nginx
MySQL安装
参见文档:
/livestreaming/2128571
PHP安装
参见文档:
/livestreaming/2092166
/livestreaming/2092162
Nginx配置支持PHP
以下配置打epoll、sendfile,可以多更好的并发和静态文件响应性能。
#使用deamon用户运行,注意对应目录的读写权限设置。userdaemon;#开启四个进程worker_processes4;worker_rlimit_nofile5120;events{useepoll;worker_connections5000;}http{includemime.types;#default_typeapplication/octet-stream;access_logoff;#文件缓存优化open_file_cachemax=2000inactive=60s;open_file_cache_valid60s;open_file_cache_min_uses2;open_file_cache_errorson;output_buffers232k;client_max_body_size1m;keepalive_timeout65;server{listen80;server_namelocalhost;charsetutf-8;sendfileon;root/var/www/;indexindex.phpindex.htmlindex.htm;error_page500502503504404403/error.html;location~\.php${fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;}}}