Ubuntu下php+mysql+nginx安装

1,更新源

sudo apt update
sudo apt upgrade

2,安装nginx

sudo apt install nginx
sudo service nginx start

使用浏览器访问Ip地址,返回Welcome to nginx!

3,安装mysql

sudo apt install  mysql-server

4,安装php

sudo apt install php php-fpm php7.2-mysql
cd  /etc/nginx/sites-available/

5,配置多端口

cd /etc/nginx/sites-available/swoole

ln /etc/nginx/sites-available/swoole /etc/nginx/sites-enabled/swoole

6,MySQL

如果密码忘了可以执行如下命令来重设密码

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

第一步:在/etc/mysql/my.cnf下找到bind-address = 127.0.0.1

在这行前加个"#"进行注释,或者改为:bind-address = 0.0.0.0允许任意IP访问;或者指定自己需要远程访问的IP地址。

然后重启

mysql:sudo /etc/init.d/mysql restart

grant all privileges on  库名.表名  to   '用户名'@'IP地址'   identified  by  '密码'  with   grant  option;

flush privileges;

grant all privileges on *.* to root@"%"identified by "password"with grant option;

flush privileges;

你可能感兴趣的:(Ubuntu下php+mysql+nginx安装)