centos7.4 install nginx1.21/php7.3/mysql5.7 做一些筆記玉组,逐個(gè)安裝有些麻煩,趕快用docker 容器來(lái)自動(dòng)部署。
install nginx1.21
centos7.4 install software
============ nginx1.21
yum install epel-release
yum install nginx
systemctl start nginx
systemctl status nginx
# 設(shè)置開機(jī)啟動(dòng)nginx
systemctl enable nginx
# 修改了nginx 的配置
nginx -t
nginx -s relaod 或者 systemctl reload nginx
install php7.3
============ php7.3
sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install epel-release yum-utils
sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php73
sudo yum -y install php php-cli php-fpm php-mysqlnd php-zip php-devel \
php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath \
php-json
php -v
# 安裝php 的擴(kuò)展
sudo yum install php-<entension-name>
systemctl enable php-fpm.service
systemctl status php-fpm.service
systemctl start php-fpm.service
systemctl stop php-fpm.service
# 重新加載配置, 別漏了reload這一步
systemctl reload php-fmp
systemctl restart php-fpm
install mysql5.7
============ mysql5.7
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install mysql-community-server
systemctl start mysqld.service
# 開機(jī)啟動(dòng)
systemctl enable mysqld.service
# 臨時(shí)密碼
grep "password" /var/log/mysqld.log
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'C7Q#6xxxxx';
接下來(lái)遷移項(xiàng)目代碼和數(shù)據(jù)庫(kù),如果細(xì)節(jié)處理不好盅安,由于數(shù)據(jù)量比較大别瞭,就會(huì)很浪費(fèi)時(shí)間株憾。因此記錄一下:
遷移項(xiàng)目代碼
# 查看當(dāng)前目錄下各個(gè)file/directory size
du -ah --max-depth=1 | sort -h
# 忽略一些不用打包的問(wèn)題,加快打包時(shí)間
tar -zcf why_zhejiang.tar.gz --exclude=webroot/a/* --exclude=webroot/b/* webroot/
遷移數(shù)據(jù)庫(kù)
# 建議先到my.cnf 看數(shù)據(jù)存放目錄datadir=/disk/lib/mysql
cd /disk/lib/mysql
cd why
# 查看那個(gè)表最大墙歪,是否可以不遷移
du -ah --max-depth=1 | sort -h
# 開始
mysqldump -uroot -p$(cat /data/mysql/mysql_password) \
--socket=/var/lib/mysql/mysql.sock --single-transaction \
why >> why.sql
# 遷移到目標(biāo)庫(kù)
mysql -uroot -p$(cat /data/mysql/mysql_password) << EOF
< create database why DEFAULT CHARSET=utf8mb4;
< use why;
< source /data/tmp/why.sql
< EOF
# 為這個(gè)庫(kù)創(chuàng)建用戶
grant all on why.* to why_user@'localhost' identified by 'fffff-';
grant all on why.* to why_user@'127.0.0.1' identified by 'fffff-';
遷移定時(shí)任務(wù)
# work 用戶下
crontab -l >> work_crontab