WHAT'S NEW?
Loading...
Showing posts with label server. Show all posts
Showing posts with label server. Show all posts
Sometimes you need to migrate a new website from the root directory of the domain, for example you want move your website from http://www.mydomain.com to http://www.mydomain.com/wordpress/
If you need help follow the instructions below.


Backup all the WordPress files and MySql script onto your local drive

Create the new location for the core WordPress files to be stored, create the subfolder in the htdocs of the Apache installation: $APACHE_HOME\htdocs\wordpress

Copy or move all the files and subfolders in the new folder.

Change all the references in the .htaccess file. It is a hidden file and should be located in the root folder for WordPress.

Login to phpMyAdmin, click the link to your wordpress database and  look for the table "wp_options", open the table and watch the "option_name" column, scroll down and look for "siteurl" and "home". Change the value from  http://www.mydomain.com to http://www.mydomain.com/wordpress/

Login to the new wordpress url: http://www.mydomain.com/wordpress/wp-login.php 

If you are using Permalinks, go to the Administration > Settings > Permalinks panel and click UPDATE

Now we must modify the existing image/media links uploaded media, you must install the Better Search Replace plugin and activate it https://wordpress.org/plugins/better-search-replace/ 
Open the menu Tools -->  Better Search Replace


Write in the "Search for": http://www.mydomain.com

Write in the "Replace with": http://www.mydomain.com/wordpress/

Select the checkbox you want and click "Run Search/Replace"

You have now completely moved your wordpress instance in the subfolder.

If you continue to have 404 error on permalinks then check if

AllowOverride Not Enabled 

Your server may not have the AllowOverride directive enabled. If the AllowOverride directive is set to None in your Apache httpd.config file, then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccessfiles in the filesystem. When this directive is set to All, then any directive which has the .htaccess Context is allowed in .htaccess files. Example of enabled AllowOverride directive in httpd.config:
 <Directory />
    Options FollowSymLinks
    AllowOverride All
 </Directory>
You may also have to enable the AllowOverride directive in your DocumentRoot:
 <Directory /var/www/html>
    # ... other directives...
    AllowOverride All
 </Directory>
VirtualHost example

<VirtualHost IP>
    ServerName domain.com
    ServerAlias www.domain.com
    DocumentRoot /var/www/mydomain
    ServerAdmin webmaster@domain.com
   <Directory "/var/www/mydomain">
         Options FollowSymLinks
         AllowOverride All
         Order allow,deny
         Allow from all
   </Directory>
</VirtualHost>
 We will see how to  use mod_rewrite to reditect url in a configured virtual host



This example is based on a url with incoming query string empty. The trick is to use a RewriteCond to match the empty query string portion of the URL, and a regular RewriteRule to match the path.



<virtualhost>
    ServerAdmin awesome@test.com
    DocumentRoot C:\test
    ServerName test.com

     <directory test="">
       Order allow,deny
       Allow from all
       AllowOverride All
    </directory>
    
    RewriteEngine On
    RewriteCond %{REQUEST_URI}  ^/web/guest/myurl/$
    RewriteCond %{QUERY_STRING} ^$
    RewriteRule ^(.*)$ http://www.mynewdomain.com/ [R=301,L]
</virtualhost>    

As result the url

http://www.mycurrentsite.com/web/guest/myurl/ will be redirect to http://www.mynewdomain.com/

the url

http://www.mycurrentsite.com/web/guest/myurl/?id=576576 will not be redirect.

When you work to build a modern website based only on HTML5 and Javascript, you don't need complex configurations to verify how the end user will display the web site. A simple web server serving static files is the fastest and easiest solution, in this guide we will learn how to install Node.js and create a simple web server to use for our work. Node.js is a runtime environment for developing server-side web applications. In simple words, the Node.js platform makes it possible to run JavaScript programs on a server and also on your Raspberry Pi 2.



First of all, please run the following command in a shell or terminal

sudo apt-get update

Please wait! This command can be very slow, it downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies.

Remove a program with similar name to node.js (it creates conflicts, so better remove it)

sudo apt-get --purge remove node

To install Node.js run the commands

sudo apt-get install nodejs
sudo apt-get install npm

Nice job! You have sucessfully installed nodejs and npm in your Raspberry Pi 2. You can see the version currently being used by the shell by typing:

node -v

If nothing happens and you have the error  node: No such file or directory create a symlink with the command

sudo ln -s /usr/bin/nodejs /usr/sbin/node

Create a folder called /var/www/ and navigate to that folder, it will be our work directory.

sudo mkdir /var/www 
cd /var/www

We are ready to start coding! We will create a simple Webserver to host static website. Install the dependencies 

npm install --save compression connect http serve-static

Create a folder called httpdocs, this folder will cointain your HTML file, images and js code you want to host.

sudo mkdir /var/www/httpdocs

For example create a file index.html

Create in /var/www a file named server.js and put this code inside:

or you can download the file

wget https://gist.githubusercontent.com/orfeomorello/704f8639a5afcf50871f/raw/2ca571e41e9bc4c2fd12578293bdcd08eda51a34/server.js

If you followed all the steps, typing the ls command you can see this dicrectory structure

httpdocs node_modules server.js

To start the web server, execute the script with the command

node server.js

This will create a local webserver running on port 8181, if you write this web addess in your browser http://localhost:8181/index.html you will view your website running (remember to put your files in /var/www/httpdocs folder). To stop running the server press ctrl + c

Do you want to make available your website directly on the Internet? Follow this other tutorial