2年前 把服务器上面的网站都转成docker了,最近需要单独部署一台国外服务器,下面就简单记录一下过程和问题吧。
- 阿里云ECS,1核1G
配置服务器
- 配置密钥登陆:公钥添加到
~/.ssh/authorized_keys
文件里。 - 生成部署公钥:
ssh-keygen -b 4096 -t rsa -C "Your Description Here"
- 更新系统:
apt update && apt upgrade -y
安装环境和软件:
apt install -y git zip unzip
apt install -y php7.4 php7.4-fpm php7.4-gd php7.4-json php7.4-mysql php7.4-odbc php7.4-opcache php7.4-xml php7.4-zip php7.4-imap php7.4-mbstring php7.4-soap php7.4-curl
apt install -y nginx wget
apt install -y mariadb-server-10.3
安装Composer:最新composer安装参考:https://getcomposer.org/download/ ```bash php -r “copy(‘https://getcomposer.org/installer‘, ‘composer-setup.php’);” php -r “if (hash_file(‘sha384’, ‘composer-setup.php’) === ‘756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;” php composer-setup.php php -r “unlink(‘composer-setup.php’);”
复制composer到可执行目录,以后可以方便全局使用
cp composer.phar /usr/local/bin/composer
配置镜像
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
<a name="xfFWK"></a>
# 启动服务
```bash
systemctl enable nginx.service
systemctl start nginx.service
systemctl enable php7.4-fpm.service
systemctl start php7.4-fpm.service
创建文件夹、克隆项目代码
composer安装依赖
composer install —no-dev
配置数据库
mysql_secure_installation
systemctl enable mariadb.service
systemctl start mariadb.service
其他
touch /run/php/php7.4-fpm.sock
chmod 777 /run/php/php7.4-fpm.sock
nginx 日志 目录: /var/log/nginx/error.log