HOW TO INSTALL VARNISH AND PHPMYADMIN ON A CENTOS 7 VPS WITH NGINX, MARIADB AND PHP-FPM
- Category : Server Administration
- Posted on : Jul 06, 2014
- Views : 1,498
- By : Xavier N.
Looking for CentOS help? Visit our CentOS 7 help and tutorials page.
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. Use the following article to install Nginx, MariaDB and PHP-FPM on a CentOS 7 VPS.
Then, it is time to install Varnish and phpMyAdmin.
Enable EPEL Repository:
rpm -Uvh http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpmyum updateyum install varnish phpMyAdmin
Create a self-signed SSL Certificate so you can access phpMyAdmin using SSL:
mkdir -p /etc/nginx/sslcd /etc/nginx/sslopenssl genrsa -des3 -out server.key 1024openssl req -new -key server.key -out server.csrcp server.key server.key.orgopenssl rsa -in server.key.org -out server.keyopenssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
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:
vi /etc/nginx/nginx.confuser 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;}}}
Open ‘/etc/php-fpm.d/www.conf’ and add/modify the following lines:
vi /etc/php-fpm.d/www.conflisten = /var/run/php-fpm/php-fpm.sockuser = nginxgroup = nginx
Edit the ‘/etc/varnish/default.vcl’ file and add/modify the following lines:
vi /etc/varnish/default.vclbackend default {.host = "127.0.0.1";.port = "8080";}
Edit the ‘/etc/varnish/varnish.params’ file:
vi /etc/varnish/varnish.paramsVARNISH_LISTEN_ADDRESS=your_IPVARNISH_LISTEN_PORT=80
Make sure to change ‘your_IP’ with your actual server IP address.
Enable varnish service to start automatically on server boot using the following command:
1 systemctl enable varnish.service
Edit the ‘/etc/phpMyAdmin/config.inc.php’ phpMyAdmin configuration file and modify the following line:
vi /etc/phpMyAdmin/config.inc.php$cfg['Servers'][$i]['auth_type'] = 'http';
Edit ‘php.ini’ and change the ‘session.save_path’ default value to ‘/var/lib/php/session’:
php -i | grep php.iniConfiguration File (php.ini) Path => /etcLoaded Configuration File => /etc/php.ini
|
vi /etc/php.ini
session.save_path = "/var/lib/php/session"
|
Change the ownership of ‘/var/lib/php/session’ directory on your CentOS 7 VPS:
chown -R nginx:nginx /var/lib/php/session
Restart php-fpm, nginx and varnish services:
systemctl restart php-fpmsystemctl restart nginxsystemctl restart varnish
To verify that the Varnish cache is working, check the HTTP response headers:
curl -I http://your_IPHTTP/1.1 200 OKServer: nginx/1.6.1Date: Sat, 16 Aug 2014 00:35:10 GMTContent-Type: text/htmlLast-Modified: Fri, 15 Aug 2014 19:27:58 GMTETag: "53ee5f3e-e74"X-Varnish: 2Age: 0Via: 1.1 varnish-v4Content-Length: 3700Connection: keep-alive
Open https://your_IP/phpMyAdmin/index.php , enter your MariaDB username and password, and start managing your MariaDB databases.
That’s All Enjoy.
Categories
Subscribe Now
10,000 successful online businessmen like to have our content directly delivered to their inbox. Subscribe to our newsletter!Archive Calendar
Sat | Sun | Mon | Tue | Wed | Thu | Fri |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Recent Articles
-
Posted on : Jul 25
-
Posted on : Jul 07
-
Posted on : Apr 07
-
Posted on : Mar 19
Optimized my.cnf configuration for MySQL 8 (on cPanel/WHM servers)
Tags
- layer 7
- tweak
- kill
- process
- sql
- Knowledge
- vpn
- seo vpn
- wireguard
- webmail
- ddos mitigation
- attack
- ddos
- DMARC
- server load
- Development
- nginx
- php-fpm
- cheap vpn
- Hosting Security
- xampp
- Plesk
- cpulimit
- VPS Hosting
- smtp
- smtp relay
- exim
- Comparison
- cpu
- WHM
- mariadb
- encryption
- sysstat
- optimize
- Link Building
- apache
- centos
- Small Business
- VPS
- Error
- SSD Hosting
- Networking
- optimization
- DNS
- mysql
- ubuntu
- Linux