Install wordpress on ubuntu 20.04 Lamp
I’m using Linode hosting my blog ,I just upgrade ubuntu from 14.04 to 20.04 ,so I reinstalled wordpress ,below is the step I was using.
Install Lamp using tasksel
sudo apt update sudo apt install tasksel sudo tasksel --list sudo tasksel install lamp-server sudo apt remove tasksel
Virtual host setup
1.Create a apache configuration file for your wordpress site(Replace example.com with your domain name)
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
2.Edit the conf file created above and set your ServerName and DocumentRoot.Eg:
<VirtualHost *:80>
ServerName ubuntututorials.org
ServerAlias www.ubuntututorials.org
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/ubuntututorials.org/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Note: It’s better to add and “www” ServerAlias if you are using the base domainname
3.Create required directory
sudo mkdir -p /var/www/html/example.com/public_html
4.Enable your site and disable the apache default one
sudo a2ensite example.com sudo a2dissite 000-default.conf sudo systemctl reload apache2
Mysql Setup
1.Login into mysql using root
sudo mysql -u root
2.Create a database instance for you wordpress site.Eg:
CREATE DATABASE wordpress;
3.Create a mysql user and grant it the full access to the db create in step 2
CREATE USER 'wpuser' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'; quit
WordPress installation and setup
1.Download the latest wordpress package somewhere and extract it
sudo wget http://wordpress.org/latest.tar.gz sudo tar -xf latest.tar.gz
2.Move wordpress files to your public_html directory
sudo mv wordpress/* /var/www/html/example.com/public_html/
3.Chown the owner and group to www-data
sudo chown www-data:www-data -R /var/www/html/example.com/public_html/
4.Configure WordPress , open your wordpress site now ,you should be able to see the configuration page
Use the database name / username/password created above
Some Optional setup
1.Enable Permalinks for your wordpress site , you can add below lines into your wordpress’s apache site configure file
<Directory /var/www/html/example.com/public_html> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
sudo systemctl reload apache2
2.Install phymyadmin
sudo apt install phpmyadmin