最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

使用我搭的LNMP S环境 运行网站 以Magento 2 为例

Magento 资料整理 ajiang-tuzi 32090浏览

Magento 2下载地址
Magento 2 开放下载
使用的环境 LNMP S 自己搭的
Centos7+Mysql/MariaDB+sendMail+Nginx+PHP 环境搭建一条龙
注 我用的是Mysql 不是Mariadb
liunx 下 或centos7 下安装 MySQL-5.6

安装命令示范

magento setup:install --base-url=http://127.0.0.1/magento2/ \
--db-host=localhost --db-name=magento --db-user=magento --db-password=magento \
--admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1

被安装的模块 请看附录一
关于这个错误

Installing data.. PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /usr/local/www/mage2/vendor/oyejorge/less.php/lib/Less/Parser.php on line 1052
PHP Stack trace:
PHP   1. {main}() /usr/local/www/mage2/bin/magento:0
PHP   2. Symfony\Component\Console\Application->run() /usr/local/www/mage2/bin/magento:25
PHP   3. Magento\Framework\Console\Cli->doRun() /usr/local/www/mage2/vendor/symfony/console/Symfony/Component/Console/Application.php:126
PHP   4. Symfony\Component\Console\Application->doRun() /usr/local/www/mage2/vendor/magento/framework/Console/Cli.php:49
PHP   5. Symfony\Component\Console\Application->doRunCommand() /usr/local/www/mage2/vendor/symfony/console/Symfony/Component/Console/Application.php:195
PHP   6. Symfony\Component\Console\Command\Command->run() /usr/local/www/mage2/vendor/symfony/console/Symfony/Component/Console/Application.php:874
PHP   7. Magento\Setup\Console\Command\InstallCommand->execute() /usr/local/www/mage2/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
PHP   8. Magento\Setup\Model\Installer->install() /usr/local/www/mage2/setup/src/Magento/Setup/Console/Command/InstallCommand.php:125
PHP   9. call_user_func_array:{/usr/local/www/mage2/setup/src/Magento/Setup/Model/Installer.php:331}() /usr/local/www/mage2/setup/src/Magento/Setup/Model/Installer.php:331
PHP  10. Magento\Setup\Model\Installer->installDataFixtures() /usr/local/www/mage2/setup/src/Magento/Setup/Model/Installer.php:331
PHP  11. Magento\Setup\Model\Installer->handleDBSchemaData() /usr/local/www/mage2/setup/src/Magento/Setup/Model/Installer.php:746
PHP  12. Magento\CustomerSampleData\Setup\InstallData->install() /usr/local/www/mage2/setup/src/Magento/Setup/Model/Installer.php:798
PHP  13. Magento\Framework\Setup\SampleData\Executor->exec() /usr/local/www/mage2/vendor/magento/module-customer-sample-data/Setup/InstallData.php:33
PHP  14. Magento\Framework\App\State->emulateAreaCode() /usr/local/www/mage2/vendor/magento/framework/Setup/SampleData/Executor.php:50
PHP  15. call_user_func_array:{/usr/local/www/mage2/vendor/magento/framework/App/State.php:171}() /usr/local/www/mage2/vendor/magento/framework/App/State.php:171
PHP  16. Magento\CustomerSampleData\Setup\Installer->install() /usr/local/www/mage2/vendor/magento/framework/App/State.php:171
PHP  17. Magento\CustomerSampleData\Model\Customer->install() /usr/local/www/mage2/vendor/magento/module-customer-sample-data/Setup/Installer.php:33
PHP  18. Magento\Framework\App\State->emulateAreaCode() /usr/local/www/mage2/vendor/magento/module-customer-sample-data/Model/Customer.php:168
PHP  19. call_user_func_array:{/usr/local/www/mage2/vendor/magento/framework/App/State.php:171}() /usr/local/www/mage2/vendor/magento/framework/App/State.php:171
PHP  20. Magento\Customer\Model\AccountManagement->createAccount() /usr/local/www/mage2/vendor/magento/framework/App/State.php:171
PHP  21. Magento\Customer\Model\AccountManagement->createAccountWithPasswordHash() /

也很简单
可分配的内存太小,查看php.ini配置文件,修改大小,就ok了。如下:
查到这儿,memory_limit = 128M;
修改其值,如512或1024,看你自己想分配多大的内存了。

 Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 800M

由于我的CentOS 启用了 SELinux 所以 一直报这个错
这种错误 比较奇特 因为你用命令行的话[用户和组都是 Nginx] 他不会爆任何错误 但你用浏览器的话 就会报错 Mysql 也遇到过这种情况
这个我会单开一篇文章

#提示
new selinux security alert
avc denial click icon to view
exception 'Zend_Cache_Exception' with message 'cache_dir "/usr/local/www/mage2/var/page_cache" is not writable' in /usr/local/www/mage2/vendor/magento/zendframework1/library/Zend/Cache.php:209
Stack trace:
#0 /usr/local/www/mage2/vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php(180): Zend_Cache::throwException('cache_dir "/usr...')
#1 /usr/local/www/mage2/lib/internal/Cm/Cache/Backend/File.php(82): Zend_Cache_Backend_File->setCacheDir('/usr/local/www/...')
#2 /usr/local/www/mage2/vendor/magento/zendframework1/library/Zend/Cache.php(153): Cm_Cache_Backend_File->__construct(Array)
#3 /usr/local/www/mage2/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true)
#4 /usr/local/www/mage2/vendor/magento/framework/App/Cache/Frontend/Factory.php(155): Zend_Cache::factory('Magento\\Framewo...', 'Cm_Cache_Backen...', Array, Array, true, true, true)
#5 /usr/local/www/mage2/vendor/magento/framework/App/Cache/Frontend/Pool.php(67): Magento\Framework\App\Cache\Frontend\Factory->create(Array)
#6 /usr/local/www/mage2/vendor/magento/framework/App/Cache/Frontend/Pool.php(146): Magento\Framework\App\Cache\Frontend\Pool->_initialize()

这个是 访问权限的问题 我是直接 chmod -R 0777


Warning: SessionHandler::read(): open(/var/lib/php/session/sess_qkjjjam4up27vd8hmesbf6g917, O_RDWR) failed: Permission denied (13) in /usr/local/www/mage2/vendor/magento/framework/Session/SaveHandler.php on line 74
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'SessionHandler:...', '/usr/local/www/...', 74, Array)
#1 /usr/local/www/mage2/vendor/magento/framework/Session/SaveHandler.php(74): SessionHandler->read('qkjjjam4up27vd8...')
#2 [internal function]: Magento\Framework\Session\SaveHandler->read('qkjjjam4up27vd8...')
#3 /usr/local/www/mage2/vendor/magento/framework/Session/SessionManager.php(189): session_start()
#4 /usr/local/www/mage2/vendor/magento/framework/Session/SessionManager.php(130): Magento\Framework\Session\SessionManager->start()
#5 /usr/local/www/mage2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(115): Magento\Framework\Session\SessionManager->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Framework\Session\Config), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State))
#6 /usr/local/www/mage2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array)

这 个可能是配置冲突把 因为 同时还运行着mariadb 从 phpinfo 的输出中 sock 的 位置是对的
命令行执行也没问题

Could not connect: No such file or directory

解决方如下 方法很多任选一种即可

For some reason mysql on OS X gets the locations of the required socket file a bit wrong, but thankfully the solution is as simple as setting up a symbolic link.

You may have a socket (appearing as a zero length file) as /tmp/mysql.sock or /var/mysql/mysql.sock but 1 or more apps is looking in the other location for it.

Rather than move the socket and have to edit config files and remember to keep edited files local and away from servers where the paths are correct, simply create a symbolic link so your mac finds the required socket, even when it’s looking in the wrong place!

If you have /tmp/mysql.sock but no /var/mysql/mysql.sock then…

cd /var 
sudo mkdir mysql
sudo chmod 755 mysql
cd mysql
sudo ln -s /tmp/mysql.sock mysql.sock
If you have /var/mysql/mysql.sock but no /tmp/mysql.sock then

cd /tmp
ln -s /var/mysql/mysql.sock mysql.sock
@

当然 这种对我没用 留着 备用
第二种

I was having the same problem and this is how I fixed it:

I had this and it didn't work:

$con = mysql_connect('localhost', 'root', '1234');
I did this and it worked:

$con = mysql_connect(':/Applications/MAMP/tmp/mysql/mysql.sock', 'root', '1234');
Instead of using the mysql server, I connected directly to the Unix Socket. Worked for me.

试过 没用 留着备用

其实我是这么干的

使用 127.0.0.1
代替 localhost

原因是
The reason is that “localhost” is a special name for the mysql driver making it use the unix socket to connect to mysql instead of the a tcp socket.
这是原话 就放这儿了 当然这不是本文的重点
参考来自
stackoverflow
作品展示

homepage

成果
附录一

Starting Magento installation:
File permissions check...
[Progress: 1 / 362]
Enabling Maintenance Mode...
[Progress: 2 / 362]
Installing deployment configuration...
[Progress: 3 / 362]
Installing database schema:
Schema creation/updates:
Module 'Magento_Store':
[Progress: 4 / 362]
Module 'Magento_AdvancedPricingImportExport':
[Progress: 5 / 362]
Module 'Magento_Directory':
[Progress: 6 / 362]
Module 'Magento_Theme':
[Progress: 7 / 362]
Module 'Magento_Backend':
[Progress: 8 / 362]
Module 'Magento_Backup':
[Progress: 9 / 362]
Module 'Magento_Eav':
[Progress: 10 / 362]
Module 'Magento_Customer':
[Progress: 11 / 362]
Module 'Magento_BundleImportExport':
[Progress: 12 / 362]
Module 'Magento_AdminNotification':
[Progress: 13 / 362]
Module 'Magento_CacheInvalidate':
[Progress: 14 / 362]
Module 'Magento_Indexer':
[Progress: 15 / 362]
Module 'Magento_Cms':
[Progress: 16 / 362]
Module 'Magento_CatalogImportExport':
[Progress: 17 / 362]
Module 'Magento_Catalog':
[Progress: 18 / 362]
Module 'Magento_Rule':
[Progress: 19 / 362]
Module 'Magento_Msrp':
[Progress: 20 / 362]
Module 'Magento_Search':
[Progress: 21 / 362]
Module 'Magento_Bundle':
[Progress: 22 / 362]
Module 'Magento_Quote':
[Progress: 23 / 362]
Module 'Magento_CatalogUrlRewrite':
[Progress: 24 / 362]
Module 'Magento_Widget':
[Progress: 25 / 362]
Module 'Magento_SalesSequence':
[Progress: 26 / 362]
Module 'Magento_CheckoutAgreements':
[Progress: 27 / 362]
Module 'Magento_Payment':
[Progress: 28 / 362]
Module 'Magento_Downloadable':
[Progress: 29 / 362]
Module 'Magento_CmsUrlRewrite':
[Progress: 30 / 362]
Module 'Magento_Config':
[Progress: 31 / 362]
Module 'Magento_ConfigurableImportExport':
[Progress: 32 / 362]
Module 'Magento_CatalogInventory':
[Progress: 33 / 362]
Module 'Magento_Sam

........................................................

关于 magento 2 的nginx 配置文件


upstream fastcgi_backend {
    server  127.0.0.1:9000;
}
server {
    listen 80;
    server_name mage2.com;
    set $MAGE_ROOT /usr/local/www/mage2;
    set $MAGE_MODE developer;

    root $MAGE_ROOT;

    index index.php;
    autoindex off;
    # disable_symlinks on;
    charset off;

    location /setup/ {
        rewrite / /setup/index.php;
        location /setup/pub/ {}
        location /setup/index.php {
            fastcgi_pass   fastcgi_backend;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

    location / {
        root $MAGE_ROOT/pub;

        location / {
            rewrite / /index.php ;
        }

        location /static/ {
            if ($MAGE_MODE = "production") {
                expires max;
            }
            if (!-f $request_filename) {
                rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
            }
        }

        location /media/ {
            if (!-f $request_filename) {
                rewrite / /get.php;
            }
        }

        location /media/customer/ {
            deny all;
        }

        location /media/downloadable/ {
            deny all;
        }
...........................................................
#完整的下面有下载

Magento 2 Nginx Config 下载

  mage2.conf_.txt (2.2 KiB, 47 hits)
您需要注册或者回复才能下载此文件.

引用:
Magento 2.0 语言包 及 安装方法
GIT Centos 下安装 Magento 2

转载请注明:(●--●) Hello.My Weicot » 使用我搭的LNMP S环境 运行网站 以Magento 2 为例

蜀ICP备15020253号-1