0
votes

First of all I read a lot of topics from stackoverflow and other sites but I can't find the answer.

I am trying to setup my own WordPress hosting solutions for my WordPress sites. So, I have server from digitalocean I install nginx,hhvm and mysql.I can install WordPress without errors. But when i try to install plugin from WordPress dashboard, WordPress asks my ftp credentials. How can I remove that and automatically install plugins without ftp credentials?

I know I can modify wp-config file adding define('FS_METHOD','direct') but at that time i am getting 'Could not create directory.' error and this is not right solution because every time I install new wordpress I should do it again and again.

Another thing writing ftp credentials to wp-config file again not right solution because i have to repeat again and again in every site.

Last thing I found is this code;

sudo chown -R www-data:www-data wordpress-foldername

it works but again i have to do that for every wordpress site. Can i automate this? I don't want to make this every install new wordpress. How can i configure one time and it works all the time?

1

1 Answers

1
votes

I also used Digital Ocean for hosting personal and development project,

Whenever I have a new project I need to used command line to install wordpress, and configure the install, so I'm not sure how you did it.

Here's the full code, using command line browse to the html directory

cd /var/www/sites-folder-directory

download wordpress package and extract

wget http://wordpress.org/latest.tar.gz && tar xfz latest.tar.gz 

move wordpress files to root folder & Delete Wordpress Folder and tar file

mv wordpress/* ./ 
rmdir ./wordpress/ && rm -f latest.tar.gz 

Assign these new files and folders to default nginx user and group, you should check your default nginx user and group under /etc/nginx/nginx.conf

chown -R nginx:nginx /var/www/sites-folder-directory 

Not really nescessary but if you want to change folder and file permission you can use command below

# Change Folders Permission
sudo find <directory> -type d -exec chmod 755 {} \;

# Change Files Permission
sudo find <directory> -type f -exec chmod 644 {} \;

if you have correct folders and files permission and the current directory is assign to default user and group it wouldn't ask for FTP credentials