Skip to content

Instantly share code, notes, and snippets.

@zeddee
Last active September 1, 2019 09:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeddee/c9e1f6ac9f6d0ed2cf44090514785562 to your computer and use it in GitHub Desktop.
Save zeddee/c9e1f6ac9f6d0ed2cf44090514785562 to your computer and use it in GitHub Desktop.

(INCOMPLETE) Installing Wordpress + PHP-fpm from scratch on ubuntu

Install PHP

sudo apt-get install php-fpm # installs php7.2-fpm
sysctl status php7.2-fpm # checks status

Install NGINX to serve the PHP-fpm endpoint

# It's on ubuntu repos
# alternatives here: https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#prebuilt_ubuntu
sudo apt-get install nginx
# backup init conf
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup-original

# restart nginx
nginx -s reload

Install Go to compile Caddy

wget https://dl.google.com/go/go1.12.9.linux-amd64.tar.gz
tar -xvf go1.12.9.linux-amd64.tar.gz
mv go /opt
export GOPATH=$HOME/go
export PATH=$PATH:/opt/go/bin:$GOPATH/bin
go get https://www.github.com/caddyserver/caddy/caddy

Install and configure MySQL 8.0.17

# install apt repo
wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server

Working with MySQL

sudo service mysql status
sudo service mysql stop
sudo service mysql start

Authenticate via Unix Sockets

Add the following to /etc/mysql/my.cnf:

[mysqld]
plugin-load-add=auth_socket.so

And then restart mysql:

sudo service mysql stop && sudo service mysql start

This automatically loads the auth_socket plugin on start.

Then, create an account for your unix user for msql:

# log into unix system as root
mysql
CREATE USER 'userland'@'localhost' IDENTIFIED WITH auth_socket;

Then, log into the 'userland' account on your unix system. You should be able to log into mysql by just running mysql.

NOTE: If things go wrong and you can't authenticate with 'userland':

# log into unix system as root
DROP USER 'userland';
FLUSH PRIVILEGES;
CREATE USER 'userland'@'localhost' IDENTIFIED WITH auth_socket;

Figure out where the unix socket is located:

netstat -ln | grep "unix.*mysql"

Get Wordpress

wget https://wordpress.org/latest.tar.gz
tar -xvf latest.tar.gz

If using passwordless/socket connection to MySQL, edit the DB_HOST directive in your wp_config.php file so that it looks like this:

define('DB_HOST', 'localhost:/var/run/mysqld/mysqld.sock');

Set up Caddyfile

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