LNMP环境搭建

127 阅读1分钟
  1. 安装nginx yum install nginx

##开启

nginx service nginx start 或者 nginx -s reload

2.安装MYSQL yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

yum install mysql-community-server

//开启

mysql service mysqld start

//查看mysql的root账号的密码

more /var/log/mysqld.log

//登录mysqlmysql -uroot -p

//修改密码

set password=password('Lyhwbt.052336');

//修改root用户可远程登录

GRANT  ALL  PRIVILEGES  ON  .  TO  'root'@'%'IDENTIFIED  BY  'Lyhwbt.052336'  WITH GRANT OPTION;

//刷新(可能不需要)

flush privileges;

3.安装php 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

//查看

yum search php71w

//安装php以及扩展

yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath

//开启服务

service php-fpm start

//修改

/etc/nginx/nginx.conf

使其支持php 见下

//重启

nginxservice nginx restart 或者 nginx -s reload

//nginx配置文件

user nginx root;

worker_processes 2;

error_log /var/log/nginx/error.log crit;

#error_log logs/error.log notice;

#error_log logs/error.log info;

pid /run/nginx.pid;

events {

 worker_connections 2048;

}

http {

charset utf-8;

 root /www;

index index.php;

 include mime.types;

default_type application/octet-stream;

sendfile on;

keepalive_timeout 65;

server {

    listen 80;

     server_name 127.0.0.1;

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ \.php$ {

         root /www;

        fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

        include fastcgi.conf;

    }

}

}