lnmp部署

标签:multi   连接   int   lnmp   comm   isa   install   none   ted   

目录
  • lnmp部署
    • nginx编译安装
    • mariadb安装
    • php安装
  • lnmp配置
    • php配置
    • nginx配置
  • 测试
    • 开启服务
    • 测试

lnmp部署

nginx编译安装

  • nginx编译安装

mariadb安装

##安装mariadb
[root@vm3 ~]# yum -y install mariadb mariadb-server
##修改mariadb密码
[root@vm3 ~]# mysql 
MariaDB [(none)]> set password=password("123456");
Query OK, 0 rows affected (0.002 sec)

php安装

[root@vm3 ~]# yum list all | grep php-*
php.x86_64                                             7.2.24-1.module_el8.2.0+313+b04d0a66             @AppStream
php-bcmath.x86_64                                      7.2.24-1.module_el8.2.0+313+b04d0a66             @AppStream
php-cli.x86_64                                         7.2.24-1.module_el8.2.0+313+b04d0a66             @AppStream
php-common.x86_64                                      7.2.24-1.module_el8.2.0+313+b04d0a66             @AppStream
php-dba.x86_64                                         7.2.24-1.module_el8.2.0+313+b04d0a66             @AppStream
................................................
[root@vm3 ~]# yum -y install php-* php

lnmp配置

php配置

  • /etc/php-fpm.d/www.conf
[root@vm3 ~]# vim /etc/php-fpm.d/www.conf
.................................................
user = nginx
group = nginx
listen = 127.0.0.1:9000
.................................................
  • 创建php文件
[root@vm3 ~]# cd /usr/local/nginx/html/
[root@vm3 html]# ls
50x.html  index.html  index.php  mysql.php
[root@vm3 html]# cat index.php 
<?php 
  phpinfo();
?>
[root@vm3 html]# cat mysql.php 
<?php
  $link=mysqli_connect("127.0.0.1","root","123456");
  if($link) echo "数据库连接成功!";
  mysqli_close($link);
?>

nginx配置

[root@vm3 ~]# cd /usr/local/nginx/conf/
[root@vm3 conf]# ls
fastcgi.conf            koi-utf             nginx.conf           uwsgi_params
fastcgi.conf.default    koi-win             nginx.conf.default   uwsgi_params.default
fastcgi_params          mime.types          scgi_params          win-utf
fastcgi_params.default  mime.types.default  scgi_params.default
[root@vm3 conf]# vim nginx.conf
...............................
http{
    ........................
    server{
        listen 80;
        server_name  localhost;
        ..............................
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}

测试

开启服务

[root@vm3 ~]# systemctl enable --now mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@vm3 ~]# systemctl enable --now php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
[root@vm3 ~]# nginx -s reload -c /usr/local/nginx/conf/nginx.conf
[root@vm3 ~]# ss -antl 
State         Recv-Q        Send-Q               Local Address:Port               Peer Address:Port        
LISTEN        0             128                        0.0.0.0:80                      0.0.0.0:*           
LISTEN        0             128                        0.0.0.0:22                      0.0.0.0:*           
LISTEN        0             128                      127.0.0.1:9000                    0.0.0.0:*           
LISTEN        0             128                           [::]:22                         [::]:*           
LISTEN        0             80                               *:3306                          *:*           

测试

技术图片

技术图片

  • 统计logs/access.log日志文件访问最多的ip
[root@vm3 ~]# awk ‘{print $1}‘ /usr/local/nginx/logs/access.log | sort | uniq -c | sort -nr -k1 | head -n 3
     27 192.168.225.128
     15 192.168.225.130
     10 192.168.225.127
[root@vm3 ~]# awk ‘{print $1}‘ /usr/local/nginx/logs/access.log | sort | uniq -c | sort -nr -k1 | head -n 4
     27 192.168.225.128
     15 192.168.225.130
     10 192.168.225.127
     10 192.168.225.1
[root@vm3 ~]# awk ‘{print $1}‘ /usr/local/nginx/logs/access.log | sort | uniq -c | sort -nr -k1 | head -n 1
     27 192.168.225.128

lnmp部署

标签:multi   连接   int   lnmp   comm   isa   install   none   ted   

原文地址:https://www.cnblogs.com/fyjpeng/p/14165540.html

版权声明:完美者 发表于 2020-12-25 12:22:47。
转载请注明:lnmp部署 | 完美导航

暂无评论

暂无评论...