欢迎光临
国外VPS主机测评和服务器分享!

Ubuntu系统安装与Nginx和php并配置环境

安装

  1. sudo apt-get install nginx

添加php源

  1. sudo add-apt-repository ppa:ondrej/php
  2. sudo apt-get update
  3. sudo apt-get upgrade

安装php

  1. 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

  1. sudo service php7.0-fpm start
  2. sudo service php7.0-fpm status

配置 nginx 服务器

  1. cd /etc/nginx/site-avaliabel
  2. sudo vim default
  3. -- 配置 www 目录
  4. root /mnt/c/www;
  5. -- 新加 index.php
  6. # Add index.php to the list if you are using PHP
  7. index index.html index.htm index.nginx-debian.html index.php;
  8. -- 打开注释
  9. -- location ~ \.php$
  10. -- include snippets/fastcgi-php.conf;
  11. -- fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; location ~ \.php$
  12. -- (要和 /etc/php/7.0/fpm/pool.d 中的 www.conf 中的 listen = /run/php/php7.0-fpm.sock 一致)
  13. # pass PHP scripts to FastCGI server
  14. #
  15. location ~ \.php$ {
  16. include snippets/fastcgi-php.conf;
  17. #
  18. # # With php-fpm (or other unix sockets):
  19. fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
  20. # # With php-cgi (or other tcp sockets):
  21. # fastcgi_pass 127.0.0.1:9000;
  22. }

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

  1. sudo nginx -t
  2. sudo service nginx restart

安装 mysql-server

  1. sudo apt-get install mysql-server-5.7
赞(0) 打赏
未经允许不得转载:魔方主机测评 » Ubuntu系统安装与Nginx和php并配置环境

评论 抢沙发

评论前必须登录!

 

登录

找回密码

注册