ubuntu php 支持mysql_在ubuntu16.04上安装php7 mysql5.7 nginx1.10并支持http2
安裝nginx
首先更新軟件包 并且安裝nginx
sudo apt-get update
sudo apt-get install nginx
開放防火墻配置
sudo ufw allow 'Nginx HTTP'
查看防火墻狀態
sudo ufw status
------------------
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx HTTP ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx HTTP (v6) ALLOW Anywhere (v6)
訪問服務器看看nginx是否配置成功
http://server_domain_or_IP
2安裝mysql
sudo apt-get install mysql-server
安裝期間會配置數據庫的root密碼 而且默認的root賬戶不可以遠程登錄
如果密碼忘了可以執行如下命令來重設密碼
sudo mysql_secure_installation
如果需要遠程登錄mysql的root賬戶
可以執行
```
mysql -uroot -p
輸入root密碼 進入mysql命令行
執行mysql命令
mysql>use mysql;
mysql>update user set host = '%' where user =
'root';
mysql>select host, user from user;
然后重啟msql 就可以遠程root登錄了
service mysql restart
```
3安裝php
sudo apt-get install php-fpm php-mysql
配置php
sudo vim /etc/php/7.0/fpm/php.ini
修改cgi.fix_pathinfo為0,防止安全泄露
cgi.fix_pathinfo=0
保存關閉 ,重啟php
sudo systemctl restart php7.0-fpm
配置nginx 使用php
找到站點配置
sudo vim /etc/nginx/sites-available/default
大概修改成下面這樣,根據情況自行配置
```
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 / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
```
只需要保證?index配置有index.php?在location中有fastcgi_pass?并且配置正確就可以
檢查nginx配置
sudo nginx -t
重啟nginx
sudo systemctl reload nginx
當然 service也可以
service nginx restart
5添加php文件測試配置
sudo vim /var/www/html/info.php
添加下面代碼
總結
以上是生活随笔為你收集整理的ubuntu php 支持mysql_在ubuntu16.04上安装php7 mysql5.7 nginx1.10并支持http2的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql数据库恢复数据_【技术分享】使
- 下一篇: mysql insert 失败_mysq