Install LEMP and WordPress on Ubuntu 16.04
Yesterday, there was a need to deploy WordPress on Ubuntu server, I haven’t touched WordPress for more than two years, so I have to check the information and read how to install it. Most of the tutorials use LNMP, and most of them use PHP5.6, after all, WordPress is also a few years, here to record the installation process, to facilitate the next query.
Introduce
WordPress is a blog system implemented by MySQL and PHP technology stacks. It has been in existence for more than a decade, because of its high usability, rich popularity of themes and plug-ins, although it has rarely appeared in public view in recent years. There have been quite a few blog system contenders, but it is undeniable that WordPress is perfect if you want to quickly develop a blog system with a focus on writing articles and not spending too much time on the page. Meet the requirements, if you are skilled, you can build a blog system in a few minutes, and then take a few minutes to choose a relatively simple and generous theme, which is extremely efficient.
To install WordPress, you must first have a PHP and MySQL environment. It is best to have a port forwarding application. Nginx and Apache are optional. These are conflicts, so you can only choose one. This article takes LNMP as an example.
Install LNMP
Preliminary Preparation
At first
1 | apt update |
Just in case, it’s good to confirm that the Apache related application has been removed.
1 | apt remove apache2* |
Install Nginx
just use apt.
1 | apt install nginx |
Then use the following code to start the service, at this point we can see the default Nginx page by visiting the domain/IP.
1 | service nginx start |
Install MySQL
1 | apt install mysql-server |
The password must be remembered, otherwise, it is quite troublesome to reset and change the password.
Install PHP7.0
1 | apt install php php-fpm php7.0-mysql |
Test If The Installation Is Successful (optional)
- Create a php file
1 | nano /usr/share/nginx/html/info.php |
Edit this file
1 |
|
Then modify the configuration of Nginx
1 | nano /etc/nginx/sites-available/default |
Mainly modify the root location.
After modification, restart Nginx with the following code to ensure that the new configuration file is read.
1 | service nginx restart |
Then visit through the browser to see if there is a normal parsing to the php info page.
Install WordPress
After the previous steps, the WordPress environment is installed. Next, install WordPress. First, we must first configure the MySQL database.
1 | mysql -u root -p |
After entering the MySQL command line
1 | create database wordpress character set utf8 collate utf8_bin; |
1 | grant all privileges on wordpress.* to wordpressuser@localhost identified by "[insert-password-here]"; |
Be careful to replace the password set in the previous steps.
After you finish, you can start downloading WordPress. There are Chinese station and official English station. Both are the same, but the default language package is different. If you download the language package in any version, you can switch to another version.
Here is the official version.
1 | wget http://wordpress.org/latest.tar.gz |
Modify the values of DB_NAME
, DB_USER
, DB_PASSWORD
, and then migrate the directory to /var/www/html
1 | cp -r ~/wordpress/* /var/www/html |
It should be noted that the current WordPress part of the configuration is over, then you want to access, you also need to modify the Nginx configuration, the request is configured to the WordPress directory.
Additional
After installing WordPress, when you need to upload files, you may not have the permission of the superior directory. You need to modify the permissions of the corresponding folder and its parent folder. It is relatively convenient to change to 777. Be careful not to make mistakes in the modified folder. It is not necessarily a folder named after WordPress.