このチュートリアルでは、MariaDB、PHP-FPM、およびNginxを使用してUbuntu14.04VPSにOpenCart2をインストールする方法について説明します。 OpenCartは、オープンソースで、機能が豊富で、使いやすく、検索エンジンに優しいPHPベースのeコマースソリューションです。このガイドは他のLinuxVPSシステムでも機能するはずですが、Ubuntu14.04VPS用にテストおよび作成されています。
SSH経由でVPSにログイン
ssh your_user@myVPS
システムを更新し、必要なパッケージをインストールします
user@myVPS:~# sudo apt-get update && sudo apt-get -y upgrade user@myVPS:~# sudo apt-get install python-software-properties software-properties-common git curl openssl vim
MariaDB10.0をインストール
user@myVPS:~# sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db user@myVPS:~# sudo add-apt-repository 'deb http://mirror.pw/mariadb/repo/10.0/ubuntu trusty main' user@myVPS:~# sudo apt-get install mariadb-server
インストールが完了したら、次のコマンドを実行してインストールを保護します。
mysql_secure_installation
次に、OpenCartインストール用のデータベースを作成する必要があります。
mysql -uroot -p MariaDB [(none)]> CREATE DATABASE opencart; MariaDB [(none)]> GRANT ALL PRIVILEGES ON opencart.* TO 'opencartuser'@'localhost' IDENTIFIED BY 'opencartuser_passwd'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> \q
OpenCart2をダウンロードして解凍します
Webサイトのルートディレクトリを作成し、OpenCart2zipファイルを抽出します
user@myVPS:~# mkdir -p ~/your_shop.com user@myVPS:~# cd ~/your_shop.com user@myVPS:~# wget https://github.com/opencart/opencart/archive/2.0.1.1.zip user@myVPS:~# unzip 2.0.1.1.zip user@myVPS:~# mv opencart-2.0.1.1/upload/* . user@myVPS:~# rm -rf opencart-2.0.1.1 2.0.1.1.zip
PHPとNginxをインストールして構成する
PHPとNginxのインストールは非常に簡単です。次のコマンドを実行するだけです:
user@myVPS:~# sudo apt-get install nginx php5-fpm php5-cli php5-mcrypt php5-gd php5-mysqlnd php5-curl user@myVPS:~# sudo php5enmod mcrypt
ユーザー用に新しいPHP-FPMプールを作成します:
user@myVPS:~# sudo vim /etc/php5/fpm/pool.d/your_user.conf
[your_user] user = your_user group = your_user listen = /var/run/php5-fpm-your_user.sock listen.owner = your_user listen.group = your_user listen.mode = 0666 pm = ondemand pm.max_children = 5 pm.process_idle_timeout = 10s; pm.max_requests = 200 chdir = /
your_userを自分のユーザー名に変更することを忘れないでください。
PHP-FPMを再起動します
user@myVPS:~# sudo service php5-fpm restart
SSL証明書を生成する:
user@myVPS:~# sudo mkdir -p /etc/nginx/ssl user@myVPS:~# cd /etc/nginx/ssl user@myVPS:~# sudo openssl genrsa -des3 -passout pass:x -out opencart.pass.key 2048 user@myVPS:~# sudo openssl rsa -passin pass:x -in opencart.pass.key -out opencart.key user@myVPS:~# sudo rm opencart.pass.key user@myVPS:~# sudo openssl req -new -key opencart.key -out opencart.csr user@myVPS:~# sudo openssl x509 -req -days 365 -in opencart.csr -signkey opencart.key -out opencart.crt
次に、新しいNginxサーバーブロックを作成します:
user@myVPS:~# sudo vim /etc/nginx/sites-available/your_shop.com
server {
listen 80;
server_name www.your_shop.com;
add_header Strict-Transport-Security max-age=2592000;
return 301 http://your-shop.com$request_uri;
}
server {
listen 80;
server_name your_shop.com;
root /home/your_user/your_shop.com;
index index.html index.htm index.php;
charset utf-8;
access_log /var/log/nginx/your_shop.com.access.log;
error_log /var/log/nginx/your_shop.com.error.log;
rewrite /admin$ $scheme://$host$uri/ permanent;
location / {
try_files $uri @opencart;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location /admin {
index index.php;
}
rewrite ^/sitemap.xml$ /index.php?route=feed/google_sitemap last;
rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last;
rewrite ^/download/(.*) /index.php?route=error/not_found last;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
sendfile off;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm-your_user.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}
server {
listen 443 ssl spdy;
server_name www.your_shop.com;
ssl on;
ssl_certificate /etc/nginx/ssl/opencart.crt;
ssl_certificate_key /etc/nginx/ssl/opencart.key;
return 301 https://your-shop.com$request_uri;
}
server {
listen 443 ssl spdy;
server_name your_shop.com;
ssl on;
ssl_certificate /etc/nginx/ssl/opencart.crt;
ssl_certificate_key /etc/nginx/ssl/opencart.key;
ssl_session_timeout 5m;
ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
root /home/your_user/your_shop.com;
index index.html index.htm index.php;
charset utf-8;
access_log /var/log/nginx/your_shop.com.ssl.access.log;
error_log /var/log/nginx/your_shop.com.ssl.error.log;
rewrite /admin$ $scheme://$host$uri/ permanent;
location / {
try_files $uri @opencart;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location /admin {
index index.php;
}
rewrite ^/sitemap.xml$ /index.php?route=feed/google_sitemap last;
rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last;
rewrite ^/download/(.*) /index.php?route=error/not_found last;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
sendfile off;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm-your_user.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}
your_userを自分のユーザー名に変更することを忘れないでください。
シンボリックリンクを作成してサーバーブロックをアクティブ化し、Nginxを再起動します:
user@myVPS:~# sudo ln -s /etc/nginx/sites-available/your_shop.com /etc/nginx/sites-enabled/your_shop.com user@myVPS:~# sudo /etc/init.d/nginx restart
OpenCart2をインストールする
空の構成ファイルを作成します:
user@myVPS:~# cd ~/your_shop.com
user@myVPS:~# touch {admin,.}/config.php ブラウザを開き、アドレスを入力して、インストールウィザードに従います。インストールプロセス中に、mysqlデータベース、ユーザー名、およびパスワードを入力するように求められます(前の手順で作成したmysqlデータベース、ユーザー名、およびパスワードを入力してください)。
SSLを有効にする
インストールが完了してSSLを有効にしたら、管理ダッシュボードにログインし、System -> Settings -> Server Tab and select Use SSLを選択します。 保存をクリックします。また、config.phpファイルで次の変更を行う必要があります。
user@myVPS:~# vim ~/your_shop.com/config.php
define('HTTPS_SERVER', 'http://your_shop.com/');を変更します
to define('HTTPS_SERVER', 'https://your_shop.com/');
それでおしまい。これで、UbuntuVPSにOpenCart2が正常にインストールされました。 OpenCart 2の詳細については、OpenCartのWebサイトを参照してください。
もちろん、Linux VPSホスティングサービスのいずれかを使用している場合は、これを行う必要はありません。その場合は、専門のLinux管理者にセットアップを依頼するだけです。 24時間年中無休でご利用いただけます。リクエストはすぐに処理されます。
PS 。この投稿が気に入った場合は、左側のボタンを使用してソーシャルネットワーク上の友達と共有するか、下に返信を残してください。ありがとう。