アンドロイド

ubuntu 18.04にapacheでwordpressをインストールする方法

2 месяца с Ubuntu 18.04 LTS - так ли она хороша?

2 месяца с Ubuntu 18.04 LTS - так ли она хороша?

目次:

Anonim

WordPressは、世界のWebサイトの4分の1を超える、最も人気のあるオープンソースのブログおよびCMSプラットフォームです。 PHPとMySQLに基づいており、無料のプレミアムプラグインとテーマを使用して拡張できる機能が満載です。 WordPressを使用すると、eコマースストア、Webサイト、ポートフォリオ、またはブログを簡単に構築できます。

このチュートリアルでは、Ubuntu 18.04マシンにWordPressをインストールする方法を示します。 完了するのに10分もかからない、かなり簡単なプロセスです。 この記事の執筆時点で、WordPressの最新バージョンはバージョン5.0.2です。

ApacheをWebサーバー、SSL証明書、最新のPHP 7.2、MySQL / MariaDBをデータベースサーバーとして使用したLAMPスタックを使用します。

前提条件

このチュートリアルを続行する前に、次の前提条件が満たされていることを確認してください。

  • サーバーのパブリックIPを指すドメイン名を持っています。 example.com を使用し example.com 。sudo権限を持つユーザーとしてログインします。以下の手順に従ってApacheをインストールします。ドメインにSSL証明書がインストールされています。 以下の手順に従って、無料のLet's Encrypt SSL証明書をインストールできます。

パッケージリストを更新し、インストールされたパッケージを最新バージョンにアップグレードします。

sudo apt update sudo apt upgrade

MySQLデータベースの作成

WordPressはMySQLデータベースを使用して、投稿、ページ、ユーザー、プラグイン、テーマ設定などのすべてのデータを保存します。 まず、MySQLデータベースとMySQLユーザーアカウントを作成し、データベースへのアクセスを許可します。

UbuntuサーバーにMySQLまたはMariaDBがインストールされていない場合は、以下のガイドのいずれかに従ってそれを行うことができます。

次のコマンドを入力して、MySQLシェルにログインします。

sudo mysql

MySQLシェル内から、次のSQLステートメントを実行してデータベースを作成します。

CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

次に、MySQLユーザーアカウントを作成し、データベースへのアクセスを許可します。

GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'change-with-strong-password';

最後に、次のように入力してmysqlコンソールを終了します。

EXIT

PHPのインストール

Ubuntu 18.04のデフォルトのPHPバージョンであるPHP 7.2は、WordPressで完全にサポートされ、推奨されています。

PHPおよび必要なすべてのPHP拡張機能をインストールするには、次のコマンドを実行します。

sudo apt install php7.2 php7.2-cli php7.2-mysql php7.2-json php7.2-opcache php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl

新しくインストールされたPHP拡張がロードされるように、apacheを再起動します。

sudo systemctl restart apache2

Wordpressをダウンロードする

Wordpressアーカイブをダウンロードする前に、まずWordPressファイルを保持するディレクトリを作成します。

sudo mkdir -p /var/www/example.com

次の手順では、次のwgetコマンドを使用して、WordPressダウンロードページから最新バージョンのWordPressをダウンロードします。

cd /tmp wget

ダウンロードが完了したら、アーカイブを抽出し、抽出したファイルをドメインのドキュメントルートディレクトリに移動します。

tar xf latest.tar.gz sudo mv /tmp/wordpress/* /var/www/example.com/

次のchownコマンドを使用して、Webサーバーがサイトのファイルとディレクトリにフルアクセスできるように、正しいアクセス許可を設定します。

sudo chown -R www-data: /var/www/example.com

Apacheの構成

このチュートリアルの前提条件を確認していない場合は、すでにSSL証明書付きのApacheがシステムにインストールされているはずです。

次のステップは、WordPressドメインのApache仮想ホスト設定を編集することです。

sudo nano /etc/apache2/sites-available/example.com.conf

次のApache構成は、 http https リダイレクトし、 www をドメインの non-www バージョンにリダイレクトし、HTTP2を有効にします。 example.com をWordpressドメインに置き換え、SSL証明書ファイルへの正しいパスを設定することを忘れないでください。

/etc/apache2/sites-available/example.com.conf

ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DirectoryIndex index.html index.php DocumentRoot /var/www/example.com ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem Options FollowSymLinks AllowOverride All Require all granted ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DirectoryIndex index.html index.php DocumentRoot /var/www/example.com ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem Options FollowSymLinks AllowOverride All Require all granted ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DirectoryIndex index.html index.php DocumentRoot /var/www/example.com ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem Options FollowSymLinks AllowOverride All Require all granted ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DirectoryIndex index.html index.php DocumentRoot /var/www/example.com ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem Options FollowSymLinks AllowOverride All Require all granted ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DirectoryIndex index.html index.php DocumentRoot /var/www/example.com ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem Options FollowSymLinks AllowOverride All Require all granted

ドメインの仮想ホストを有効にします。 以下のコマンドは、 sites-available から sites-enabled ディレクトリへのシンボリックリンクを作成します。

sudo a2ensite example.com

新しい構成を有効にするには、次を入力してApacheサービスを再起動します。

sudo systemctl restart apache2

WordPressインストールの完了

Wordpressがダウンロードされ、サーバー構成が完了したので、Webインターフェースを介してWordPressのインストールを完了します。

ブラウザを開き、ドメインを入力すると、次のような画面が表示されます。

ここから、新しいテーマとプラグインをインストールして、WordPressインストールのカスタマイズを開始できます。

結論

おめでとうございます。これで、Ubuntu 18.04サーバー上にWordPressとApacheが正常にインストールされました。 WordPressの最初のステップは、WordPressの使用を開始する方法について詳しく知るための出発点として適しています。

Ubuntuワードプレスmysql mariadb cms apache