Skip to content

Instantly share code, notes, and snippets.

@itzikbenh
Created June 10, 2018 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itzikbenh/79a6c6e8bc4d2a2fb84f21fcbb532764 to your computer and use it in GitHub Desktop.
Save itzikbenh/79a6c6e8bc4d2a2fb84f21fcbb532764 to your computer and use it in GitHub Desktop.
WordPress + NGINX
- sudo apt-get update
- sudo add-apt-repository -y ppa:nginx/development
- sudo add-apt-repository -y ppa:ondrej/php
- sudo apt-get update
- sudo apt-get install -y git tmux vim curl wget zip unzip htop
- sudo apt-get install -y nginx
- sudo systemctl start nginx
- sudo systemctl enable nginx
Install PHP
- sudo apt-get install -y php7.1-fpm php7.1-cli php7.1-mcrypt php7.1-gd php7.1-mysql \
php7.1-pgsql php7.1-imap php-memcached php7.1-mbstring php7.1-xml php7.1-curl \
php7.1-bcmath php7.1-sqlite3 php7.1-xdebug
Configure PHP-FPM
- sudo nano /etc/php/7.1/fpm/pool.d/www.conf
- listen = /run/php/php7.1-fpm.sock OR /var/run/php/php7.1-fpm.sock //Both are the same as /var/run would symlink to /run/php.
- user = nginx, group = nginx, listen.owner = nginx, listen.group = nginx, uncomment listen.mode and make sure it’s set to 0660.
- ps aux | grep php //List PHP processes
Install WordPress
- wget -q -O - http://wordpress.org/latest.tar.gz | tar -xzf - --strip 1 -C /var/www/blog.example.com
- cp /var/www/blog.example.com/wp-config-sample.php /var/www/blog.example.com/wp-config.php
- chown -R nginx:nginx /var/www/blog.example.com //Change ownership to nginx.
- Get salt values from https://api.wordpress.org/secret-key/1.1/salt/ and configure the wp-config file for DB password.
Install MySQL
- sudo apt-get install -y mysql-server
- systemctl start mysql
- systemctl enable mysql
- systemctl status mysql
- mysql -u root -p
- CREATE DATABASE wordpress;
- create user myuser@'localhost' identified by 'secret';
- GRANT ALL PRIVILEGES ON wordpress.* TO wpuser@localhost IDENTIFIED BY "p@ssw0rd";
- flush privileges; - “re-cache it record of users and permissions in-memory”
- \q - “Quit MySQL”
sudo nano /etc/nginx/conf.d/blog.example.com.conf
server {
listen 80;
server_name blog.example.com;
root /var/www/blog.example.com;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment