How to change the default Wordpress upload folder to a shared network one? - wordpress

I have a webserver setup in 2 separate pc's .
First machine holds the MySql server and folder for uploads, shared on the network, that i can access using UNC path like //PC1/uploads.
Second machine holds the ISS server and the Wordpress files.
I can use file:// to embed existing images, etc from the first machine in the wordpress site.
What I don't know is how to setup Wordpress to change it's default upload folder to //PC1/uploads instead of the default local folder.
I have tried with define('UPLOADS','file://PC1/uploads'); and with a ftp server
define ('UPLOADS','ftp://User:pass#pc1.ip');
I get and error Is its parent directory writable by the server?
The upload folder has Everyone read/write in permisions setting , and I can use mput to upload files with ftp.
Thank you

Turns out it was really simple.
Move the entire webroot on the shared folder, set the UNC path and credentials in ISS and define('WP_CONTENT_DIR,'\\\\ServerName\\SharedFolder\\'.'/wp-content');

The above answer isn't exactly right for WordPress 4.7. I got it with including both the following in wp-config.php:
define('WP_CONTENT_DIR','//server/sharedpath'.'/wp-content');
define( 'WP_CONTENT_URL', 'https://url-to-virtual-directory/wp-content' );

Related

problem on moving Wordpress website from Localhost to Server

I ve created my wordpress website on local, then I hosted it using ovh and filezilla
I followed these steps
upload source files under www fileZilla
import my database on ovh
update wp-config
The problem is when i launch my site it still get css files from localhost nd showing this error
Failed to load resource: net::ERR_CONNECTION_REFUSED
You cannot import a WordPress database and have it just work because there are plenty of hard links (including hostname, in your case localhost) in it.
There are several ways to change the URL in the database. My favorite way is to use wp-cli ( https://wp-cli.org/ ) on the command line. Once installed and having the wp command inside your PATH, you can change (cd) to your WP installation's root directory (where the wp-config.php file is located) and run the following command:
wp search-replace 'http://localhost' 'https://your-new-domain.com' --export=my_wp_export.sql
Replace your-new-domain.com by whatever you're using on your ovh host. Be careful when selecting http or https depending on whether you have a valid SSL certificate in place and your hosting is correctly set up for HTTPS, or not.
You now have an SQL file where each localhost URL is replaced by your-new-domain.com. Next, upload and import the my_wp_export.sql file - everything should work.

Wrong permissions when uploading file on WORDPRESS (Windows server 2012)

I've recently moved my WP site from godaddy to a physical sever using windows server 2012 R2.
But I'm having problem uploading files using the Admin panel, After uploading the file, I can see it physically on the server (wp-content\upload\2017\10)
But I can't see it on the website it self.
I can only see the file if I'm changing it permissions on the server it self.
I've changed the permissions to the folder, I gave full access to the relevant users. But still, it doesn't work for new files\pictures I'm uploading via the wp admin panel
Edit:
I've notice that every time I come to change the folder permissions the permissions under CREATOR OWNER are always empty, Is it Related ?
Thank you very much for the help
When you upload a file, PHP sends the file to a temporary directory on your server's hard drive (usually C:\Windows\Temp) and then copies it over to the proper directory. Once the file has is initially put in the temporary directory, it gets the permissions of that directory. The problem is when Windows moves that file to the proper place, it keeps the temporary directory’s permissions, which can cause access problems.
The way to fix this is to change the temporary directory to a folder within your WordPress installation, usually wp-content/upgrade.
To do this, follow these directions:
Find your php.ini file.
Find the upload_tmp_dir line, and change it to the wp-content/upgrade folder.
Browse to this folder and verify that the permissions are set properly.
You should then have the ability to properly view all your images. You'll most likely need to select all the previous selected images, and change the owner of the files to the web folder owner. Then you should be good to go!
If you can’t upload an image at all, it’s probably because you need to give the IUSR account Read/Write/Modify permission on your wp-content folder. This will allow you to upload, and do the WordPress & plugin updates.
Once you have done that, all you need to do is give the IIS_IUSRS group Read permissions on your “C:\Windows\Temp” folder.
Make sure to notice that the two permission changes you make are not for the same user/group. Give IUSR permissions on your wp-content folder and IIS_IUSRS permissions on your Windows temp folder.
Note: If you have edited your php.ini file and change the upload temp directory then you will need to give IIS_IUSRS group read permissions on that folder instead.
That should do it, or at least it worked for me.
http://chris.wastedhalo.com/2011/01/wordpress-upload-permissions-on-iis-7-fix/
I find myself coming back to this question time after time when images I add to the Media Gallery don't have the correct permissions in the WordPress Uploads folder. Since I develop WordPress sites locally, it would be a pain to set permission on the Uploads folder every time I work on a new site.
To fix this, I created a folder "C:\Websites\Temp" without messing around with permissions or security settings, etc. Then in MAMP, I edited the php.ini template of the PHP version I was using for this site, php7.3.0.ini (File, Edit Tempate, PHP). I then set upload_tmp_dir to "C:\Websites\Temp":
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = c:\websites\temp
and voila, no more permission issues.
Well, a few years later, found this post. Tried it. Failed.
Other solution is to assign a specific user to the site in IIS and apply the right permisions to the folder containing the site.

Unreal file in Cpanel

I see an unknown tar file in cpanel file manager. The thing that is bothering me whether or not I delete this file.
Recently I found some malicious files in my wordpress website and the hosting provider sent me a message to look over the whole website. Can anyone tell me if this unreal file was responsible or not?
Unreal file
This is a unusual filename (with tar.gz). This isn't wordpress file also. I think is better to delete this file.
The file seems very odd and is not part of any installation.
It is also uploaded in your Home Directory - which no application does.
If you have not uploaded the folder yourself you should indeed delete it.
Afterwards it is nice to go through your access log files to see if there aren't any POST requests made to your website that seem odd.
You can also look through the file called .lastlogin in your cPanel's Home Directory - it contains all IP addresses that have accessed your cPanel account.

Change the path where Apache WAMP access to PHPMyAdmin

We work with a WordPress in Apache but we need to work with the same DataBase and files in differents PCs.
To do this, I know how change the path where apache search the files (Wordpress in that case) where we put in a Dropbox but I don't know how I can change the path to PHPMyAdmin to add it in Dropbox.
Sharing phpMyAdmin files will not help you. What you need is a centrally located mysql server which is shared and accessed by different PCs (on which code is developed). If you just want to share the database file (with out collaborating) then you can just export the database in .sql format and upload it to dropbox for others collaborators to download and use.

wordpress fresh install showing blank page

I am using linux. I downloaded wordpress zip file. I have a folder life.com and unzipped the wordpress contents in it.
I have created a virtual host life.com (its not a live site). its only accessible from my computer.
I set my apache web server and hosts so that life.com points to the folder.
When i open life.com it shows blank page. I just renames index.php to index1.php then it shows the contents of the folder life.com
I put a sample.php with hello. when i open life.com/sample.php it shows hello
there is no problem with the apache and php.
generally the fresh install of the wordpress should show the page
There doesn't seem to be a wp-config.php file. I need this before we can get started.
Need more help? We got it.
You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.
Create a Configuration File
instead of opening life.com, i made a folder in the apache root directory /srv/wordpress and unzipped the files there.
when i open localhost/wordpress then it shows
There doesn't seem to be a wp-config.php file. I need this before we can get started.
Need more help? We got it.
You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.
Create a Configuration File
its showing blank page when i open from virtual host (life.com) but opens correctly from localhost/wordpress.

Resources