{"id":4215,"date":"2014-08-16T12:03:00","date_gmt":"2014-08-16T17:03:00","guid":{"rendered":"https:\/\/secure.rosehosting.com\/blog\/?p=4215"},"modified":"2022-12-30T02:47:11","modified_gmt":"2022-12-30T08:47:11","slug":"how-to-install-varnish-and-phpmyadmin-on-a-centos-7-vps-with-nginx-mariadb-and-php-fpm","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-varnish-and-phpmyadmin-on-a-centos-7-vps-with-nginx-mariadb-and-php-fpm\/","title":{"rendered":"How to install Varnish and phpMyAdmin on a CentOS 7 VPS with Nginx, MariaDB and PHP-FPM"},"content":{"rendered":"
In this tutorial, we will show you how to install Varnish cache and phpMyAdmin on a CentOS 7 VPS with Nginx, MariaDB and PHP-FPM. Varnish cache is a web application accelerator created for speeding up dynamic web sites. phpMyAdmin is an open-source web application, created to handle the administration of MySQL databases through a web browser. <\/p>\n Then,\u00a0it is time to install Varnish <\/strong>and phpMyAdmin<\/strong>.<\/p>\n Enable EPEL Repository:<\/p>\n Create a self-signed SSL Certificate so you can access phpMyAdmin using SSL:<\/p>\n Configure Varnish to run on port 80 while Nginx on port 8080 and pass the SSL requests straight through to Nginx web server without having to pass it through Varnish. Modify the main Nginx configuration file:<\/p>\n Open ‘\/etc\/php-fpm.d\/www.conf’ and add\/modify the following lines:<\/p>\n Edit the ‘\/etc\/varnish\/default.vcl’ file and add\/modify the following lines:<\/p>\n Edit the ‘\/etc\/varnish\/varnish.params’ file:<\/p>\n Make sure to change ‘your_IP’ with your actual server IP address.<\/p>\n Enable varnish service to start automatically on server boot using the following command:<\/p>\n Edit the ‘\/etc\/phpMyAdmin\/config.inc.php’ phpMyAdmin configuration file and modify the following line:<\/p>\n Edit ‘php.ini’ and change the ‘session.save_path’ default value to ‘\/var\/lib\/php\/session’:<\/p>\n Change the ownership of ‘\/var\/lib\/php\/session’ directory on your CentOS 7 VPS<\/a><\/strong>:<\/p>\n Restart php-fpm, nginx and varnish services:<\/p>\n systemctl restart php-fpm To verify that the Varnish cache is working, check the HTTP response headers:<\/p>\n Open https:\/\/your_IP\/phpMyAdmin\/index.php , enter your MariaDB username and password, and start managing your MariaDB databases.<\/p>\n Of course you don\u2019t have to do any of this if you use one of our Linux VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install LEMP, Varnish <\/strong>and phpMyAdmin <\/strong>for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n PS<\/span>.<\/strong> If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":" In this tutorial, we will show you how to install Varnish cache and phpMyAdmin on a CentOS 7 VPS with … <\/p>\n
\nUse the following article to install Nginx, MariaDB and PHP-FPM<\/a> on a CentOS 7 VPS<\/a><\/strong>.<\/p>\nrpm -Uvh http:\/\/dl.fedoraproject.org\/pub\/epel\/beta\/7\/x86_64\/epel-release-7-0.2.noarch.rpm<\/pre>\n
yum update\r\nyum install varnish phpMyAdmin<\/pre>\n
mkdir -p \/etc\/nginx\/ssl\r\ncd \/etc\/nginx\/ssl\r\nopenssl genrsa -des3 -out server.key 1024\r\nopenssl req -new -key server.key -out server.csr\r\ncp server.key server.key.org\r\nopenssl rsa -in server.key.org -out server.key\r\nopenssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt<\/pre>\n
vi \/etc\/nginx\/nginx.conf<\/pre>\n
user nginx;\r\nworker_processes 2;\r\n\r\nerror_log \/var\/log\/nginx\/error.log;\r\n\r\npid \/run\/nginx.pid;\r\n\r\nevents {\r\n worker_connections 1024;\r\n}\r\n\r\n\r\nhttp {\r\n include \/etc\/nginx\/mime.types;\r\n default_type application\/octet-stream;\r\n\r\n log_format main '$remote_addr - $remote_user [$time_local] \"$request\" '\r\n '$status $body_bytes_sent \"$http_referer\" '\r\n '\"$http_user_agent\" \"$http_x_forwarded_for\"';\r\n\r\n access_log \/var\/log\/nginx\/access.log main;\r\n\r\n sendfile on;\r\n\r\n keepalive_timeout 60;\r\n\r\n include \/etc\/nginx\/conf.d\/*.conf;\r\n\r\n index index.html index.htm;\r\n\r\n server {\r\n listen 127.0.0.1:8080;\r\n root \/usr\/share\/nginx\/html;\r\n location \/ {\r\n }\r\n\r\n error_page 404 \/404.html;\r\n location = \/40x.html {\r\n }\r\n\r\n error_page 500 502 503 504 \/50x.html;\r\n location = \/50x.html {\r\n }\r\n\r\n location ~ \\.php$ {\r\n root \/usr\/share\/nginx\/html;\r\n fastcgi_split_path_info ^(.+\\.php)(.*)$;\r\n fastcgi_pass unix:\/var\/run\/php-fpm\/php-fpm.sock;\r\n fastcgi_index index.php;\r\n fastcgi_param SCRIPT_FILENAME $document_root\/$fastcgi_script_name;\r\n include fastcgi_params;\r\n}\r\n }\r\n\r\n\r\nserver {\r\n listen 443;\r\n\r\n ssl on;\r\n ssl_certificate \/etc\/nginx\/ssl\/server.crt;\r\n ssl_certificate_key \/etc\/nginx\/ssl\/server.key;\r\n\r\n ssl_session_timeout 5m;\r\n\r\n ssl_protocols SSLv2 SSLv3 TLSv1;\r\n ssl_ciphers HIGH:!aNULL:!MD5;\r\n ssl_prefer_server_ciphers on;\r\n\r\nlocation \/ {\r\nroot html;\r\nindex index.html index.htm;\r\n}\r\nlocation ~* ^\/phpMyAdmin\/(.+\\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root \/usr\/share\/;\r\n}\r\n\r\nlocation ~ \\.php$ {\r\n root \/usr\/share\/nginx\/html;\r\n fastcgi_split_path_info ^(.+\\.php)(.*)$;\r\n fastcgi_pass unix:\/var\/run\/php-fpm\/php-fpm.sock;\r\n fastcgi_index index.php;\r\n fastcgi_param SCRIPT_FILENAME $document_root\/$fastcgi_script_name;\r\n include fastcgi_params;\r\n}\r\n}\r\n}\r\n<\/pre>\n
vi \/etc\/php-fpm.d\/www.conf<\/pre>\n
listen = \/var\/run\/php-fpm\/php-fpm.sock\r\nuser = nginx\r\ngroup = nginx<\/pre>\n
vi \/etc\/varnish\/default.vcl<\/pre>\n
backend default {\r\n .host = \"127.0.0.1\";\r\n .port = \"8080\";\r\n}<\/pre>\n
vi \/etc\/varnish\/varnish.params<\/pre>\n
VARNISH_LISTEN_ADDRESS=your_IP\r\nVARNISH_LISTEN_PORT=80<\/pre>\n
systemctl enable varnish.service<\/pre>\n
vi \/etc\/phpMyAdmin\/config.inc.php\r\n\r\n$cfg['Servers'][$i]['auth_type'] = 'http';<\/pre>\n
php -i | grep php.ini\r\nConfiguration File (php.ini) Path => \/etc\r\nLoaded Configuration File => \/etc\/php.ini<\/pre>\n
vi \/etc\/php.ini<\/pre>\n
session.save_path = \"\/var\/lib\/php\/session\"<\/pre>\n
chown -R nginx:nginx \/var\/lib\/php\/session<\/pre>\n
\nsystemctl restart nginx
\nsystemctl restart varnish<\/p>\ncurl -I http:\/\/your_IP\r\n\r\nHTTP\/1.1 200 OK\r\nServer: nginx\/1.6.1\r\nDate: Sat, 16 Aug 2014 00:35:10 GMT\r\nContent-Type: text\/html\r\nLast-Modified: Fri, 15 Aug 2014 19:27:58 GMT\r\nETag: \"53ee5f3e-e74\"\r\nX-Varnish: 2\r\nAge: 0\r\nVia: 1.1 varnish-v4\r\nContent-Length: 3700\r\nConnection: keep-alive<\/pre>\n