Skip to main content

Posts

Showing posts from January, 2019

Set time and date #Centos #linux

Login to your system with root user or sudo privilege . 1. Type date to confirm the date #date or  $sudo date Copy the output as shown in image 2. Then set the date as follows #date -s  <your desired date and time> #date -s "Thu Jan 31 20:11:13 +0545 2019" or  $sudo date -s "Thu Jan 31 20:11:13 +0545 2019"

server name alias, wildcard, regular expression names #nginx #centos #linux

Server names Wildcard names Regular expressions names Miscellaneous names Internationalized names Optimization Compatibility Server names are defined using the server_name directive and determine which server block is used for a given request. See also “How nginx processes a request”. They may be defined using exact names, wildcard names, or regular expressions: server {     listen       80;     server_name  example.org  www.example.org;     ... } server {     listen       80;     server_name  *.example.org;     ... } server {     listen       80;     server_name  mail.*;     ... } server {     listen       80;     server_name  ~^(?<user>.+)\.example\.net$;     ... } When searching for a virtual server by name, if name matches more than one of the specified variants, e.g. both wildcard name and regular expression match, the first matching variant will be chosen, in the following order of precedence: 1. exact name 2. longest wildcard name start

how to install jmeter in windows 10 #website #load_testing

Step 1: Install Java 8 Download latest Java 8 from Oracle website. You will need to have Oracle account for downloading Java. Run the Java installer package. Verify installed Java version by running this command on Command Prompt. a.     Download Java from the following link and then install . https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html b.   Then set Java home as follows Why do I need to set JAVA_HOME? Many Java based programs like Tomcat require JAVA_HOME to be set as environment variable to work correctly. Please note JAVA_HOME should point to a JDK directory not a JRE one. The point of setting the environment variable is to let programs know in which directory executables like javac can be found. 1. Open Advanced System Settings In Windows 10 press Windows key + Pause Key, This will open the System Settings window. Go to  Change settings  and select the  Advanced  tab. Alternatively: Open “Windows search” – you will

ERROR 1044 (42000): Access denied for user

Unable to import database with user[all permission granted still getting that error] - ERROR 1044 (42000): Access denied for user Solution : Note: Before playing wiht any file to your system make backup then only try 1. First of verify the user with which you are trying to export database 2.Check the database, there might be database name defined in the sql so that would problem lets say you are trying to import database 'xyz.sql' to the test_db <DB name> then vi xyz.sql check the top 10 lines, you might see the defined database name already their. So you need to replace that database name with test_db < i mean you db name> . Possibly, you need to change the older db name with your new db name to which you want to import 3. mysql -u username -p dbname < xyz.sql

CONFIGURE HTTP STRICT TRANSPORT SECURITY (HSTS) ON #APACHE and #NGINX

HOW TO CONFIGURE HTTP STRICT TRANSPORT SECURITY (HSTS) ON APACHE & NGINX What is HTTP Strict Transport Security (HSTS)? HTTP Strict Transport Security (HSTS) is a security policy which is necessary to protect secure HTTPS websites against downgrade attacks. It also aids protection against cookie hijacking. It allows web servers to declare that web browsers should only interact with it using secure HTTPS connections, and never via the insecure HTTP protocol. What are the requirements for HSTS? A minimum of Apache 2.2.22 and NGINX 1.1.19 is required for HSTS. Implications of turning on HSTS? Turning on HSTS is actually a simple process. However, don’t underestimate the implications of turning it on! Firstly, HSTS is a time based system. What this means is that when you enable it you decide how long you are prepared to guarantee that your site will be served over HTTPS. It is advised that this is set to a long time. At least 6 months or longer is recommended. How does H

Permanent URL #redirect http to https #80 #443 #nginx #linux #apache

Configuration for nginx, add this code to /etc/nginx/conf.d/redirect.conf #Nginx server { listen 80; server_name example.com www.example.com; return 301 https://$server_name$request_uri; } Configuration for APACHE, add this code to /etc/httpd/conf.d/redirect.conf #Apache <virtualhost *:80> ServerName  example.com ServerAlias  www.example.com Redirect / https://example.com/ </virtualhost>

Find all open socket at your linux with the following command. #centos #linux #socket

Find all open socket at your linux with the following command. sudo find / -type s It will be helpful when you are using php-fpm, if you want to be sure for socket is open or not. Then simply you can run the following command sudo find / -type s | grep sock sometime we might have problem during myslqdump if the mysql.sock is not at default location, in that case we need to provide socket details. mysqldump -u dbuser --protocol=socket -S /riyazdata/mysql/mysql.sock -p dbname > dbriyaz_20190103.sql Note: [/riyazdata/mysql/mysql.sock] this information you can get with "sudo find / -type s"

# DISABLE CACHING #cpanel #.htaccess

If you have hosted your website at #cpanel and you are testing your code directly their, web caching might irritates you. simply open your .htaccess file and add the following code # DISABLE CACHING <filesMatch "\.(html|htm|js|css)$"> FileETag None <ifModule mod_headers.c> Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" </ifModule> </filesMatch>

Turn off pagespeed #cpanel

Specially this code will be useful when your website is at cpanel hosting you want to test and you are getting issue with #pagespeed. We can simply turn it off by adding the following code to .htaccess Go to your code and edit .htaccess file and add the following code. <IfModule pagespeed_module> ModPagespeed off </IfModule>

Install php composer #php #composer #centos7

#php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" #php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" #php composer-setup.php #php -r "unlink('composer-setup.php');" Note : run these command from where you want to run composer command because all of above command command will generate composer.phar. You can run these from normal user as well. now you can run command for composer as follows #php71 composer.phar update or #composer.phar update

How to install nginx-more

1. First update your system with epel-release yum install epel-release -y yum -y update 2. Nginx-More installation CentOS 6 > yum install https://repo.aerisnetwork.com/stable/centos/6/x86_64/aeris-release-1.0-4.el6.noarch.rpm CentOS 7 > yum install https://repo.aerisnetwork.com/stable/centos/7/x86_64/aeris-release-1.0-4.el7.noarch.rpm Now install nginx-more yum install nginx-more -y Note: If nginx is already installed then yum swap nginx nginx-more