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 


10.重启nginx

systemctl restart nginx

11.测试

LNMP单机架构_第1张图片

你可能感兴趣的:(架构,服务器,linux,运维)