Set Up WP Development Environment
Linux, Sysadmin, WordPress
This will create a test site here:
/var/www/testdomain.com/public_html/newsite
The site will be visible at testdomain.com/newsite
Create a Directory
Open a terminal on the VPS by means of SSH.
Navigate to the test domain document root:
cd /var/www/testdomain.com/public_html
Create a new directory:
sudo mkdir newsite
Set Ownership & Permissions
Grant ownership of the new directory to the proper user. Don’t leave the directory owned by root.
sudo chown -R $USER:www-data /var/www/testdomain.com/public_html/newsite
Set permissions so files can be viewed:
sudo chmod -R 755 /var/www/testdomain.com/public_html/newsite
WordPress Settings
Set Directory Permissions to 755:
find /var/www/domain.com/path-to-wp -type d -exec chmod 755 {} \;
Set File Permissions to 644:
find /var/www/path-to-wp -type f -exec chmod 644 {} \;
Note that permissions may need to be more permissive to allow uploading of files, depending on the server environment:
Any file that needs write access from WordPress should be owned or group-owned by the user account used by the WordPress (which may be different than the server account). For example, you may have a user account that lets you FTP files back and forth to your server, but your server itself may run using a separate user, in a separate usergroup, such as dhapache or nobody. If WordPress is running as the FTP account, that account needs to have write access, i.e., be the owner of the files, or belong to a group that has write access. In the latter case, that would mean permissions are set more permissively than default (for example, 775 rather than 755 for folders, and 664 instead of 644).
From WordPress Codex.
Create a MySQL Database with new user & password:
mysql -u root -pROOTPASSWORD -e "create database db_name; GRANT ALL PRIVILEGES ON db_name.* TO new_user@localhost IDENTIFIED BY 'NewUserPassword'"
Entering the root password is optional and may be inadvisable. Leave it out, and the system will prompt for Root password in normal way before carrying out the mysql command.
Install WordPress
Install WordPress using WP-CLI
Set Aliases
Open ~/.bashrc and set up aliases:
comments powered by Disqus