##更新系統並安裝必要的軟體包
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install curl nano git
sudo apt install unzip
##安裝nginx和重啟
sudo apt-get install nginx
sudo systemctl start nginx
##php安裝
apt -y install software-properties-common apt-transport-https lsb-release ca-certificates
add-apt-repository ppa:ondrej/php
apt update
apt install php7.3-fpm php7.3-mysql php7.3-curl php7.3-gd php7.3-mbstring php7.3-xml php7.3-xmlrpc php7.3-zip php7.3-opcache php7.3-soap php7.3-bcmath php7.3-intl -y
##修改 php 配置檔案
sudo vim /etc/php/7.3/fpm/php.ini
sudo vim /etc/php/7.3/cli/php.ini
(編輯2個檔案中的
memory_limit = 2G
max_execution_time = 1800
zlib.output_compression = On
)
systemctl restart php7.3-fpm
##MYSQL 的安裝以及配置
sudo apt install -y mysql-server mysql-client
sudo service mysql start
sudo mysql_secure_installation(確保安裝 可不執行此命令)
mysql -u root -p
CREATE DATABASE magento2 CHARACTER SET utf8 COLLATE utf8_general_ci;
##以下 1 步在 ubuntu20.04- 版本下操作
GRANT ALL ON magento2.* TO magento@localhost IDENTIFIED BY 'Magento2020@';
##以下 2 步在 ubuntu20.04+ 版本下操作
CREATE USER 'magento'@'localhost' IDENTIFIED BY 'Magento2020@';
GRANT ALL PRIVILEGES ON magento2.* TO 'magento'@'localhost' WITH GRANT OPTION;
##必須執行,否則安裝 magento2 報錯
sudo mysql -e "ALTER USER 'magento'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Magento2020@'"
digitalstartup.co.uk/t/cant-instal...
FLUSH PRIVILEGES;
cd /var/www/
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/bin --filename=composer
composer create-project --repository=https://repo.magento.com/ magento/project-community-edition magento2
##magento2 官網獲取 user key
cd magento2
##新增使用者
adduser jx
##將使用者加入組
sudo usermod -a -G www-data jx
groups jx
cd /var/www/magento2
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
##賦予許可權
chown -R :www-data .
chmod u+x bin/magento
##安裝 magento2
php bin/magento setup:install --backend-frontname="admin" \
--base-url="http://域名" \
--base-url-secure="https://域名" \
--db-host=localhost \
--db-name=magento2 \
--db-user=magento \
--db-password='Magento2020@' \
--admin-firstname=J \
--admin-lastname=X \
--admin-email=1541223540@qq.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1
##1419 錯誤 1419
set global log_bin_trust_function_creators=1;
##配置虛擬主機
cd /etc/nginx/sites-available/
vim magento2
##將下面配置修改好複製貼上
upstream fastcgi_backend {
server unix:/run/php/php7.3-fpm.sock;
}
server {
listen 80;
server_name 域名;
set $MAGE_ROOT /var/www/magento2;
set $MAGE_MODE developer;
include /var/www/magento2/nginx.conf.sample;
error_log /var/log/magento2/nginx/error.log;
}
sudo mkdir -p /var/log/magento2/nginx/
sudo nginx -t
sudo ln -s /etc/nginx/sites-available/magento2 /etc/nginx/sites-enabled/
//以下操作在nginx1.18+版本
vim /etc/nginx/nginx.conf
//頭部
user www-data;
#user jx;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
http中增加
include /etc/nginx/sites-enabled/*;
//以上操作在nginx1.18+版本
sudo systemctl restart nginx
//反向代理 修改nginx.conf檔案
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
本作品採用《CC 協議》,轉載必須註明作者和本文連結