在 FreeBSD 11.2 里安装 Magento2.3

环境:FreeBSD 11.1-RELEASE

过程:

1.pkg install apache24 # 安装 apache2.4
2.pkg install mysql57-server # 安装 mysql server 5.7
3.pkg install php72 php72-curl php72-gd php72-mbstring php72-mysqli php72-openssl php72-pdo_mysql php72-xml php72-dom php72-json php72-xsl php72-ctype php72-intl php72-hash php72-soap php72-filter php72-phar php72-zip php72-iconv php72-bcmath php72-simplexml php72-xmlwriter php72-tokenizer php72-opcache xmlreader php72-xmlreader php72-session php72-wddx php72-sockets php72-readline php72-pcntl php72-gettext php72-exif php72-fileinfo php72-zlib php72-calendar php72-ftp # 安装 php7.2 和相关扩展
4./usr/local/etc/apache24/httpd.conf # 编辑 httpd 的配置文件,本例,启用了好些模块 rewrite_module, mpm_event_module, http2_module, ssl_module, mod_proxy_fcgi, mod_proxy,引用了 httpd-vhosts.conf 文件,禁用了 mpm_worker_module 模块
5./usr/local/etc/apache24/extra/httpd-vhosts.conf # 编辑虚拟主机配置文件,如下例,是添加了https站点 szt.anqun.org的配置内容

Listen 443
<VirtualHost *:443>
        Protocols h2 http/1.1
        ServerName szt.anqun.org

        SSLEngine on
        SSLCertificateFile "/root/.acme.sh/szt.anqun.org/fullchain.cer"
        SSLCertificateKeyFile "/root/.acme.sh/szt.anqun.org/szt.anqun.org.key"

        DocumentRoot "/usr/local/www/szt_anqun_org/public_html"
        ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/www/szt_anqun_org/public_html/$1
        ErrorLog "/usr/local/www/szt_anqun_org/logs/error.log"

    <Directory "/usr/local/www/szt_anqun_org/public_html">
        AllowOverride All
        DirectoryIndex /index.php index.php index.html
        Require all granted
        Allow from all
    </Directory>

</VirtualHost>

6.sysrc apache24_enable=yes # 允许 apache24 服务
7.sysrc mysql_enable=yes # 允许 mysql-server 服务
8.sysrc php_fpm_enable=yes # 允许 php-fpm 服务
9.service apache24 start # 启动 apache24 服务
10.service mysql-server start # 启动 mysql-server 服务
11.service php-fpm start # 启动 php-fpm 服务
freebsd-magento2-3.png
12.ALTER USER 'root'@'localhost' IDENTIFIED BY 'niDEpASSWORD' ; # 首次启动mysql5.7后,root的密码会写在/root/.mysql_secret 文件里,需要用 ALTER USER 命令更改密码后使用
13.下载不带演示数据的magento2安装文件,解压到 /usr/local/www/szt_anqun_org/public_html,且将目录权限设置为www用户所有
14.切换到magento的目录,执行以下命令安装:

sudo -u www php bin/magento setup:install --base-url=https://szt.anqun.org/ \
--db-host=localhost --db-name=mage --db-user=mage --db-password=wpmima888 \
--admin-firstname=Magento --admin-lastname=User --admin-email=liujia@anqun.org \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1

freebsd-magento2-1.png
15.在浏览器访问前台和后台,正常
freebsd-magento2-2.png

参考:https://devdocs.magento.com/guides/v2.3/install-gde/install/cli/install-cli-subcommands.html

标签: magento, FreeBSD

添加新评论