While migrating my server data to anther server, Permission denied /home/.htaccess pcfg_openfile unable, I got this error. while restarting apache server I got following error.
[Mon Apr 25 12:15:41 2016] [crit] [client 115.117.45.10] (13)Permission denied: /home/purab/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
Background, I am using centos (Linux) for hosting my sites and I am using user defined directory and apache 2.4 version for server.
I was not using .htaccess file in that location, still I was getting this error. Easy solution will be disable .htaccess setting httpd.conf file If we are planning not to use the htaccess file in our project. I found many solutions but that didn’t solved my issue. above issue is specific to file permission.
If it isn’t obvious that .htaccess cannot be read by the server (either 0755 or .htacess and the rest of the tree is in www-data group), search for a higher directory root only onwer:group which does *not* have world execute access.
In order for apache to find a file, it has to search down the tree. It cannot do this if a directory which is root:root does not have global execute access.
I executed following command to change ownership of public_html folder.
chown apache -R /home/purab
usermod -a -G /home/purab apache
After this I restarted my apache server using following command.
/etc/init.d/httpd restart
Using above command, it solved my issue. But purab user cannot edit the files in purab folder. So I used setfacl command.
What is setfacl command?
This utility sets Access Control Lists (ACLs) of files and directories. On the command line, a sequence of commands is followed by a sequence of files (which in turn can be followed by another sequence of commands, …).
The options -m, and -x expect an ACL on the command line. Multiple ACL entries are separated by comma characters (‘,’). The options -M, and -X read an ACL from a file or from standard input. The ACL entry format is described in Section ACL ENTRIES.
Finally I executed following command which solved my issue.
Using above command I kept purab directory permission to purab user again so purab user has all permission of directory. Using setfacl command I given permission to apache user for read, write and execute permission. It worked for me and solved my issue.
In this tutorial we are going to tell you how to install php mysql apache on centos 7 with very easy and simple steps and guide.
LAMP is becoming more popular these day. Many people are using LAMP for server solutions.
Add EPEL-7 to your linux os with latest phpMyadmin.
Now time to test php and apache version.
The document root of the default website is /var/www/html. We can create info.php file and put in document root folder
vi /var/www/html/info.php
put following code in that file
<?php echo phpinfo(); ?>
Now we call that file in a browser (e.g. http://192.168.0.109/info.php):
Now we can install some useful PHP moduels which can be required for CMS Systems like WordPress, Joomla and Drupal:
In the article we will tell you to install apache 2.4, php 5.5 and mysql on centos 6/7 with this we will guide you about installing phpmyadmin and related php and mysql modules.
LMAP is becoming more and more popular these days. People are using more vps and dedicated servers for their sites and applications. PHP backend is became more popular so here in this post we will tell you about installation on linux system’s.
Here I am using centos 6 for installation. From sept 2015 php 5.4 is no longer supported by PHP team so people are trying to install PHP 5.5+ version for good security and performance purpose on their linux servers.
install apache 2.4, php 5.5 and mysql on centos 6/7
Install Remi Repository
Remi is a repository where you can find the latest versions of the PHP in this repository we can find latest programs and dependencies.
Do not forget to accept installation and type Y when you asked while installation. After installation run following command which will be useful while rebooting server(linux). After rebooting server following service will automatically started. —— Enable Apache and MySQL on Boot ——
# chkconfig --levels 235 httpd on
# chkconfig --levels 235 mysqld on
There are many caching solution available in open source. But Varnish is best in among. In this article, We given full steps to use and install varnish with wordpress and apache server . varnish setup with your wordpress site. Many website webmasters installed Varnish on their production servers to handle millions of requests without delay in response. There are many caching plugin like W3 Total Cache, WP Super Cache, Hyper Cache and so many..
Varnish is free open source software licensed under a two-clause BSD licence aimed to really super boost server performance. In short, it will work as web accelerator between any server that speaks with HTTP (Apache or any other).
Why Apache or Nginx is Enough to Handle Huge Traffic
Many system administrator do many tricks with Apache because it performs really bad when the server is getting very high requests. Some people started using other servers like Ngnix and LiteSpeed. WordPress itself are using Ngnix server for many years for production environment. But still performance and response time of website is not that much fast with these plugins. So Best solution is Varnich Cache.
Varnish Explained Here
Vanish server started working on top of Apache server. When HTTP request comes to server first it will go the varnish server, If Vanish server has the response in memory cache then it will give response immediately, If Varnish server does not has cache for that request then it will go to apache server and get the response and keep in cache. Next request will delivered by Varinish cache, which will be so fast. Using varnish cache you can increase your server performance and response time by 300 to 900x. I personally checked response time difference. Before installing varnish cache my server response time was 3.46 second. After installing Varnish Cache, my server response time was 0.3, Means My server response increased by 1000x.
In following diagram, we explained, how varnish server process request.
Why install varnish with wordpress
It will reduce server load , by reducing CPU work
It will load your load your WordPress website very fast, because vanish cache stored in RAM.
Your wordpress site SEO will increase, Because your site will load so fast
Response time will reduce by 1000x
Google page speed response score improves by at-least 20%
how to install varnish with wordpress and apache
Note: You can use this tutorial for setup varnish with any apache website. If you used HTML, ROR, JAVA, PHP for your website than you can set up varinish as we shown in this article. Here, we are assuming you already installed wordpress with apache server on linux server.
We are using dedicated Linux (centos) server for hosting our sites. So here we given steps can be applicable for Red Hat, Centos, Fedora, ubuntu server. But for ubuntu server you need use “apt-get install” instead of yum install.
So now Just follow my steps to install the varnish server. For latest version of Linux, you don’t need to install repository. But for older linux version you need to install the Varnish server repository. For that use following command to install varnish repository.
Than you will be ready for install varnish server. Use following command for installing varnish server. You need to run following command as root. So first became root.
yum install varnish
Configure Varnish to work on port 80
usually Apache run on port 80 and your all sites will run on port 80. So as I told you earlier in this article. (check Varnish Explained section) Varnish work on top of apache server So you need to set up varnish on port 80. In CentOS, RedHat, Fedora, and Ubuntu server, Varnish configuration file located in “/etc/sysconfig/varnish”. You can edit file using vim or vi editor or you can download file to your PC and edit it then upload to server.
I am using vim here.
vim /etc/sysconfig/varnish
Please change files first part code as per I shown in image. OR you can download setting file from here:
[viral-lock message=”Download Link is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
Got to “Alternative 2” section and change setting as I shown in image. Un-comment all the lines after “Alternative 2” as I shown.
By default -s setting will be pointed to filesystem, change that to memory. This is important, because we want, varnish give response from memory.
you need to change “-a : 6081 \” to “-a : 80 \” as we shown here in image. You can change “256m” to higher number, which is depends on your server configuration. If you have higher memory server then you can 512mb or 1GB for Varnish server. Many websites are using 4gb for varinsh servers. But they have a huge amount of traffic.
Second Part of configuration – go to end of file, using “shit+g” key. Change configuration as per I shown.
Got to “Alternative 3” section and change setting as I shown in image. Comment all the lines after “Alternative 3”
Change server config of Varnish
Like Apache server, Varnish server VCL file found in “/etc/varnish/default.vcl” location. Varnish VCL file is configuration for looking for apache(server) response data(content). You can edit this file using vim editor as per shown in following image OR you can download file from following location.
[viral-lock message=”Download Link is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
Change the port 80 to 8080 port as We shown in image. Means Varnish server will generate cache from port 8080 so you need configure your apache server on port 8080.
Now Varnish configuration is complete. Now we need to configure apache server to send apache in back of varnish server.
You need to change following setting of your apache server. By default apache config file is htttpd.conf or apache.conf file. You will find this file in “/etc/httpd/conf/httpd.conf” location. For ubuntu that will be other location. Open your apache config file.
You can download apache configuration file from here. You can refer only “custom.conf” file. it has all changed configuration.
We created custom.conf file and added under “/etc/httpd/conf.d/” folder. So that file will be automatically loaded in apache config.
You can add following code in your apache configuration file as we shown in following image. You need to change the NameVirtualHost 80 to 8080. So your apache server will run on port 8080.
You need to change VirtualHost entries for each of your domain. This is very important, If you do not change this properly then your apache server will through error while restarting.
Now your Varnish and Apache configuration are done. So time to restart both servers.
First Stop the Apache server and start the Varnish server. After starting Varnish server. Again start the apache server. You can use following commands step by step. Use commands in following order.
service httpd stop
service varnish start
service httpd start
Note: If you try to start varnish server without stopping apache server then it will never start because it will try to start using port 80.
Test Website performance and response time
How can you test your site pages speed and response time. Go to following “Google pagespeed” URL to test the website response time.
Check Varnish service is running for your site. go to following URL and add your website URL in inputbox and select “service scan” checkbox and click on go button.
You will get response as shown in following image.
As per explained in this article. After varnish configuration, your website will perform much faster then earlier and server CPU will not be consumed by apache server. We are using small dedicated server so we used only 256mb memory. If you have 1gb RAM of our server then use 256mb means one-fourth of memory for varnish server. When you have all code and database of same server.
Varnish Useful commands
# varnishlog : Provides detailed information on requests.
# varnishtop : It reads varnishd shared memory logs and presents a most commonly occurring log entries.
# varnishadm : Command-line varnish administration used to reload vcl and purge urls.
# varnishstat : Provides all the info you need to spot cache misses and errors.
# varnishhist : Provides a histogram view of cache hits/misses.
By “varnishstat” command you can check real-time statistics of varnish server. You can see following items
Client connection
Hit rate ration
Hit rate average
Number of client connections accepted
Following is screenshot of my production site. There are a lot of useful data provided by varnish stats
Create Varnish Log File
Using following command you can create varnish request log file as per apache log file. In this file you will get similar information like apache access log.
varnishncsa -c -a -d -w /var/log/varnish/varnish.log
For more varnish commands you can go to varnish site using following URL.
Now you are set with varnish server and wordpress site. Above article can be used for any linux distribution like, Fedora, Ubuntu, Centos, RedHat and Suse. Commands will be same and configuration will be same.
In wordpress configuration you do not need to change anything. With Varnish server .htaccess file will not break because still main webserver is apache.
If you still need assistance to install Varnish server and configure production server then contact to me.
For putting the web authentication we always use the .htaccess or apache configuration file. For removing the web auth from folder you need put following code in .htaccess file.
How to remove the AuthType Basic
<Directory /var/www/html/>
#AuthType Basic
#AuthName "By Invitation Only"
#AuthUserFile /etc/httpd/passwd/passwords
#Require user wpapi
#Require valid-user
</Directory>
<Directory /var/www/html/>
AuthType None
Require all granted
Satisfy Any
</Directory>
Sometimes we need the redirection rule for your website. When you want to divert your website traffic to another site.
That is very easy to writing or putting the one site to another site redirection rule through apache.
apache redirect one domain to another site
You need to put entry in your virtual host section or if you are having shared hosting then open your .htaccess file and put following entry in that file
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
You just change newdomain.com to your new website name.
how to prevent direct access to images. To protect your images or media file you should use apache rewrite rules. To protect being linked on another website. To protect your images or media file you should use apache rewrite rules. To protect your images or other files from being linked or used on another website. Due the this issue your images may be used by many sites.
how to prevent direct access to images
The Apache Server’s Mod Rewrite Engine can examine the name of the document requesting a file of a particular type. If the URL of the page requesting the image file is from an allowed domain, display the image. Otherwise, return a broken image.
There are many people who try to use your website images. That will cut your bandwidth so using this code is good idea.
You can use following apache code in apche config file or put following code in your .htaccess file.
Second thing you should do. you should create the dummy index.html file and put in your images folder for so any visitor will not see the directory listing of images.
If you use above code then when other domain try to see or use the your images then they will see the following error message.
it will result in a Forbidden error.
Still if you are having any issue or question then write to me.
Confused how to configure load balancer on Amazon. Here we given you detail instructions about How to configure haproxy load balancing on amazon EC2
Many people take amazon EC2 cloud hosting. Amazon does gives the load balancer for application load balancing. But Amazon load balancer is not that much good. Amazon load balancer is not working on hardware or software base. That balancer just sending request to server one by one. Many people confused how to configure load balancer on Amazon EC2.
Here I am going to give you detail instructions about setting up the HaProxy load balancer on Amazon EC2.
How to configure haproxy load balancing on amazon ec2
What is Haproxy?
AProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for web sites crawling under very high loads while needing persistence or Layer7 processing. Supporting tens of thousands of connections is clearly realistic with todays hardware. Its mode of operation makes its integration into existing architectures very easy and riskless.
For Haproxy load balancing I recommend to create the micro instance first. Then login to micro instance and install haproxy on that machine. I taken the Centos 5.0 virgin os. Use following command for install the haproxy.
#yum install haproxy
Then Open the haproxy config file.
# vi /etc/haproxy.cfg
For detail configuration you should read the Haproxy config documentation.
Haproxy’s default load balancing style is roundrobin. Which is trusted and good. With this load balancing I am serving around two million pages daily. Means I am handling 6 to 7 million requests per day. I am not having any issues.
I used the three backend server for delivery of my application and one server for serving the static data which is having images and js and css and application files.
Here is my configuration file
global
maxconn 4096 # Total Max Connections. This is dependent on ulimit
daemon
nbproc 4 # Number of processing cores. Dual Dual-core Opteron is 4 cores for example.
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option dontlognull
option httpclose
option httplog
option forwardfor
option redispatch
timeout connect 10000 # default 10 second time out if a backend is not found
timeout client 300000
timeout server 300000
maxconn 60000
retries 3
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
#frontend main *:80
frontend http-in
bind :80
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
acl url_stats path_beg /haproxy-stats
use_backend be_stats if url_stats
use_backend static if url_static
default_backend app
#-------------------------------------------------
#back-end statistics section
#----------------------------------------------------------------
backend be_stats
stats uri /haproxy-stats
# stats show-node
#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
balance roundrobin
server static 10.211.164.138:80 check
#server static 10.211.185.111:80 check
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
balance roundrobin
server app1 10.214.284.241:80 check
server app2 10.208.168.131:80 check
server app3 10.212.158.126:80 check
You can use the above code in haproxy.cfg file. You just need to change the IP address which are listed under backend static and backend app section. You just put your static server(amazon EC2 instance’s internal IP address).
You should use internal IP address of server because that will reduce the bandwidth uses of Amazon EC2 server. Do not use the public IP address for load balance because that will cost you.
Put application database and application files on all the server. Point your domain to your load balancer machine’s Public IP address.
Let say your application is running on following domain.
www.YOURDOMAIN.COM – point to Load balancer macine.
Open your all application and static server’s apache configuration file. put following entry in that file.
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName www.YOURDOMAIN.COM
# Other directives here
</VirtualHost>
after this just restart the apache server of all servers.
If you are having any issues or questions about setting up the haproxy on amazon EC2 server Please write to me.
Jmeter is basically used for load testing of web applications. Application Load testing is very important for every application. Jmeter is loved by every QA and testing software professional. If you are QA software professional then you need to know how install on windows or linux box and how use it properly. Here In this tutorial I shown you to how to Jmeter on Linux.
how to install Jmeter on Linux
JMeter is to first download the latest production release and install it. The release contains all of the files you need to build and run most types of tests, e.g. Web (HTTP/HTTPS), FTP, JDBC, LDAP, Java, and JUnit.
If you want to perform JDBC testing, then you will, of course, need the appropriate JDBC driver from your vendor. JMeter does not come with any JDBC drivers.
If you want to install the jmeter on your linux box you need to follow my steps:
[viral-lock message=”Installation steps are Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
1) Goto http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi
2) Download Binary 2.3.4.zip . The zip file name will be “jakarta-jmeter-2.3.4”
3) Paste it in /var/www/html/
4) Unzip “jakarta-jmeter-2.3.4”
5) New folder with name “jakarta-jmeter-2.3.4” will be created
6) Go to command prompt
7) go to “jakarta-jmeter-2.3.4” folder (cd /var/www/html/jakarta-jmeter-2.3.4)
8) go to “bin” folder (cd bin)
9) Now you are in bin folder (i.e /var/www/html/jakarta-jmeter-2.3.4/bin/)
10) type the command “sh jmeter”
11) After a short pause, the JMeter GUI should appear.
[/viral-lock]
After this you can use following commands for load testing.
For non-interactive testing, you may choose to run JMeter without the GUI. To do so, use the following command options
-n This specifies JMeter is to run in non-gui mode
-t [name of JMX file that contains the Test Plan].
-l [name of JTL file to log sample results to].
-r Run the test in the servers specified by the JMeter property “remote_hosts”
-R [list of remote servers] Run the test in the specified remote servers
The script also lets you specify the optional firewall/proxy server information:
-H [proxy server hostname or ip address]
-P [proxy server port]
Now these days keeping www in URL is becoming old fashion. How can check many websites for that and the current example is twitter.com. Using apache rule you can remove the www from url with rewite rule.
How to remove the www from url with rewite rule
I specially dont like to put www in URL so we can easily remove the www from URL.
Open your apache configuration file. If you are using Linux then open file from following location
# vim /etc/httpd/conf/httpd.conf
put following lines in your virtual directory section.