Install WordPress on Apache Server

Install WordPress on Apache Server

Download the wordpress files on /var/www/html or /var/www/ folder depend on the Operating System (Deb 8, Deb 7)

#cd /var/www/
#wget --no-check-certificate http://wordpress.org/latest.zip

We have to install unzip to unpack our wordpress files
Unzip the wordpress files in the /var/www/ directory:

#apt-get install install unzip
#unzip latest.zip

Move all extracted folder files to /var/www/

#cd /var/www/wordpress/
#mv * /var/www/
#rm -rf /var/www/wordpress/

We will need to create an /upload directory on /var/www/wp-content/ folder so we can make contents and upload files into it.

#mkdir -p /var/www/wp-content/uploads

Set the user, group ownership and permissions for the directory:

#chown -R www-data:www-data /var/www/
#chmod -R 755 /var/www/

Create database with mySQL
Log into mysql server as root.

[root@vpshelpdesk]#mysql -u root -p
Connect-to-mySQL-server-as-root-from-console
Create a mySQL database from console by type this
mysql>CREATE DATABASE dbuser;
create-database-mySQL
mysql>CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
mysql>GRANT ALL PRIVILEGES ON dbuser.* TO 'user'@'localhost' WITH GRANT OPTION;
mysql>CREATE USER 'user'@'%' IDENTIFIED BY 'password';
mysql>GRANT ALL PRIVILEGES ON dbuser.* TO 'user'@'%' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
mysql>SHOW GRANTS FOR 'user'@'localhost';
SHOW-GRANTS-FOR-user-localhost
Displaying list of users, use the SELECT USER statement

Installing WordPress via web browser http://ipaddress and follow the instruction

 

Google webmaster sitemap xml namespace error

Google webmaster sitemap xml namespace error

Change the opening <urlset> tag to look like the following

<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.google.com/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns:image="https://www.google.com/schemas/sitemap-image/1.1">

Force non www and https and vice-versa with .htaccess

Force non www and https and vice-versa with .htaccess

Redirect web from www to non-www and from HTTP to HTTPS with .htaccess.

http://example.com
http://www.example.com
redirect to
https://example.com

Insert following code at the top of .htaccess

# pass the default character set
AddDefaultCharset utf-8

Options All -Indexes
Options +FollowSymlinks
RewriteEngine On
# NOW WWW HTTPS
#RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

If the default URL to be www.example.com

# pass the default character set
AddDefaultCharset utf-8

Options All -Indexes
Options +FollowSymlinks
RewriteEngine On
# NOW WWW HTTPS
#RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]

How it works

RewriteEngine On

The first line enables the Apache runtime rewriting engine, required to perform the redirect. You may have already enabled it in a previous config in the same file. If that’s the case, you can skip that line.

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]

These two lines are are the redirect conditions, they are used to determine if the request should be redirected. Because the conditions are joined with an [OR], if any of those two conditions returns true, Apache will execute the rewrite rule (the redirect).

The first condition determines if the request is using a non-HTTPS URL. The second condition determines if the request is using the www URL. Notice that I used www\. and not www., because the pattern is a regular expression and the . dot has a special meaning here, hence it must be escaped.

RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]

The forth line is a convenient line I used to avoid referending the hostname directly in the URL. It matches the HOST of the incoming request, and decomposes it into www part (if any), and rest of the hostname. We’ll reference it later with %1 in the RewriteRule.

If you know the host name in advance, you may improve the rule by inlining the URL and skipping this condition (see later).

RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]

The RewriteRule is the heart of the redirect. With this line we tell Apache to redirect any request to a new URL, composed by:

https://www.
%1: the reference to the non-www part of the host
%{REQUEST_URI}: the URI of the request, without the hostname

All these tokens are joined together, and represents the final redirect URI. Finally, we append 3 flags:

NE to not escape special characters
R=301 to use the HTTP 301 redirect status

L to stop processing other rules, and redirect immediately

Remarks

As I’ve already mentioned, my example uses an extra RewriteCond line to extract the host name, and avoid to inline the hostname in the rule. If you feel this is a performance penalty for you, you can inline the host directly in the rule:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [L,NE,R=301]

Origin article from https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/