Install WordPress With LAMP


Linux, Apache, MySQL, PHP

 1sudo apt update
 2sudo apt-get install apache2 -y # apache2
 3sudo apt install php libapache2-mod-php # php, libapache2-mod-php
 4sudo systemctl restart apache2 # restart apache2
 5sudo apt-get install mariadb-server php-mysql -y # MariaDB Server and PHP-MySQL packages
 6sudo systemctl restart apache2 # restart apache2 again
 7cd /var/www/html/ # open web folder
 8sudo rm * # remove old files
 9sudo wget # download WordPress
10sudo tar xzf latest.tar.gz # extract WordPress tarball
11sudo mv wordpress/* . # move WordPress files to /var/www/html/*
12sudo rm -rf wordpress latest.tar.gz # remove wordpress folder and WordPress tarball
13sudo apt install tree
14tree -L 1
16├── index.php
17├── license.txt
18├── readme.html
19├── wp-activate.php
20├── wp-admin
21├── wp-blog-header.php
22├── wp-comments-post.php
23├── wp-config-sample.php
24├── wp-content
25├── wp-cron.php
26├── wp-includes
27├── wp-links-opml.php
28├── wp-load.php
29├── wp-login.php
30├── wp-mail.php
31├── wp-settings.php
32├── wp-signup.php
33├── wp-trackback.php
34└── xmlrpc.php
363 directories, 16 files
38sudo chown -R www-data: . # change ownership of all these files to Apache user
39sudo mysql_secure_installation # MariaDB
40sudo mysql -uroot -p # run MySQL
41MariaDB [(none)]> create database wordpress;
42Query OK, 1 row affected (0.001 sec)
43MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' IDENTIFIED BY '<YOUR PASSWORD>';
44Query OK, 0 rows affected (0.012 sec)
45MariaDB [(none)]> FLUSH PRIVILEGES;
46Query OK, 0 rows affected (0.001 sec)
47# Exit the MariaDB prompt with Ctrl + D
48sudo reboot # restart Raspberry Pi

Write php file to test:


Save to test.php, then access http://ip/test.php, will see the phpinfo.

After execute sudo mysql_secure_installation:

  • You will be asked Enter current password for root (enter for none): — If you had set root password jusst input, or you can press Enter to set it.
  • Type in Y and press Enter to Set root password?.
  • Type in a password at the New password: prompt, and press Enter. Important: remember this root password, as you will need it later to set up WordPress.
  • Type in Y to Remove anonymous users.
  • Type in Y to Disallow root login remotely.
  • Type in Y to Remove test database and access to it.
  • Type in Y to Reload privilege tables now.

When complete, you will see the message All done! and Thanks for using MariaDB!.

Install WordPress

Then begin the WordPress installation.

1Database Name:      wordpress
2User Name:          root
3Password:           <YOUR PASSWORD>
4Database Host:      localhost
5Table Prefix:       wp_

After input these, if you get Server Down error, just run sudo systemctl restart apache2.


1Site Title: tianheg
2Username: root
3Password: <Set a password>
4Email: [email protected]

I like’s theme, I download it, install it.

Install WordPress Theme

  1. Access http://address/wp-admin/
  2. Click Appearance/Themes
  3. Find Add New/Upload Theme, you can just upload the zh2 zip file. That’s it!
  4. Custom it as you want.