lnmp环境

1、准备一台服务器

192.168.52.35

2、关闭防火墙

systemctl stop firewalld

setenforce 0

3、上传nginx包并解压

[root@localhost ~]# ls
anaconda-ks.cfg  nginx-1.16.1  nginx-1.16.1.tar.gz  original-ks.cfg

4、安装nginx依赖环境

yum -y install gcc gcc-c++ pcre-devel  zlib-devel

5、解压nginx,编译,安装

cd /nginx-1.161      ./configure  && make &&  make install

6、配置nginx文件

vim /usr/local/nginx/conf/nginx.conf


    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.php index.html index.htm;     #添加index.php
        }

将这几行的注释去掉   CTRL+V  方向键下拉+D
       location ~ \.php$ {
           root           html;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME          
                $document_root$fastcgi_script_name;   #将这行改动$document_root
           include        fastcgi_params;
       }

7、启动nginx

/usr/local/nginx/sbin/nginx

8、安装lnmp环境

yum -y install mariadb mariadb--server php php-gd php-mysql php-fpm

9、启动php-fpm

systemctl start php-fpm

10、编写PHP测试页面

[root@localhost ~]# vim /usr/local/nginx/html/index.php
[root@localhost ~]# cat /usr/local/nginx/html/index.php
<?php
phpinfo();
?>
[root@localhost ~]# 

11、重新挂载nginx

/usr/local/nginx/sbin/nginx -s reload

12、lnmp环境搭建完成

posted @ 2019-12-19 16:01  Zsecret  阅读(140)  评论(0编辑  收藏  举报