このチュートリアルでは、Nginx、MariaDB、およびPHP-FPMを使用してCentOS7VPSにVarnishキャッシュとphpMyAdminをインストールする方法を示します。 Varnish cacheは、動的なWebサイトを高速化するために作成されたWebアプリケーションアクセラレータです。 phpMyAdminは、Webブラウザを介したMySQLデータベースの管理を処理するために作成されたオープンソースのWebアプリケーションです。
次の記事を使用して、 CentOS 7 VPSにNginx、MariaDB、PHP-FPMをインストールしてください> 。
次に、ワニスをインストールします。 およびphpMyAdmin 。
EPELリポジトリを有効にする:
rpm -Uvh http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm
yum update yum install varnish phpMyAdmin
自己署名SSL証明書を作成して、SSLを使用してphpMyAdminにアクセスできるようにします。
mkdir -p /etc/nginx/ssl cd /etc/nginx/ssl openssl genrsa -des3 -out server.key 1024 openssl req -new -key server.key -out server.csr cp server.key server.key.org openssl rsa -in server.key.org -out server.key openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Nginxがポート8080で実行され、SSL要求がVarnishを経由せずにNginxWebサーバーに直接渡されるようにVarnishを構成します。メインのNginx構成ファイルを変更します:
vi /etc/nginx/nginx.conf
user nginx;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 60;
include /etc/nginx/conf.d/*.conf;
index index.html index.htm;
server {
listen 127.0.0.1:8080;
root /usr/share/nginx/html;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 443;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
location ~* ^/phpMyAdmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/;
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
}
}
を含める 「/etc/php-fpm.d/www.conf」を開き、次の行を追加/変更します。
vi /etc/php-fpm.d/www.conf
listen = /var/run/php-fpm/php-fpm.sock user = nginx group = nginx
「/etc/varnish/default.vcl」ファイルを編集し、次の行を追加/変更します。
vi /etc/varnish/default.vcl
backend default {
.host = "127.0.0.1";
.port = "8080";
} 「/etc/varnish/varnish.params」ファイルを編集します:
vi /etc/varnish/varnish.params
VARNISH_LISTEN_ADDRESS=your_IP VARNISH_LISTEN_PORT=80
必ず「your_IP」を実際のサーバーのIPアドレスに変更してください。
次のコマンドを使用して、サーバーの起動時にワニスサービスが自動的に開始されるようにします。
systemctl enable varnish.service
「/etc/phpMyAdmin/config.inc.php」phpMyAdmin構成ファイルを編集し、次の行を変更します。
vi /etc/phpMyAdmin/config.inc.php $cfg['Servers'][$i]['auth_type'] = 'http';
「php.ini」を編集し、「session.save_path」のデフォルト値を「/ var / lib / php/session」に変更します。
php -i | grep php.ini Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini
vi /etc/php.ini
session.save_path = "/var/lib/php/session"
CentOS 7 VPSの「/var/ lib / php/session」ディレクトリの所有権を変更します :
chown -R nginx:nginx /var/lib/php/session
php-fpm、nginx、およびニスサービスを再起動します:
systemctl restart php-fpm
systemctl restart nginx
systemctl restart varnish
Varnishキャッシュが機能していることを確認するには、HTTP応答ヘッダーを確認します。
curl -I http://your_IP HTTP/1.1 200 OK Server: nginx/1.6.1 Date: Sat, 16 Aug 2014 00:35:10 GMT Content-Type: text/html Last-Modified: Fri, 15 Aug 2014 19:27:58 GMT ETag: "53ee5f3e-e74" X-Varnish: 2 Age: 0 Via: 1.1 varnish-v4 Content-Length: 3700 Connection: keep-alive
https://your_IP/phpMyAdmin/index.phpを開き、MariaDBのユーザー名とパスワードを入力して、MariaDBデータベースの管理を開始します。
もちろん、Linux VPSホスティングサービスのいずれかを使用している場合は、これを行う必要はありません。その場合は、専門のLinux管理者に LEMP、Varnishのインストールを依頼するだけです。 およびphpMyAdmin あなたのために。 24時間年中無休でご利用いただけます。リクエストはすぐに処理されます。
PS。 この投稿が気に入った場合は、左側のボタンを使用してソーシャルネットワーク上の友達と共有するか、下に返信を残してください。ありがとう。