LNMP环境搭建(centos)
2018-08-13 本文已影响0人
lyhwbt
1. 安装nginx (默认网站目录 /usr/share/nginx/html)
yum install nginx
开启
nginx service nginx start 或者 nginx -s reload or systemctl restart nginx
解决nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)
sudo nginx -c /etc/nginx/nginx.conf
2.安装MYSQL
(见https://www.jianshu.com/p/7495c071e599)
yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum install mysql-community-server
//开启
mysql service mysqld start or systemctl restart mysqld
//查看mysql的root账号的密码
more /var/log/mysqld.log
//登录mysql mysql -u root -p
//修改密码
set password=password('Qwer.123456');
//修改root用户可远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Qwer.123456' WITH GRANT OPTION;
//立即生效
flush privilege
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
//安装php-fpm
yum install -y php71w-fpm
//开启服务
service php-fpm start or systemctl restart php-fpm
//修改
/etc/nginx/nginx.conf
//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;
}
}
}
//重启
nginx service nginx restart 或者 nginx -s reload