LNMP搭建

来源:互联网 发布:手机爱淘宝1元口令 编辑:程序博客网 时间:2024/04/28 17:14

网络自启动:

1、 ifconfig查看网络设备号eno-xxxxxx

2、 cd /etc/sysconfig/network-scripts/

3、 ls

4、 vim /ifcfg-eno16777736

5、 ONBOOT=yes

OK

 

安装mysql

cenos7 默认安装mariadb而不是mysql

先开启网络!!

1、通过yum在线安装:

   1yum -y  install mariadb-server mariadb mariadb-devel

      yum install mariadb mariadb-server

   2systemctl start mariadb启动

   3systemctl enable mariadb  开机自启动

   4mysql_secure_installation  设置root密码等相关

   5firewall-cmd --permanent --add-service mysql防火墙加入mysql

   6systemctl restart firewalld.service  重启防火墙

   7iptables -L -n|grep 3306   查看防火墙又没开放3306

   8msyql -uroot -p  连接mysql

   9show databases;  查看数据库

2、设置数据库远程访问

   1mysql -uroot -p;链接数据库

   2use mysql;选择数据库

   3grant all privileges on *.* to‘root’@'%' identified by 'root';

   4flush privileges;刷新权限

3、安装nginx

   1rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-

       7-0.el7.ngx.noarch.rpm

   2yum install nginx

   3systemctl start nginx.service

   4systemctl enable nginx.service

   5、防火墙开启80端口firewall-cmd --zone=public --add-port=80/tcp --permanent

   6systemctl restart firewalld.service重启防火墙

   7systemctl start nginx.service

4、安装php 5.6

   1rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/7/x86_64/e/

      epel-release-7-5.noarch.rpm

   2http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

   3yum list --enablerepo=remi --enablerepo=remi-php56 | grep php

   4yum 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
   5php -v 显示版本

 

 5、配置nginx

      1cp nginx.conf nginx.conf.origin

      2vim /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;

      3cd /etc/nginx/conf.d

      4cp default.conf default.conf.origin

      5vim 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;

}

      6systemctl start  php-fpm.service

      7systemctl enable php-fpm.service

      8systemctl restart nginx.service

    9cd /usr/share/nginx/html/

      10vim index.php

<?php

…………;

?>

     6、配置php

       1vi /etc/php.ini #编辑

       2date.timezone = PRC #把前面的分号去掉,改为date.timezone = PRC

       3expose_php = Off #禁止显示php版本的信息

       4short_open_tag = ON #支持php短标签

       5open_basedir = .:/tmp/  #设置表示允许访问当前目录(PHP脚本文件所在之目   )/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题(例如:织梦内容管理系统),可以注销此行,或者直接写上程序的目录      /data/www.osyunwei.com/:/tmp/

       6:wq! #保存退出

       7systemctl restart mariadb.service #重启MariaDB

       8systemctl restart httpd.service #重启apache

0 0
原创粉丝点击