• 实现LNMP


    实现LNMP

    环境:

    	linux系统机器
    		A:一台N:nginx,ip:192.168.213.251
    		B:一台P:php-fpm,php-mysql ,ip:192.168.213.253
    		C:一台M:mysql or mariadb,ip:192.168.213.254
            连接方式:
                        A <------------> B <-----------> C
    	关闭防火墙
    	disable掉selinux
    

    1.在A上安装和配置nginx

    	yum install nginx
    	cd /etc/nginx
    	cp nginx.conf nginx.conf.bak
    	vim nginx.conf
    		在server中添加
    		index index.php ;
    		location ~* .php$ {
    			fastcgi_pass 192.168.213.254:9000;
    			fastcgi_param SCRIPT_FILENAME /var/www/html/php$fastcgi_script_name;
    			include fastcgi_params;
    		}
    		location  ~ ^/(status|ping)$ {
    			fastcgi_pass 192.168.213.254:9000;
    			fastcgi_param SCRIPT_FILENAME /var/www/html/php$fastcgi_script_name;
    			include fastcgi_params;
    		}
    	nginx -t
    	systemctl start nginx
    

    2.在B上安装和配置php-fpm,php-myql

    	yum install php-fpm php-myql
    	vim /etc/php-fpm.d/www.conf
    		listen=9000
    		listen.allowed_clients = 127.0.0.1,192.168.213.251
    		pm.status_path = /status  #用于查看php-fpm状态
    		ping.path = /ping
    		ping.response = pong
    

    3.在C上安装和配置mysql 数据库

    	yum install mysql mysql-server mysql-libs
    	chkconfig mysqld on
    	chkconfig --list mysqld
    	service mysqld start
    	service mysqld status
    	/usr/bin/mysql_secure_installation  #根据需求进行配置
    	mysql -uroot -pxm1234
    	mysql>create user "shenxm"@'%' identified by 'xm1234';
    

    4.测试

    	在B上找个目录,存放数据。
    	cd /var/www/html/php
    	vim index.php
    		<?php
    			echo date("Y/m/d h:i:s");
    			$mysqli=new mysqli("192.168.213.253","shenxm","xm1234");
    			if(mysqli_connect_errno()){
    			echo "not ok!";
    			$mysqli=null;
    			exit;
    			}
    			echo "ok.o....kkkk!!!";
    			$mysqli->close();
    			phpinfo();
    		?>
    	在浏览器上
    		http://192.168.213.251/index.php #会有是否ok的显示
    		http://192.168.213.251/ping  #会显示pong的恢复
    		http://192.168.213.251/status  #会有状态信息显示
    

    5.实现fastcgi缓存

    	在A上
    		cd /etc/nginx
    		vim nginx.conf
    			在http中添加:
    				fastcgi_cache_path /var/cache/nginx/fcgi_cache levels=1:2:1 keys_zone=fcgicache:20m inactive=120s;
    			在server中location ~* .php$中补充:
    				fastcgi_cache fcgicache;
    				fastcgi_cache_key $request_uri;
    				fastcgi_cache_valid 200 302 10m;
    				fastcgi_cache_valid 301 1h;
    				fastcgi_cache_valid any 1m;
    	测试:
    		ab -c 100 -n 2000 http://192.168.213.251/index.php 
    	可以把fastcgi_cache 关掉在测试下
    		修改配置文件nginx.conf ,把“fastcgi_cache fcgicache;”改为“fastcgi_cache off;”,然后在测试。
    
  • 相关阅读:
    Linux 下的dd命令使用详解
    理解Linux的inode
    2021.11.11
    转一篇DLL逆向的文章,适用于一般的dll逆向
    关于Exchange DSAccess组件目录检测机制
    一些KB
    Inside of my heart
    C/C++是程序员必须掌握的语言吗?
    一个自动检测并安装hotfix的脚本
    VC++中DLL的创建和使用
  • 原文地址:https://www.cnblogs.com/shenxm/p/7751188.html
Copyright © 2020-2023  润新知