ubuntu部署php7.1
来源:互联网 发布:云笔记 linux 编辑:程序博客网 时间:2024/04/27 23:51
先更新本机内置的程序。
sudo apt-get updatesudo apt-get upgrade
再判断系统是否内置了add-apt-repository命令,如果没有执行下列命令安装
sudo apt-get install software-properties-common
git
安装一下git程序,很多地方会用到
sudo apt-get install git
设置一下自己的git名字和邮箱
git config --global user.name "你的名字或昵称"git config --global user.email "你的邮箱"
php
添加最新php的源,然后安装php
sudo add-apt-repository ppa:ondrej/phpsudo apt-get updatesudo apt-get install php7.1 php7.1-common php7.1-fpm php7.1-dev sudo apt-get install php7.1-mbstring php7.1-xml
安装结束之后就可以执行php -i命令查看到php-cli的信息
不过要配合nginx的话,需要用php-fpm来管理php的进程。
service php7.1-fpm startservice php7.1-fpm stopservice php7.1-fpm restart
安装 MySQL 5.7
安装 MySQL 运行命令:
apt-get -y install mysql-server mysql-client
你会被要求提供MySQL的root用户密码 :
New password for the MySQL “root” user: <– yourrootsqlpasswordRepeat password for the MySQL “root” user: <– yourrootsqlpasswor
nginx
直接安装nginx
sudo apt-get install nginx
nginx的操作命令如下:
service nginx startservice nginx stopservice nginx restart
查看nginx使用的config配置文件或者软重启的命令是
nginx -tnginx -s reload
一般配置文件在/etc/nginx目录下。
不过要配置一个新的网站,不需要在nginx.conf里添加,只需要在sites-enabled文件夹下加一个对应文件即可(文件名随意)
cd /etc/nginx/sites-enabledtouch demo
上面的demo文件是随便命名,用vi打开
vim demo
然后添加下面的内容
server { listen 80; server_name demo.com; root /home/www/demo/public; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/run/php/php7.1-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}
解释一下上面的配置:
- 独立的一个服务器配置需要用server{}包裹起来
- listen 80表示监听80端口,也就是http访问的默认端口,其它端口在浏览器上需要输入端口号。
- server_name表示绑定的是哪个域名。
- root表示该域名访问到路径对应的实际文件夹
- index表示域名的path为空的时候对应访问哪个文件,默认都是index.html、index.htm和index.php
- location /这里是对所有路径做路由重写,里面的try_files $uri $uri/ /index.php?$query_string;是laravel框架的路径重写配置。
- location ~ \.php$是指访问所有后缀名带.php的路径时候,需要执行的操作,这里也就是配置php的fastcgi
- fastcgi里的最重要部分是fastcgi_pass,它代表nginx服务器如何与php通信,这里的unix:/run/php/php7.1-fpm.sock;是php7.1-fpm启动后生成的套接字文件,可以和nginx通信。
阅读全文
0 0
- ubuntu部署php7.1
- ubuntu php7.1 安装curl
- ubuntu php7.1安装zip扩展
- ubuntu 安装 php7.1 的脚本
- Ubuntu下源码编译安装PHP7.1
- ubuntu 安装php7
- ubuntu安装php7
- ubuntu搭建php7环境
- Ubuntu Nginx+PHP7
- ubuntu 16.04 安装php7
- ubuntu nginx+php7+mysql
- ubuntu中安装php7
- Ubuntu 14.04 安装配置MySQL5.7 PHP7.1 Nginx1.10
- ubuntu上用apt安装php7.1的扩展
- Ubuntu 16.04.1搭建mantis服务器(基于php7.0)
- ubuntu 14.04 安装配置php7
- ubuntu apt-get 安装 php7
- ubuntu上编译安装php7
- CDN缓存小结
- 设计模式讲解与代码实践(二十)——观察者
- Execution failed for task ':app:transformClassesWithDexForRelease'.
- Android Retrofit2使用
- spring boot打jar包遇到错误
- ubuntu部署php7.1
- Excel操作数据库进行新增修改批量操作
- 第三项 zlib压缩与base64解压
- test
- APP中集成移动端车牌识别需要注意哪些?
- angularJs简介
- PHP中MySQL、MySQLi和PDO的用法和区别
- 自建flask server传送文件
- 我在VMware下装系统遇到的几个问题