Magento2 LNMP 环境安装

##更新系统并安装必要的软件包

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 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!