WordPress and Nginx installation

Install packages

We need NGINX, PHP, and MYSQL.

sudo apt-get install nginx
sudo apt-get install php7.0-fpm
sudo apt-get install mysql-server
sudo apt-get install php7.0-mysql

Enable PHP

  • enable php in nginx configuration file
  • php and nginx should both be working at this point
    • to test add an index.php directive containing <?php phpinfo(); ?>to web root
    • then go to localhost or ip address and verify that the php status page displays

Create a database and user

mysql -u root -p    
CREATE DATABASE 'wordpress' DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL ON 'wordpress'.* to 'user'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;

Download wordpress

wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo chown www-data:www-data -R wordpress

Setup wordpress

Run wordpress intallation script

  • go to [ip/domain]/wordpress, which redirects to wp-admin/setup-config.php to run the installation script

To transfer an existing WordPress installation

Copy all wordpress files and database over to the new server.

Files

Create a tar of existing directory (wordpress intallation):

sudo tar -czvf name_of_archive.tar.gz /path/to/directory_or_file

Extract tar contents to current directory:

sudo tar -xzvf archive.tar.gz

Database

To dump an existing database to a file that you can later read in to create the new database:

mysqldump --quick db_name | gzip > db.gz

Then to read it in to a new database:

gunzip < db.gz | mysql db_name