Tag Archives: Apache

How to move a WordPress instance from one server to another Linux server

Motivation:

You want to move a WordPress instance from one server to another to consolidate your websites to reduce cost.

Solution:

Install and use below Duplicator plugin to achieve your goal.

https://wordpress.org/plugins/duplicator/

User guide: https://snapcreek.com/duplicator/docs/quick-start/

If everything goes well for you then congratulation!

Otherwise, please review below possible problems and corresponding solutions.


Problem 1:

You don’t have a website on the new server.

Solution 1:

1. Create a new virtual host in the /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot "/var/www/www.example.com"
</VirtualHost>

2. Set 775 permission for /var/www/www.example.com

3. Restart httpd service

sudo systemctl restart httpd

Problem 2:

You are using Amazon Linux 2 server.

You are logged in as ec2-user.

You use WinSCP to upload files and edit configuration files.

You cannot modify /etc/httpd/conf/httpd.conf and /etc/php.ini.

Solution 2:

1 View permission settings for the file

ls -ld /etc/httpd/conf/httpd.conf

The result indicates that the file owner is root user and root group, not ec2-user.

2. View groups of a user

groups ec2-user

The result indicates that the ec2-user does not belong to root group.

3. Add a user to root group

sudo usermod -a -G root ec2-user

4. Grant Read-Write permission against a file to root group

sudo chmod g+rwx /etc/httpd/conf/httpd.conf
sudo chmod g+rwx /etc/php.ini

5. Logout and login to the server again.


Problem 3:

You are using Amazon Linux 2 server. The ZipArchive feature is missing.

Solution 3:

1. Execute below commands:

sudo amazon-linux-extras install php7.2
sudo yum install php-pear php-devel gcc libzip-devel zlib-devel
sudo pecl install zip-1.13.5 # we must specify a slightly older version due due to compatibility

2. Add “extension=zip.so” to /etc/php.ini

3. Restart the server

sudo reboot

Problem 4:

You don’t have a WordPress database on the new Linux server.

Solution 4:

Execute below MySQL commands:

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE `wp_database`;
GRANT ALL PRIVILEGES ON `wp_database`.* TO "username"@"localhost";
FLUSH PRIVILEGES;

Problem 5:

An database error occurs while restoring a website.

Solution 5:

1. Execute below commands to remove the website:

sudo chown -R ec2-user:apache /var/www/example.com
sudo chmod 2775 /var/www/example.com && find /var/www/example.com -type d -exec sudo chmod 2775 {} \;
find /var/www/example.com -type f -exec sudo chmod 0664 {} \;
rm -r /var/www/example.com

2. Upload the Duplicator files again, and restore the website again.


Problem 6:

No write access against /var/www/example.com is available for Duplicator.

Solution 6:

1. Execute below commands:

sudo chown -R ec2-user:apache /var/www/example.com
sudo chmod 2775 /var/www/example.com && find /var/www/example.com -type d -exec sudo chmod 2775 {} \;
find /var/www/example.com -type f -exec sudo chmod 0664 {} \;

2. Run http://example.com/installer.php again.

Topic 7 – Introduction to Web Application Development

Why do I need to learn about web application development?

Desktop applications are very powerful and convenient but their development, deployment and maintenance are daunting. The reason is that the platform dependency makes it very expensive to create a desktop application working on different versions of different operating systems, such as Windows, Linux and Mac OSX. Deployment and updates of desktop application typically require high privileges access to a computer machine, causing a problem for companies requiring high security.

Fortunately, you can overcome these limitations by creating a web application running on a browser. To create a web application you need to learn about web application development.

What can I do after finishing learning web application development?

You will be able to create web applications like The BBC News, The WordPress Blog or The White House Website.

This is just what I want to learn! What should I do now?

Web application development requires a lot of reading. You have to master networking concepts, HTML, CSS, JavaScript, a programming language and a database management system for web.
Please read 
- this Semmy Purewal (2014). Learning Web App Development. O'Reilly Media book, and
- this Jon Duckett (2011). HTML & CSS - Design and Build Websites. John Wiley & Sons book first to get familiar with web application development.
After that please read
- this Stephen Greig (2013). CSS3 - Pushing the Limits. John Wiley & Sons book and
- this Anne Boehm and Zak Ruvalcaba (2018). Murach's HTML5 and CSS3. Mike Murach and Associates book to learn in-depth about HTML and CSS.
JavaScript is the language for web development because it is implemented in most of the web browsers. Please read 
- this David Flanagan (2020). JavaScript: The Definitive Guide. O'Reilly Media book, and 
- this Kyle Simpson (2015). You Don't Know JS. O'Reilly Media book, and
- this Jon Duckett (2014). JavaScript and JQuery. Interactive Front-End Web Development. John Wiley & Sons book to master it. Strong knowledge of JavaScript will ease your web development learning very much.
Single page application is the default front-end choice for most of new web development projects. Please read 
- this Kirupa Chinnathambi (2018). Learning React. Addison-Wesley Professional book, and 
- this Robin Wieruch (2020). The Road to React - Your Journey to Master Plain Yet Pragmatic React. Leanpub book to learn how to create a single page application (SPA).
After that you will have 4 main options. You can choose one of them. We STRONGLY recommend that you choose only ONE option. You should NOT learn all of them at the beginning. You could save your time by digging into only one option. After mastering the selected path, you will realize that all of them are very similar in the sense of use. One note is that although their concepts are similar to one another but they will still take us much time to learn how to apply implementation of an approach in real world solutions.
When developing a real world web application, you often use only one or two of these 4 approaches. If you cannot make your own selection then we recommend you 
- a combination of the first and second option, or
- a combination of the first and third option, or
- a combination of the first and fourth option.
The first option is PHP world.  Please read 
- this Luke Welling and Laura Thomson (2016). PHP and MySQL Web Development. Addison-Wesley Professional book or 
- this Robin Nixon (2018). Learning PHP, MySQL & JavaScript. O'Reilly book.
After that depending on your projects you can read these books below. 
- Brad Williams, David Damstra and Hal Stern (2015). Professional WordPress: Design and Development. Wrox.
The second option is ASP.NET Core. Please read
- Adam Freeman (2020). Pro ASP.NET Core 3: Develop Cloud-Ready Web Applications Using MVC, Blazor, and Razor Pages. Apress book and
- this Andrew Lock (2021). ASP.NET Core in Action. Manning book.
A complementary part for this option is ASP.NET Web Forms. Please read this "Imar Spaanjaars (2014). Beginning ASP.NET 4.5.1: in C# and VB" book.
The third option is Java world. if you are not familiar with Java language then please read 
- this Cay S. Horstmann (2019). Core Java. Volume I - Fundamentals. Pearson book, and
- this Cay S. Horstmann (2019). Core Java. Volume II - Advanced Features. Pearson book first.

Then please read 
- this Tim Downey (2021). Guide to Web Development with Java - Understanding Website Creation. Springer book or 
- this Nicholas S. Williams (2014). Professional Java for Web Applications. John Wiley & Sons book.
The 4th option is Node.js world.  Please read this
- this Jonathan Wexler (2019). Get Programming with Node.js. Manning Publications book, and
- this Bruno Joseph D'mello et al. (2017). Web Development with MongoDB and Node. Packt Publishing book.
There are also several other options that you may consider. These options include Ruby on Rails and Flask.
If you need to convert a web application from one platform to another or create a web application framework please read 
- this Leon Shklar and Richard Rosen (2009). Web Application Architecture. John Wiley & Sons book, and
- this Leonard Richardson and Mike Amundsen (2013). RESTful Web APIs. O'Reilly Media book.
After finishing the books please click Topic 8 - Introduction to Mobile Application Development to continue.