Every day to be a little better

centos6.5 LNMP环境安装

mysql5.7

  • 安装mysql yum源
wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum install mysql-community-release-el6-5.noarch.rpm
  • 安装msqyl
  • 选择启用mysql5.7
vi /etc/yum.repos.d/mysql-community.repo
## 找到5.7 修改 enable=1
yum install mysql-community-server
  • 启动mysql
service mysqld start
  • 开机启动
chkconfig --list | grep mysqld
chkconfig mysqld on
  • 设置默认编码
vim /etc/my.cnf
[mysqld]
character-set-server=utf8 ### 加上这句
  • 重启mysql
service mysqld restart

安装php7.0

  • 添加yum源
    rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
    rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
  • 安装php
     yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64  php70w-pdo.x86_64   php70w-mysqlnd  php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongo
  • 启动
service php-fpm start
chkconfig php-fpm on

安装nginx

  • 安装
yum install nginx 
service nginx start
chkconfig nginx on
  • 配置
cd /etc/nginx/nginx.conf /etc/nginx/nginx.conf_bak
## nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections  1024;
}


http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
}
  • default.conf
## vi /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
        root  /usr/share/nginx/html;
        index index.php index.html index.htm ;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

    location ~ \.php$ {
         root           /usr/share/nginx/html;
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
         include        fastcgi_params;
    }
}
  • 测试
## vi /usr/share/nginx/html/test.php
<?php
phpinfo();

未经允许不得转载:奇葩菌博客 » centos6.5 LNMP环境安装

分享到:更多 ()