アンドロイド

CentOS 7でApacheを使用してWordPressをインストールする方法

Install CentOS 8 in VirtualBox and Get Full Screen Mode (100% working)

Install CentOS 8 in VirtualBox and Get Full Screen Mode (100% working)

目次:

Anonim

WordPressは、世界で最も人気のあるオープンソースのブログおよびCMSプラットフォームであり、今日のインターネット上のすべてのWebサイトの4分の1を支えています。 PHPとMySQLに基づいており、無料のプレミアムプラグインとテーマを使用して拡張できる機能が満載です。 WordPressは、オンラインストア、ウェブサイト、またはブログを作成する最も簡単な方法です。

このチュートリアルでは、CentOS 7にWordPressをインストールする方法を説明します。この記事を書いている時点で、WordPressの最新バージョンはバージョン5.0.3です。

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

前提条件

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

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

MySQLデータベースの作成

WordPressはそのデータと設定をMySQLデータベースに保存します。 CentOSサーバーにMySQLまたはMariaDBがまだインストールされていない場合は、以下のガイドのいずれかに従ってインストールできます。

  • CentOS 7にMySQLをインストールします。CentOS7にMariaDBをインストールします。

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

mysql -u root -p

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

CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

次に、 wordpressuser という名前のMySQLユーザーアカウントを作成し、次のコマンドを実行してユーザーに必要な権限を付与します。

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

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

EXIT;

Wordpressをダウンロードする

次のコマンドは、wgetを使用してWordPressダウンロードページからWordPressの最新バージョンをダウンロードし、ドメインのドキュメントルートディレクトリにアーカイブを抽出します。

wget -q -O - "http://wordpress.org/latest.tar.gz" | sudo tar -xzf - -C /var/www/html --transform s/wordpress/example.com/

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

sudo chown -R apache: /var/www/html/example.com

Apacheの構成

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

テキストエディターを開き、ドメインのApache仮想ホストの構成を編集します。

sudo nano /etc/httpd/conf.d/example.com.conf

example.com をWordpressドメインに置き換え、SSL証明書ファイルへの正しいパスを設定することを忘れないでください。

/etc/httpd/conf.d/example.com.conf

ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ DirectoryIndex index.html index.php DocumentRoot /var/www/html/example.com ErrorLog /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/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 Redirect permanent / https://example.com/ DirectoryIndex index.html index.php DocumentRoot /var/www/html/example.com ErrorLog /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/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 Redirect permanent / https://example.com/ DirectoryIndex index.html index.php DocumentRoot /var/www/html/example.com ErrorLog /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/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 Redirect permanent / https://example.com/ DirectoryIndex index.html index.php DocumentRoot /var/www/html/example.com ErrorLog /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/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 Redirect permanent / https://example.com/ DirectoryIndex index.html index.php DocumentRoot /var/www/html/example.com ErrorLog /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/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

設定は、 http https にリダイレクトし、 www をドメインの non-www バージョンにリダイレクトするようApacheに指示します。

Apacheサービスを再起動して、変更を有効にします。

sudo systemctl restart

WordPressインストールの完了

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

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

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

結論

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

CentOSワードプレスmysql mariadb cms apache