美文网首页
ubuntu16.04安装nginx,mysql,php

ubuntu16.04安装nginx,mysql,php

作者: 运维大湿兄 | 来源:发表于2018-08-07 11:45 被阅读0次

安装nginx

$ sudo apt-get update
$ sudo apt-get install nginx

ubuntu 安装nginx,默认配置如下

 #location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php7.0-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php7.0-fpm:
        #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        #}

安装mysql

$ sudo apt-get install mysql-server

To secure the installation, we can run a simple security script that will ask whether we want to modify some insecure defaults. Begin the script by typing:

$ mysql_secure_installation

注意:此步是做一些安全配置,可以不执行。比如VALIDATE PASSWORD PLUGIN,设置密码复杂度等。

默认启动监听是127.0.0.1地址。可以注释掉

# vim /etc/mysql/mysql.conf.d/mysqld.cnf
    #bind-address           = 127.0.0.1

安装PHP

$ sudo apt-get install php-fpm php-mysql

默认安装是PHP7.0版本,此版本cgi.fix_pathinfo已发现有漏洞。需更改配置

$ sudo vim /etc/php/7.0/fpm/php.ini
找到cgi.fix_pathinfo此行
更改为cgi.fix_pathinfo=0
然后重启php
$ sudo systemctl restart php7.0-fpm

php-fpm 启动默认是监听socket文件,链接PHP也只能通过sock文件链接。需要更改为端口

找到/etc/php/7.0/fpm/pool.d/www.conf

;listen = /run/php/php7.0-fpm.sock
listen = 127.0.0.1:9000

配置nginx链接PHP

$ vim /etc/nginx/conf.d/test.conf

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name server_domain_or_IP;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass 127.0.0.1:9000;
    }
}

$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ nginx -s reload


编辑/var/www/html/info.php

<?php
phpinfo();
?>

访问http://ip:port/info.php
出现下图正常

[站外图片上传中...(image-5e8700-1533613517538)]

正常后删除

$ sudo rm /var/www/html/info.php

相关文章

  • Ubuntu下安装Lnmp

    环境:Ubuntu16.04(阿里云) Lnmp需要安装的3个软件:Nginx、Mysql、PHP(python或...

  • LEMP环境配置

    Ubuntu16.04 + Nginx + MariaDB + PHP7 nginx安装 查看nginx安装状态 ...

  • 编译安装LNMP

    编译安装nginx 编译安装PHP 配置Nginx+PHP 安装MySQL

  • 编译安装LNMP2

    编译安装nginx 编译安装PHP 配置Nginx+PHP 安装MySQL

  • centos7 部署zabbix

    安装 mysql,php,nginx yum 安装mysql,php,nginx.配置php时我的php总是会出现...

  • Centos安装nginx

    先安装nginx 软件源 安装nginx、php、php-fpm、php-mysql 启动nginx php-fp...

  • WordPress

    安装Nginx 测试Nginx 安装MySQL 安装PHP 配置PHP,修改php.ini文件 启动php-fpm...

  • lnmp环境搭建

    安装nginx 安装php 7.0 安装php-fpm 安装mysql

  • Ubuntu 安装LAMP

    PHP7 Mysql5.6 nginx安装 配置PHP Nginx

  • Swoft环境搭建

    系统环境:Ubuntu16.04 1,安装PHP7.2; 2,安装PHP7.2模块; 3,安装Nginx; 4,安...

网友评论

      本文标题:ubuntu16.04安装nginx,mysql,php

      本文链接:https://www.haomeiwen.com/subject/apmovftx.html