Centos6.5 安装LNMP环境
Centos6.5 安装LNMP环境
Alexmysql5.7
- 安装mysql yum源
1
2wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum install mysql-community-release-el6-5.noarch.rpm - 安装msqyl
- 选择启用mysql5.7
1
2vi /etc/yum.repos.d/mysql-community.repo
## 找到5.7 修改 enable=11
yum install mysql-community-server
- 启动mysql
1
service mysqld start
- 开机启动
1
2chkconfig --list | grep mysqld
chkconfig mysqld on - 设置默认编码
1
2
3vim /etc/my.cnf
[mysqld]
character-set-server=utf8 ### 加上这句 - 重启mysql
1
service mysqld restart
安装php7.0
- 添加yum源
1
2rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm - 安装php
1
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
- 启动
1
2service php-fpm start
chkconfig php-fpm on
安装nginx
- 安装
1
2
3yum install nginx
service nginx start
chkconfig nginx on - 配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36cd /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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30## 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;
}
}- 测试
1
2
3## vi /usr/share/nginx/html/test.php
<?php
phpinfo();