centos7.8 下安装magento 2.4.2-p1 - 来自一叶知秋
本文内容来自QQ群大佬陈伟明(一叶知秋)的学习分享
服务端: centos7.8
前面都是在centos7下面安装,准备的工作完成后,就进入到magento的安装
一,在 https://marketplace.magento.com 注册自己的账号, 后面安装相关插件都要用
[email protected]
密码xxxxx
这是我的账号
进到个人中心 进到 Marketplace -> my Products ->Access Keys ->magento2
Public Key: xxxx Copy
Private Key: xxx Copy
这是我创建的公钥和私钥
二,创建网站,只用composer来安装,后面好开发,好维护
# cd /var/www # yum install unzip 这个装一下,compser要用到 # composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.2-p1 tribesigns
指定了版本 和要用的项目目录名 在写文件最新就是 2.4.2-p1 ,可用版本,我们可以在 github 上看,一般release的版本,在 官方都可用
https://github.com/magento/magento2/releases 可以查看
提示username输入Public Key,password输入Private Key,是否创建auth.json,输入Y回车
Do you want to store credentials for repo.magento.com in /root/.config/composer/auth.json ? [Yn] y
若是其它用户,如 www Do you want to store credentials for repo.magento.com in /home/www/.config/composer/auth.json ? [Yn]
等一段时间就可以,小心看有没有报错,若前面准备工作做好,一般没问题
若是刚开始研究,则可以
https://www.360magento.com/blog/cat/magento-download/post/magento-2-download-all/ 下载后,放到项目,然后执行
composer install 这样速度快一些
# 在网站的根目录下,
# composer install
到这里若没有错,基本magento代码是到位了
三,下面就是安装网站
www.ltribesigns66.com 这个自己在hosts 面面加一下,指定 web服务器
安装网站
bin/magento setup:install --base-url=http://www.ltribesigns.com/ \ --db-host=192.168.56.66 --db-name=tribesigns_com --db-user=root --db-password=123456 \ --backend-frontname="admin" \ --admin-firstname=Magento --admin-lastname=User [email protected] \ --admin-user=admin --admin-password=admin123 --language=en_US \ --currency=USD --timezone=America/Chicago --use-rewrites=1 \ --search-engine=elasticsearch7 --elasticsearch-host=192.168.56.67 \ --elasticsearch-port=9200 --cleanup-database
指定了网圵,会生成在两个地方: 若要更换网圵,这两个地方要改,若是生产环境,来一次完整的“单机发布”
1)core_config_data 表中
web/unsecure/base_url web/secure/base_url
2) app/etc/env.php
里面
生成后,都是root的权限,这时要改权限了
修改目录的权限
我用的是www运行
chown www.www -R xxx
若要重新安装
则要
删除 var/cache 文件夹下面的文件
删除 generated文件夹
删除 app/etc/config.php
删除 app/etc/env.php
安装 mageplaza 这个提供商质量好,最好安装
composer remove mageplaza/module-core rm -rf app/code/Mageplaza/Core rm -rf vendor/mageplaza/module-core composer dump-autoload composer require mageplaza/module-core php bin/magento setup:upgrade
四,登录后台
1.登陆后台出错:
Failed to send the message. Please contact the administrator
解决方案:
bin/magento module:disable Magento_TwoFactorAuth
2.出现以下错误:
One or more indexers are invalid. Make sure your Magento cron job is running.
解决方案:
php bin/magento indexer:reindex
原文链接:https://blog.csdn.net/Lin_Hv/article/details/109379496
个人注册
[email protected]
Cwm123!@#
五,安装演示数据
composer self-update 更新一下版本
php 的内存 memory-limit 要加大来,才能装上,我这里加到 4096M
bin/magento sampledata:deploy
若出现 Content-Length mismatch 错误,就切换一下源,再操作
我用阿里云的才装成功
composer config repo.packagist composer https://mirrors.aliyun.com/composer/ composer config repo.packagist composer https://packagist.phpcomposer.com
关联到数据,最后的安装,这是先安装好magento 后,才要执行这个动作
bin/magento setup:upgrade
这里又要改一下目录的权限
chown www.www -R xxx
把 var/cache 下面的文件清除一下
再打开网站,这里应该就正常了
nginx对应的配置文件
/usr/local/nginx/conf/vhost/tribesigns.conf
server{ listen 80; server_name localhost www.ltribesigns.com ; charset utf-8; set $MAGE_ROOT /var/www/tribesigns; set $MAGE_DEBUG_SHOW_ARGS 0; root $MAGE_ROOT/pub; index index.php; autoindex off; error_log /log/nginx/tribesigns/error.log; error_page 404 403 = /errors/404.php; # PHP entry point for setup application location ~* ^/setup($|/) { root $MAGE_ROOT; location ~ ^/setup/index.php { fastcgi_pass fastcgi_backend; fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600"; fastcgi_read_timeout 600s; fastcgi_connect_timeout 600s; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ ^/setup/(?!pub/). { deny all; } location ~ ^/setup/pub/ { add_header X-Frame-Options "SAMEORIGIN"; } } # PHP entry point for update application location ~* ^/update($|/) { root $MAGE_ROOT; location ~ ^/update/index.php { fastcgi_split_path_info ^(/update/index.php)(/.+)$; fastcgi_pass fastcgi_backend; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; } # Deny everything but index.php location ~ ^/update/(?!pub/). { deny all; } location ~ ^/update/pub/ { add_header X-Frame-Options "SAMEORIGIN"; } } location / { try_files $uri $uri/ /index.php$is_args$args; } location /pub/ { location ~ ^/pub/media/(downloadable|customer|import|custom_options|theme_customization/.*\.xml) { deny all; } alias $MAGE_ROOT/pub/; add_header X-Frame-Options "SAMEORIGIN"; } location /static/ { # Uncomment the following line in production mode # expires max; # Remove signature of the static files that is used to overcome the browser cache location ~ ^/static/version { rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last; } location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$ { add_header Cache-Control "public"; add_header X-Frame-Options "SAMEORIGIN"; expires +1y; if (!-f $request_filename) { rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; } } location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { add_header Cache-Control "no-store"; add_header X-Frame-Options "SAMEORIGIN"; expires off; if (!-f $request_filename) { rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; } } if (!-f $request_filename) { rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; } add_header X-Frame-Options "SAMEORIGIN"; } location /media/ { try_files $uri $uri/ /get.php$is_args$args; location ~ ^/media/theme_customization/.*\.xml { deny all; } location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { add_header Cache-Control "public"; add_header X-Frame-Options "SAMEORIGIN"; expires +1y; try_files $uri $uri/ /get.php$is_args$args; } location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { add_header Cache-Control "no-store"; add_header X-Frame-Options "SAMEORIGIN"; expires off; try_files $uri $uri/ /get.php$is_args$args; } add_header X-Frame-Options "SAMEORIGIN"; } location /media/customer/ { deny all; } location /media/downloadable/ { deny all; } location /media/import/ { deny all; } location /media/custom_options/ { deny all; } location /errors/ { location ~* \.xml$ { deny all; } } # PHP entry point for main application location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ { try_files $uri =404; fastcgi_pass fastcgi_backend; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000"; fastcgi_read_timeout 600s; fastcgi_connect_timeout 600s; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # Banned locations (only reached if the earlier PHP entry point regexes don't match) location ~* (\.php$|\.phtml$|\.htaccess$|\.git) { deny all; } }
作者:陈伟明
联系 : QQ 942923305 | 微信 toby942923305
E-mail: [email protected]
==================================
修订时间:
9:41 2021-06-18 星期五
------------------