lnmp yum安装搭建

准备工作

自行下载安装centos7 mini

注意

cenos7 默认安装mariadb而不是mysql
先开启网络!!

安装步骤

安装mariadb

通过yum在线安装:
1、yum -y  install mariadb-server mariadb mariadb-devel
    或yum install mariadb mariadb-server
2、systemctl start mariadb启动
3、systemctl enable mariadb  开机自启动
4、mysql_secure_installation  设置 root密码等相关
5、firewall-cmd --permanent --add-service mysql 防火墙加入mysql
6、systemctl restart firewalld.service  重启防火墙
7、iptables -L -n|grep 3306   查看防火墙又没开放3306
8、msyql -uroot -p  连接mysql
9、show databases;  查看数据库
设置数据库远程访问
1、mysql -uroot -p;链接数据库
2、use mysql; 选择数据库
3、grant all privileges on *.* to ‘root’@'%' identified by 'root';
4、flush privileges; 刷新权限

安装nginx

1、 rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-
   7-0.el7.ngx.noarch.rpm
2、 yum install nginx
3、systemctl start nginx.service
4、systemctl enable nginx.service
5、防火墙开启80端口firewall-cmd --zone=public --add-port=80/tcp --permanent
6、systemctl restart firewalld.service重启防火墙
7、systemctl start nginx.service

配置nginx

1、cp nginx.conf nginx.conf.origin
2、vim /etc/nginx/nginx.conf:
user  nginx;
worker_processes  1;
sendfile        on;
tcp_nopush     on;
//keepalive_timeout  0;
keepalive_timeout  65;
gzip  on;
index   index.php index.html index.htm;
3、cd /etc/nginx/conf.d               
4、cp default.conf default.conf.origin
5、vim default.conf:
location / {
root   /usr/share/nginx/html;
index  index.php index.html index.htm;
      }
location ~ \.php$ {
#   root           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;
}
6、systemctl start  php-fpm.service
7、systemctl enable php-fpm.service
8、systemctl restart nginx.service
  9、cd /usr/share/nginx/html/
10、vim index.php:
<?php
…………;
?>

安装php

1、rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
2、http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
3、yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
4、yum install --enablerepo=remi --enablerepo=remi-php56 php       php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt     php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof        php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process         php-gd php-common
5、php -v 显示版本

配置php

1、vi /etc/php.ini #编辑
2、date.timezone = PRC #把前面的分号去掉,改为date.timezone = PRC
3、expose_php = Off #禁止显示php版本的信息
4、short_open_tag = ON #支持php短标签
5、open_basedir = .:/tmp/  #设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题(例如:织梦内容管理系统),可以注销此行,或者直接写上程序的目录/data/www.osyunwei.com/:/tmp/
6、:wq! #保存退出
7、systemctl restart mariadb.service #重启MariaDB
8、systemctl restart httpd.service #重启

请关注我的订阅号

订阅号.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码哥说

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值