Install WordPress for new project

On Server

Download WordPress to site

wget -c http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
sudo rsync -av wordpress/* /var/www/sarah/public_html

OLD WAY Upload WordPress zip to directory

unzip wordpress.zip

Make whole site writable for WordPress (wp-content needed for plugins, wp-admin needed for wordpress update)

I think you need to set like this instead (if you have trouble installing plugins after this then I was wrong)

find /var/www/sarah/public_html -type d -exec chmod 775 {} \;
find /var/www/sarah/public_html -type f -exec chmod 664 {} \;

Then update to belong to user:

sudo chown -R sarah:www-data /var/www/sarah/public_html

Go to IP alias or domain and follow wizard

After wizard complete, download wp-config.php and add this line to bottom so users can upload plugins using admin

if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}

On Local

Download latest WordPress

Create new site folder under D:\sites\{site-name}

Unzip in folder

Open project in localhost:

http://localhost/{site-name}

Follow WordPress steps to hook up to WordPress database you created

Create new ftp user

useradd -m -d /home/sarah sarah
passwd sarah

Give password: 575757aA

usermod -g www-data sarah

Add user to vsftpd

cd /etc/vsftpd
nano sarah
local_root=/var/www/sarah/public_html
htpasswd -cd /etc/vsftpd/ftpd.passwd sarah

Will ask for password now

575757aA

Then edit user home directory (not sure if this is actually needed anymore)

usermod --home /var/www/sarah/public_html sarah

Check that user can write to directory

sudo chown -R sarah:www-data /var/www/sarah/public_html
chmod 775 /var/www/sarah/public_html
/etc/init.d/vsftpd restart

For changes to take effect restart apache

service apache2 restart

Try connecting to FTP using FTP user, password and port 21

Need port 21 because WordPress doesn’t allow changing of ports

Install vsftpd

Step 1: Installation

Run the following command to install vsftpd:

apt-get install vsftpd

Step 2: Configuration

Open up the configuration file using your text editor of choice. This example uses vim.

nano /etc/vsftpd.conf

Copy these

#listen=NO
anonymous_enable=YES
local_enable=YES
write_enable=YES
#local_umask=022
local_umask=002
#dirmessage_enable=YES
#chroot_local_user=YES
#pam_service_name=vsftpd
pam_service_name=ftp

Add to end:

#Google Compute config
pasv_min_port=5000
pasv_max_port=6000

#Wordpress FTPS config
#allow_anon_sll=NO
#force_local_data_ssl=YES
#force_local_logins_ssl=YES
#ssl_tlsv1=YES
#ssl_sslv2=NO
#ssl_sslv3=NO
#require_ssl_reuse=NO
#ssl_ciphers=HIGH
listen_port=21

Save the file and close your text editor. Then, start vsftpd as a daemon:

service vsftpd start

At this point, you can log in your ftp server from your local computer.

Extras

If you want to prevent all local users from leaving their home directory, you need to uncomment this line from /etc/vsftpd.conf:

chroot_local_user=YES

As of vsftpd 2.3.5, the chroot directory must not be writable. You can change the permissions of this folder with the following command:

chmod a-w /home/user

Remember to restart the vsftpd daemon after editing vsftpd.conf.

service vsftpd restart

Validate Value not working with Gutenberg

Currently a known issue with ACF and Gutenberg:
https://www.advancedcustomfields.com/resources/known-issues/

Solution

Write specialized JavaScript in functions.php or one of the include files that adds a click event on the publish button which will stop the page from saving when a validation error exists and gives the user an alert letting them know what to change.

add_action('admin_footer', 'update_fields');
function update_fields()
{
    global $pagenow;
    echo '<script>
    jQuery(window).on("load", function() {;
		';
    //If homepage or foundation home page
    //Check slider for anything that's not mp4 videos, give error and don't let submit
    if ( ('post.php' === $pagenow && isset($_GET['post']) && 'page' === get_post_type($_GET['post']) && $_GET['post'] == 53) || ('post.php' === $pagenow && isset($_GET['post']) && 'page' === get_post_type($_GET['post']) && $_GET['post'] == 141)) {
        if($_GET['post'] == 53){
            $sliderName = "main_slider";
        }else{
            $sliderName = "main_slider_foundation";
        }
        echo '
		// When click update, check that 
		// Checks if cat is selected when publish button is clicked
		jQuery( "body" ).on( "click", ".editor-post-publish-button", function( e ) {
			var slider = $("[data-name='.$sliderName.'] [data-name=video]");
			var errors = false;
			slider.each(function(i, obj) {
                var filename = $(this).find("[data-name=filename]").text();
                if (filename=="" || filename.indexOf(".mp4") !== -1) {
                }else{
                    errors = true;
                }
            });
            if(errors){
                alert("Please only upload mp4 videos");
                return false;
            }
		} );
		';
    }
    echo '});
    </script>';
}