dram.me

OroCommerce安装配置

安装Mail服务

apt install dovecot-imapd postfix # 安装过程中mail configuration选择Local only,mail name为默认
echo 'home_mailbox = Maildir/' >> /etc/postfix/main.cf
/etc/init.d/postfix restart
sed -i 's|^#log_path = .*|log_path = /var/log/dovecot.log|' /etc/dovecot/conf.d/10-logging.conf 
sed -i 's|^mail_location = .*|mail_location = maildir:~/Maildir|' /etc/dovecot/conf.d/10-mail.conf
/etc/init.d/dovecot restart

在完成上述配置后,后续系统通知的邮件可以在$HOME/Maildir文件夹中查看,另外可以通过OroCommerce自带的邮件客户端基于IMAP收取邮件。

安装PHP

  1. 安装依赖包:

    apt install \
    	jpegoptim \
    	libc-client2007e-dev \
    	libcurl4-openssl-dev \
    	libkrb5-dev \
    	libonig-dev \
    	libpq-dev \
    	libreadline-dev \
    	libsasl2-dev \
    	libsodium-dev \
    	libtidy-dev \
    	libxml2-dev \
    	libzip-dev \
    	pngquant \
    	zlib1g-dev
  2. 编译安装PHP:

    wget https://www.php.net/distributions/php-8.0.12.tar.gz
    tar xf php-8.0.12.tar.gz
    cd php-8.0.12
    ./configure \
    	--prefix=$HOME/.local \
    	--enable-bcmath \
    	--enable-fpm \
    	--enable-gd \
    	--enable-intl \
    	--enable-mbstring \
    	--enable-pcntl \
    	--enable-soap \
    	--with-curl \
    	--with-kerberos \
    	--with-imap \
    	--with-imap-ssl \
    	--with-ldap \
    	--with-ldap-sasl \
    	--with-openssl \
    	--with-pdo-pgsql \
    	--with-readline \
    	--with-sodium \
    	--with-tidy \
    	--with-zip \
    	--with-zlib
    make -j8
    make install

配置PHP

sed \
	-e 's/^memory_limit =.*/memory_limit = 4096M/' \
	-e 's/^;date.timezone =.*/date.timezone = Asia\/Shanghai/' \
	-e 's/^;opcache.enable_cli=.*/opcache.enable_cli=0/' \
	-e 's/^;opcache.enable=.*/opcache.enable=1/' \
	-e 's/^;opcache.interned_strings_buffer=.*/opcache.interned_strings_buffer=32/' \
	-e 's/^;opcache.max_accelerated_files=.*/opcache.max_accelerated_files=60000/' \
	-e 's/^;opcache.memory_consumption=.*/opcache.memory_consumption=512/' \
	-e 's/^;opcache.validate_timestamps=.*/opcache.validate_timestamps=0/' \
	-e 's/^;realpath_cache_size =.*/realpath_cache_size = 4096K/' \
	-e 's/^;realpath_cache_ttl =.*/realpath_cache_ttl = 600/' \
	-e 's/^;zend_extension=.*/zend_extension=opcache/' \
	php.ini-production > $HOME/.local/lib/php.ini

安装Composer

wget https://getcomposer.org/download/2.1.9/composer.phar
chmod +x composer.phar
mv composer.phar $HOME/.local/bin/composer
composer config -g repos.packagist composer https://mirrors.aliyun.com/composer/

安装Node.js

wget https://nodejs.org/dist/v14.18.1/node-v14.18.1-linux-x64.tar.xz
tar xf node-v14.18.1-linux-x64.tar.xz
ln -s $PWD/node-v14.18.1-linux-x64/bin/{node,npm} $HOME/.local/bin
npm config set registry https://registry.npm.taobao.org

创建数据库

echo "CREATE ROLE oro WITH LOGIN PASSWORD 'oro'; CREATE DATABASE orocommerce WITH OWNER oro" | psql postgres postgres
echo 'CREATE EXTENSION "uuid-ossp"' | psql orocommerce oro

安装依赖及配置

cd oroinc/crm-application
sed \
	-e 's/database_driver:.*/database_driver: pdo_pgsql/' \
	-e 's/database_host:.*/database_host: 127.0.0.1/' \
	-e 's/database_port:.*/database_port: 5432/' \
	-e 's/database_name:.*/database_name: orocommerce/' \
	-e 's/database_user:.*/database_user: oro/' \
	-e 's/database_password:.*/database_password: oro/' \
	-e 's/database_server_version:.*/database_server_version: 13/' \
	config/parameters.yml.dist > config/parameters.yml
rm package-lock.json
composer install

安装OroCommerce

php bin/console oro:install \
	--application-url=http://localhost:8000/ \
	--env=prod \
	--formatting-code=en_US \
	--language=en \
	--organization-name=ORO \
	--sample-data=n \
	--skip-translations \
	--user-email=$USER@localhost.localdomain \
	--user-firstname=Xin \
	--user-lastname=Wang \
	--user-name=admin \
	--user-password=admin

启用服务

php bin/console oro:message-queue:consume
php -S localhost:8000 -t public

访问

http://localhost:8000/index_dev.php