Skip to content

Instantly share code, notes, and snippets.

@nezahualcoyotl
Created October 9, 2020 20:34
Show Gist options
  • Save nezahualcoyotl/36b56edb208675b131efed97ccd9b8e2 to your computer and use it in GitHub Desktop.
Save nezahualcoyotl/36b56edb208675b131efed97ccd9b8e2 to your computer and use it in GitHub Desktop.
Guide to install wordpress in a LAMP environtment

Installing Wordpress in LAMP (Debian)

This is more like a personal note but if it's helpful to you go ahead!

Installing everything you need

Get all the pre requisites of wordrpess

$ apt install apache2 php7.3 libapache2-mod-php7.3 php7.3-common php7.3-mbstring php7.3-xmlrpc php7.3-soap php7.3-gd php7.3-xml php7.3-intl php7.3-mysql php7.3-cli php7.3-ldap php7.3-zip php7.3-curl

That'll do

Check php and apache is working:

$ vim /var/www/html/test.php
<?php
phpinfo();
?>

Go to your server url /test.php and verify that you can see the php info.

Installing MySQL

Install MySQL

$ apt install default-mysql-server

And configure it

$ apt mysql_secure_installation

Enter MySQL

$ apt mysql

Create the database and a user to handle it

$ CREATE DATABASE wordpress;
$ GRANT ALL PRIVILEGES on wordpress.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'wordpress_pss123';
$ FLUSH PRIVILEGES;
$ EXIT;

Installing Wordpress

We need wget, so let's install it

$ apt install wget

Move to the tmp folder to download the tar file

$ cd /tmp/
$ wget -c https://wordpress.org/latest.tar.gz

Decompress it and then move it straight to the public html folder

$ tar -xvzf latest.tar.gz
$ mv wordpress/* /var/www/html/
$ chown -R www-data:www-data /var/www/html/
$ chmod 755 -R /var/www/html/

Let's create the virtualhost for Wordpress

$ vim /etc/apache2/sites-available/wordpress.conf

This is a very standard configuration:

<VirtualHost *:80>
     DocumentRoot /var/www/html
     ServerName your-domain.com

     <Directory /var/www/html>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/domain.com_error.log
     CustomLog ${APACHE_LOG_DIR}/domain.com_access.log combined
</VirtualHost>

Enable the virtualhost and the apache rewrite module

$ ln -s /etc/apache2/sites-available/wordpress.conf /etc/apache2/sites-enabled/wordpress.conf
$ a2enmod rewrite
$ service apache2 restart

You are almost done, now you need just to remove the index.html which contains the apache welcome file. I don't think this step is absolutely necessary but I had some trouble because of it.

$ rm /var/www/html/index.html
$ service apache2 restart

That's it, you should be able to see a fresh-installed wordpress at your domain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment