Although there are various tools and plugins in solutions such as cPanel and Plesk for WordPress installation, although we can easily do this with high connection speed FTP or file transfer from the panel interface, the need to install WordPress with SSH may arise. Based on this, I will be sharing the process steps with you step by step below.
The steps to install WordPress with SSH will be as follows. And I will be sharing the details of all these steps with you.
- Starting the connection
- Installation directory selection
- WordPress download and unzip process
- Placing the files in the appropriate directory
- Setting write permissions (CHMOD)
- Setting FS_METHOD on wp-config.php
Server Connection via SSH
Actually, this method is very simple, if the privileges on your system are not sufficient for ssh connection, you may need to connect with sudo. If you have a Windows operating system, then you may need to use alternative tools such as PuTTY. For computers with Mac or Linux operating systems, simply follow the step below.
If you have a problem with authorization while connecting via ssh [email protected], complete your system password by entering the following command and create your secure connection via sudo.
sudo ssh [email protected]
After completing your connection, go to the directory where you will install wordpress. Your root directory may vary depending on the server you use for this, your server administration panel. You can access your own server’s root directory by navigating through the folders.
Execute the following command to gain access to the top directory.
After going to the top directory, you can list the files and folders inside with the ls command to find the directory where you will install, you can see the directory you are in with the pwd command, and you can use the cd command to enter the directories. Now I’m gaining access to my own root directory.
WordPress Download and Unzip Process
After making sure that you are in the correct directory, we need to download the latest version files of WordPress. The address specified in the command stores the current version in the fixed URL for such uses. With the help of the command below, we download the files and extract them from the archive.
curl -sL https://wordpress.org/latest.tar.gz | tar xfz -
After completing this process, a folder named wordpress is created in the directory we are in and the downloaded zip file is not stored.
Move Wordpres Files to Parent Directory
Upon unarchiving the WordPress files, a folder called “wordpress” is created and the files are housed in it. The reason for this is that the files in the archive are located in this folder. Using the command below, we will copy the files inside the folder to a higher directory without entering the wordpress folder.
mv wordpress/* ./
After pulling the files inside the folder to a higher directory, verify that the files are found with ls. Then you can delete the empty wordpress folder with the following command.
rm -r wordpress
Now the wordpress files are located in the root directory of our site in the order we want.
Setting Permissions (CHMOD)
Run the following commands in order, first go to a higher directory, then define the necessary write permissions to the folders and files in your site.
cd ../ clpctl system:permissions:reset vatanlar.com.tr 775
This setting allows us to download files from the panel using WordPress’ own download methods, without the need to enter FTP information on the panel. Otherwise, you may see a window asking for your FTP information.
Add the following line to an appropriate line in wp-config.php.
eg. You can add it after setting WP_DEBUG.
define( 'WP_DEBUG', false ); define('FS_METHOD', 'direct');
That’s it! I will be happy if you send your comments and questions about this article via the form below.