Magento2是个什么东东?且看 github ------------> https://github.com/magento/magento2
打开上面的网址,对一个爱国的中国人来说实在不友好。不认识几个爬行的弯弯绕绕的虫子文。
废话不多说。直接下载release,上图 VVVVV
继续上图VVVV
这就直接下载最新版本了?是否有坑?不去多想,果断下载
下载中。。。。。。下载中。。。。。。下载中。。。。。。
下载完成。。。。。
再安装宝塔和docker的服务器做事真不赖。
啥?你不知道宝塔和docker?问度娘哦。
安装好php7.4或者之上版本,在安装好Mysql,这一切在宝塔中都不是事。
然后给Magento2创建一个站点,我们就称之为mto.xxxx.xxx吧,站点创建完成后。再/www/wwwroot目录先回生成对应的目录,像这样的结构 /www/wwwroot/mto.xxxx.xxx(当然这一步也是用宝塔)
好了,看完图我们继续,上传下载好的Magento2代码到 /www/wwwroot/mto.xxxx.xxx中,然后解压。
让压缩包中的文件平铺在 /www/wwwroot/mto.xxxx.xxx 目录下好了。接着呢用如下命令
composer install
安装项目相关的依赖包
一般这一步总是会有坑。比如缺个包拉,撞到墙啦,网速不好啦等等。。
比如ext-zip、ext-xsl、fileinfo 这些php扩展都是需要的。请先安装。。
等待~~~~~~~~~~~~~~~~~~~~~~
完成后—> 进入bin目录下 ,新建一个install.sh文件,可这个用来干啥的?安装Magento2的
且看代码 VVVV
./magento setup:install \
--base-url='http://你的网址' \
--db-host='localhost' \
--db-name='magento' \
--db-user='magento' \
--db-password='***xxx***' \
--admin-firstname='admin' \
--admin-lastname='admin' \
--admin-email='xxx@qq.com' \
--admin-user='不能看见' \
--admin-password='不能看见' \
--language='en_US' \
--currency='USD' \
--timezone='America/Chicago' \
--use-rewrites=1 \
--search-engine='elasticsearch7' \
--elasticsearch-host='localhost' \
--elasticsearch-port=9200 \
--elasticsearch-index-prefix='magento2' \
--elasticsearch-timeout=15
不过之前应该先去安装elasticsearch这个牛逼的搜索引擎。VVVV
version: "3"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.1
container_name: es01
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- /data/coowalt/elasticsearch/data:/usr/share/elasticsearch/data
- /data/coowalt/elasticsearch/plugins:/usr/share/elasticsearch/plugins
ports:
- 9200:9200
- 9300:9300
networks:
- esnet
networks:
esnet:
driver: bridge
一切都准备好之后运行,到bin目录下运行VVV
./install.sh
又是等待安装~~~
如果没有遇到坑,这一步会很顺利的完成
切记 安装完成后改变一下目录权限,这样 VVV
chown -R www:www /www/wwwroot/mto.xxxx.xxx
万事大吉,去看看。。打开网站,我了个去,一大堆资源无法访问。然后~~~
陷入沉思~~~
沉思~~~
度娘说在根目录执行一下这段代码VVVV
./bin/magento setup:static-content:deploy -f
抱着怀疑试一试的心态,执行完成了~~~,。
再一次访问网站,尽然可以了 ~~~
图老好看了VVVV
为毛啥都没有 ,算球不管了,交给后面的哥们去里面遨游,填空了。
!!!第二天哥们说,咋后台提示找个什么cron job的问题 ,还发来了截图给我看 ~~~
于是,我又进行了一顿操作。。。。
crontab -u root -e
* * * * * /usr/bin/php /www/wwwroot/mto.szhyy.xyz/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /www/wwwroot/mto.szhyy.xyz/var/log/magento.cron.log
* * * * * /usr/bin/php /www/wwwroot/mto.szhyy.xyz/update/cron.php >> /www/wwwroot/mto.szhyy.xyz/var/log/update.cron.log
* * * * * /usr/bin/php /www/wwwroot/mto.szhyy.xyz/bin/magento setup:cron:run >> /www/wwwroot/mto.szhyy.xyz/var/log/setup.cron.log
./bin/magento cron:run
刷新后台管理页面,问题解决~~~
完结,不喜勿喷,只为流水记录。方便回忆