Ubuntu Nginx php 安装与环境配置

安装

sudo apt-get install nginx
复制代码

添加php源

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
复制代码

安装php

sudo apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-curl php7.0-cli php7.0-mcrypt php7.0-mbstring php7.0-dom
复制代码

启动php

sudo service php7.0-fpm start
sudo service php7.0-fpm status
复制代码

配置 nginx 服务器

cd /etc/nginx/site-avaliabel
sudo vim default


-- 配置 www 目录
root /mnt/c/www;

-- 新加 index.php
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;

-- 打开注释
-- location ~ \.php$
-- include snippets/fastcgi-php.conf;
-- fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; location ~ \.php$
-- (要和 /etc/php/7.0/fpm/pool.d 中的 www.conf 中的 listen = /run/php/php7.0-fpm.sock 一致)

 # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }
复制代码

修改配置文件后,需要重新编译配置文件,检查是否配置成功,然后启动 nginx

sudo nginx -t
sudo service nginx restart
复制代码

安装 mysql-server

sudo apt-get install mysql-server-5.7

 

 

posted @ 2020-04-29 17:02  老三的博客  阅读(3727)  评论(0编辑  收藏  举报