LNMP单机架构

1.创建用户

groupadd www -g 666
useradd www -s /sbin/nologin -M -u 666 -g 666

2.安装nginx

yum install nginx -y

3.下载第三方软件仓库,解决一些依赖

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

#此时就是多出来几个仓库
[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo       epel.repo              epel.repo.rpmnew       epel-testing.repo      webtatic-archive.repo  webtatic.repo          webtatic-testing.repo  

4.安装php7依赖

yum install -y php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml  php71w-fpm  php71w-mysqlnd  php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb php71w-json php71w-pecl-apcu php71w-pecl-apcu-devel

5.修改权限

[root@localhost ~]# grep -E '^(user|group)' /etc/php-fpm.d/www.conf 
user = www
group = www
[root@localhost ~]# grep -E ^user /etc/nginx/nginx.conf
user www;

6.安装mysql

[root@localhost ~]# yum install mariadb mariadb-server -y
[root@localhost ~]# mysqladmin -uroot password '1'

7.重启

[root@localhost ~]# systemctl restart php-fpm
[root@localhost ~]# systemctl restart nginx
[root@localhost ~]# systemctl restart mariadb

8.更改nginx配置文件

[root@localhost code]# cat /etc/nginx/conf.d/x.conf 
server {
   

  listen 80;
  server_name 192.168.23.100;
 root /www;
 index index.html index.php;

#动态资源请求
 location ~ \.php$ {
   
  root /code;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
} 
}

9.做php测试代码

[root@localhost code]# cat /code/test-phpinfo.php 
<?php
phpinfo();
echo "welcome to website"
?>

10.重启nginx

systemctl restart nginx

11.测试

在这里插入图片描述

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-01-29 11:12:03       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-29 11:12:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-29 11:12:03       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-29 11:12:03       20 阅读

热门阅读

  1. Linux 链接 GitHub 出现 Connection timed out

    2024-01-29 11:12:03       41 阅读
  2. 第十四章认识Ajax(五)

    2024-01-29 11:12:03       34 阅读
  3. 正则表达式在前端中的使用

    2024-01-29 11:12:03       36 阅读
  4. C++从零开始的打怪升级之路(day24)

    2024-01-29 11:12:03       36 阅读
  5. COMM394 Coding Literacy for Managers

    2024-01-29 11:12:03       30 阅读
  6. docker入门 问题一

    2024-01-29 11:12:03       39 阅读
  7. 状态管理与导航守卫

    2024-01-29 11:12:03       33 阅读