
Magentoは、非常に人気があり、機能が豊富なオープンソースのeコマースWebアプリケーションです。 Magentoはユーザーの要求に応答し、完全に機能するオンラインストアを数分で作成できるようにします。 この記事ではNginx Webサーバー、PHP-FPM、及びMariaDBを使用してVPSCentOS7にMagentoをインストールする方法を説明します。
CentOS7にNginxを使用してMagentoをインストール
1.ステップ1:LEMPをインストールします(Nginx-MariaDB-PHP)
LEMPをインストールするには、以下の別のテーマに従ってください。
2.ステップ2:データベースを作成する
Magentoが機能するために最初に行うことは、Magento用のデータベースを作成することです。 これを行うには、次のコマンドを順番に使用します
mysql -u root -p
CREATE DATABASE magentodb; GRANT ALL PRIVILEGES ON magentodb . * TO magentouser@'localhost' IDENTIFIED BY 'YOUR-PASSWORD' WITH GRANT OPTION; FLUSH PRIVILEGES; exit;
YOUR-PASSWORDを作成するMysqlパスワードに置き換えます
3.ステップ3:Magentoをダウンロードしてインストールします
magentodomain.comをドメイン名に置き換えます
- コードを含むディレクトリを作成します
次のコマンドを使用して、Magentoコードを含むディレクトリを作成できます。
mkdir -p /home/magentodomain.com/public_html
- Magentoをインストールします
cd /home/magentodomain.com/public_html wget https://github.com/magento/magento2/archive/2.3.tar.gz tar -xvf 2.3.tar.gz
抽出したソースコードをpublic_htmlに移動します
v magento2-2.3/{.,}* /home/magentodomain.com/public_html
タイプAとEnterキーを押して入力プロンプトが表示されたら、
不要なフォルダを削除する
rm -rf 2.3.tar.gz magento2-2.3
必要なライブラリをcomposerでインストールします。VPSにcomposerがインストールされていない場合は、CentOS7にComposerをインストールする方法の説明を参照してください。bin / magento setup:install --backend-frontname = "adminlogin"
--key = "biY8vdWx4w8KV5Q59380Fejy36l6ssUb"
--db-host = "localhost" --db-name = "magentodb"
--db-user = "magentouser"
--db-password = "MYSQL-PASSWORD"
--language = "en_US"
--currency = "USD"
--timezone = "Asia / Ho_Chi_Minh"
--use-rewrites = 1
--use-secure = 0
--base -url = "http://magentodomain.com"
--base-url-secure = "https://magentodomain.com"
--admin-user = adminuser
--admin-password = STRONG-PASSWORD
--admin-email = admin @newmagento。com
--admin-firstname = admin
--admin-lastname = user
--cleanup-database
コマンドの情報を次のように変更する必要があります。
- –backend-frontname: 必要な管理者ログインリンク(例:https://magentodomain.com/adminlogin)
- キー:任意の文字列に置き換えます
- db-name、db-user、db-password:ステップ2で作成した情報に置き換えます:データベースを作成します
- magentodomain.com:独自のドメインに置き換えます
- admin-user、admin-password:作成する管理者資格情報に置き換えます。パスワードは大文字、小文字、数字を含めて8文字以上である必要があることに注意してください
- admin-email、admin-firstname、admin-lastname:独自の情報に置き換えます
インストールが完了したら、権限エラーを回避するために所有者の設定に進みます。
chown -R nginx:nginx /home/magentodomain.com/public_html
4.ステップ4:仮想ホストを作成する
ファイル/etc/nginx/conf.d/magentodomain.com.confを作成します
nano /etc/nginx/conf.d/magentodomain.com.conf
以下のテキストを貼り付けます
upstream fastcgi_backend { server unix:/var/run/php-fpm.sock; } server { listen 80; server_name www.magentoodomain.com magentodomain.com; set $MAGE_ROOT /home/magentodomain.com/public_html; set $MAGE_DEBUG_SHOW_ARGS 1; root $MAGE_ROOT/pub; index index.html index.htm index.php; autoindex off; charset UTF-8; error_page 404 403 = /errors/404.php; #add_header "X-UA-Compatible" "IE=Edge"; # Deny access to sensitive files location /.user.ini { deny all; } # 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/(versiond*/)?(.*)$ /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/(versiond*/)?(.*)$ /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/(versiond*/)?(.*)$ /static.php?resource=$2 last; } } if (!-f $request_filename) { rewrite ^/static/(versiond*/)?(.*)$ /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 1024 4k; 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; } }押して Ctrlキー + O を押して 入力し 、ファイルを保存するために、 Ctrlキー +は、 xは、出口nanoに。
Nginxを再起動して、構成をロードします。
service nginx restart
5.チェック
完了すると、Webブラウザでドメイン名にアクセスして確認できます。
6.結論
この記事を通じて、SmartOSCはMagentoのをインストールする方法を示しましたCentOSのnginxのWebサーバー、PHP-FPMとMariaDBです。インストール時に問題が発生した場合は弊社の開発者サポートにお問い合わせください。