《Linux-Ubuntu18.04环境搭建》

秦焱
2023-12-01

环境搭建
1、lnmp

nginx 
php-fpm 
mysql 新立得安装 外加扩展
php-curl
sudo apt install php-curl

2、ssh服务

sudo apt-get install openssh-server
sudo service ssh start

3、memcached

pecl install memcached 

sudo apt-get install php7.2-memcached
extension=memcached.so

4、swoole

phpize -v
pecl -V
sudo apt-get install php-pear

sudo apt-get install php7-dev
sudo apt-get install php-dev
sudo pecl install swoole
extension=swoole.so

5、git

sudo apt install git

6、bcscale

bcmul()需要用到bcscale函数,需要用到php-bcmath扩展
sudo apt-get update
sudo apt install php7.2-bcmath

【环境配置】
[服务安装]

sudo /etc/init.d/nginx start
sudo /etc/init.d/php7.2-fpm restart
sudo /etc/init.d/mysql start

[服务卸载]

sudo apt-get remove --purge nginx-\*
sudo apt-get remove --purge php-\*
sudo apt-get remove --purge mysql-\*

【mysql安装】
参考链接:
https://segmentfault.com/a/1190000014671905
https://www.cnblogs.com/super-zhangkun/p/9435974.html
https://blog.csdn.net/sinat_21302587/article/details/76870457
https://www.2cto.com/database/201710/691335.html

[安装服务]

1. sudo apt-get install mysql-server
2. sudo apt-get install mysql-client
3. sudo apt-get install libmysqlclient-dev

检查安装
ps aux|grep mysql

修改密码(安装服务时如不提示设置密码,请用以下方法)
sudo vim /etc/mysql/debian.cnf
[client]
host = localhost
user = debian-sys-maint
password = 8DcEiTOgEGEjDqyL
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = 8DcEiTOgEGEjDqyL
socket = /var/run/mysqld/mysqld.sock

默认登录(拷贝以上用户名、密码)
mysql -udebian-sys-maint -p8DcEiTOgEGEjDqyL

show databases;
use mysql;
update user set authentication_string=PASSWORD(“自定义密码”) where user=‘root’;
update user set plugin=“mysql_native_password”;
flush privileges;
quit;

重启服务
/etc/init.d/mysql restart;

再次登录
mysql -u root -p 密码;

ok

[mysql远程链接]
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 127.0.0.1,修改为:0.0.0.0或者注释掉

mysql -uroot -proot

user,password可以设置成自己的
GRANT ALL PRIVILEGES ON . TO ‘user’@‘%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;
#GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’ IDENTIFIED BY ‘root’ WITH GRANT OPTION;

FLUSH PRIVILEGES;

 类似资料: