• Resolved cliverlong

    (@cliverlong)


    Cannot upload posts and media to WordPress running on Ubuntu
    Have downloaded posts and media from WordPress.com site. Content extracted successfully from .zip and .tar files
    Ubuntu 22.04
    Local wordpress: 6.3.1


    I cannot use WordPress import as only accepts XML file of maximum 2MB and my downloaded file is 5MB.
    Installed two WordPress plugins to attempt post and media upload to WordPress on my personal Ubuntu server.
    results of attempt to import follow.

    WP Imp Exp. Click on : New Import > Upload from Desktop > Select files. Nothing appears to happen.
    I attempted to use: WP smart import export and wordpress admin displays the following error message:

    WP Import Export : If your .htaccess file were writable, we could do this automatically, but it isn’t. So you must either make it writable or manually update your .htaccess with the mod_rewrite rules found under WP Settings >> Permalinks. Until then, the exported and imported files are not protected from direct access.

    Now the following post says how to change access rights for .htaccess: https://stackoverflow.com/questions/34026663/how-to-make-htaccess-writeable-for-wordpress

    However I cannot find the .htaccess file.

    Following post says .htaccess can be in any of a variety of locations: https://serverfault.com/questions/161473/htaccess-location . None of these work for me.

    Any idea how to locate this .htaccess file on my Ubuntu system so I can run the chown above then try to run the WordPress import plugins?

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • abletec

    (@abletec)

    Hi, cliverlong, & welcome. First, I have a question–what is your webserver, Apache or Nginx? If Nginx, then that would explain the absence of the .htaccess file.

    Secondly, you may need to change your php.ini file. The variables involved are upload_max_filesize and post_max_size.

    There is a plugin called “add from server” that allows files uploaded to the server to be imported into the media library, but it hasn’t been tested for compatibility since v. 5.2, so I can’t recommend it any longer, unfortunately.

    Thread Starter cliverlong

    (@cliverlong)

    Thanks for your helpful and speedy reply.


    1a. WordPress is using Apache2. If I enter http://localhost/html in my browser, the Apache2 default page is displayed.
    1b. It is possible that although the machine is running Apache2, I just haven’t found the .htaccess file, rather than there not being one. I have listed the directories I searched for the .htaccess file in my original post (all under /var/www) but maybe I was searching incorrectly.
    I updated upload_max_filesize to 8M in /etc/php/8.1/apache2/php.ini and restarted apache. post_max_size was already 8M.
    I logged on to WordPress admin on my localhost and navigated to the “basic” import tool.
    I saw the following error message: WP Import Export : If your .htaccess file weredo this automatically, but it isn’t. So you must either make it writable or manually update your .htaccess with the mod_rewrite rules found under WP Settings >> Permalinks. Until then, the exported and imported files are not protected from direct access.
    However below this error message I saw the following: Choose a file from your computer: (Maximum size: 8 MB)
    I selected the “Browse” button and no dialog appeared to select the xml file containing the exported WP posts.
    I tried tool: Wp Smart Import > Import XML > Upload File and nothing occurred when I selected “Upload file”
    I tried tool: Wp Imp Exp > New Import > Select Files. This went through several setup steps and attempted to process the exported xml file. The WP Imp Exp tools attempted to process the xml file but every record was rejected with message: ERROR : Content, title, and excerpt are empty.
    So I cannot find a WP tool to import posts or media. This must be a very standard process when a WordPress site is migrated from on hosting service to another.
    What tools do others successfully use for migration? IO have seen CPanel is used but this is very expensive for a one off migration for a personal, non-commercial WP Site.

    DISCLAIMER! The following is written w/o the aid of coffee. Any errors or omissions are attributable to said lack.

    Ok, I guess I was unaware that this was a local install (did you mention that?) <blushing>. At this point we also don’t know what tool, if any, you used to make your local install, & that would help immensely.

    The standard tool used to import content is a plugin from the wordpress.org site. From your dashboard, please go to ‘Tools > Import’. Download the plugin, & follow the provided onscreen instructions.

    Please understand that the .htaccess file is hidden, so you’ll need to have your operating system set up to be able to see those. We don’t know what that is, so until we do, we can’t provide meaningful instructions.

    Again, as stated above, you don’t tell us what tool you used, if any, to do your local install. Please check the documentation on whatever tool you used, if applicable, because, some, like Xampp, actually require you run it w/administrative rights in order to set the proper read/write permissions.

    Please let us know if this helps, and/or if you have further questions. It’s now officially coffee time.

    Thread Starter cliverlong

    (@cliverlong)

    Thanks again for your prompt and thorough response. I have used “inline code” tags to highlight quotes from your post as I can’t find how to quote text on this forum.

    Ok, I guess I was unaware that this was a local install (did you mention that?) .

    Yes, in my original post: Local wordpress: 6.3.1

    At this point we also don’t know what tool, if any, you used to make your local install, & that would help immensely.
    Unfortunately I can’t remember, but the resulting environment is: is WordPress 6.3.1 on Ubuntu 22.04 from my original post, Apache2 from my second post and MySQL.

    The standard tool used to import content is a plugin from the wordpress.org site. From your dashboard, please go to ‘Tools > Import’. Download the plugin, & follow the provided onscreen instructions.

    I have tried the “standard” Import tool, see my original post. This has an upload limit of 2MB but I have increased this to 8MB using your instructions to modify php.ini

    Please understand that the .htaccess file is hidden, so you’ll need to have your operating system set up to be able to see those. We don’t know what that is, so until we do, we can’t provide meaningful instructions.

    As in my original post: Ubuntu 22.04

    Again, as stated above, you don’t tell us what tool you used, if any, to do your local install. Please check the documentation on whatever tool you used, if applicable, because, some, like Xampp, actually require you run it w/administrative rights in order to set the proper read/write permissions.

    The install process might have been Xampp, following a youtube video, I just can’t find any notes on what I did. However, I have a working, local WP environment using the software listed, where the only thing I can’t currently do is bulk upload posts and media from another WordPress environment (see post above).

    Please let us know if this helps, and/or if you have further questions. It’s now officially coffee time.


    I hope your coffee was enjoyable. Thanks again.

    • This reply was modified 10 months, 4 weeks ago by cliverlong. Reason: spelling error

    Cliverlong, part of my confusion is–or maybe just was–that I wasn’t sure if this was a WSL install, (or Mac equivalent), wherein Windows or Mac was the actual OS, or if it was an actual standalone Ubuntu server.

    Now I feel I’m getting into territory where you might already know what I’m about to say, & it feels condescending. If so, apologies in advance. Here goes. To find hidden files on a Linux system, you use the command ls /a (perhaps combined w/other options as well). If you’re using a GUI, then please ensure your file manager is set to show hidden files.

    I think you said yes, but are you able to view the XML files you’ve exported? You can do that w/any text editor.

    The web server files should belong to the webserver group. In Apache, that’s generally www-data. Files in the var/www subfolder (which appears to be where you’re housing the site), should have permissions of 644 & directories/subdirectories of 755.

    If after the above you still can’t find a .htaccess file, Theme Isle gives some tips on how to create 1:

    https://themeisle.com/blog/htaccess-file-in-wordpress/

    If we haven’t found success w/these steps, perhaps please consider using pastebin or similar to where we can look at your Apache & PHP configuration files. I have to admit I’m more of an Nginx gal myself, but I can probably find my way through Apache. Nginx can at first be a headache to set up, but the performance is often superior. Since this is a local install, though, the additional work probably isn’t worth it, accept, perhaps, as a learning exercise if the time ever comes to set it up on a VPS.

    Another thing you might find helpful–& it’s always my first goto when my server’s acting wonky–is to consult my error logs. They’ll either be in /var/log/apache2 or /var/log/httpd. If you’re not quite sure what they’re telling you, then again, perhaps paste 1 into pastebin w/some questions, & we can help w/that.

    Let’s see what this gets us. We’ll get this resolved.

    Thread Starter cliverlong

    (@cliverlong)

    Cliverlong, part of my confusion is–or maybe just was–that I wasn’t sure if this was a WSL install, (or Mac equivalent), wherein Windows or Mac was the actual OS, or if it was an actual standalone Ubuntu server.

    I am very grateful for the time and detail you are putting in to try to help me in this.

    Now I feel I’m getting into territory where you might already know what I’m about to say, & it feels condescending. If so, apologies in advance. Here goes. To find hidden files on a Linux system, you use the command ls /a (perhaps combined w/other options as well). If you’re using a GUI, then please ensure your file manager is set to show hidden files.

    My Linux knowledge is very fragmentary – I pick things up as I need them – so I may lack some ‘obvious’ knowledge. Any suggestions for actions or fixes are most gratefully received by me.

    As per your instruction, the command ls -a has found the .htaccess file. See below:

    clive@clive-EB1033:/var/www$ ls -a . .. crl_h5p html wordpress

    clive@clive-EB1033:/var/www$ cd wordpress/ -bash: cd: wordpress/: Permission denied

    clive@clive-EB1033:/var/www$ sudo su [sudo] password for clive:

    root@clive-EB1033:/var/www# ls -a . .. crl_h5p html wordpress

    root@clive-EB1033:/var/www# cd wordpress/

    root@clive-EB1033:/var/www/wordpress# ls -a . robots.txt wp-config-sample.php wp-login.php .. wp-activate.php wp-content wp-mail.php .htaccess wp-admin etc. etc…..

    I think you said yes, but are you able to view the XML files you’ve exported? You can do that w/any text editor.

    An extract from the start of the extracted XML file follows:

    <?xml version="1.0" encoding="UTF-8"?>

    <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. It contains information about your site's posts, pages, comments, categories, and other content. You may use this file to transfer that content from one site to another.>

    The web server files should belong to the webserver group. In Apache, that’s generally www-data. Files in the var/www subfolder (which appears to be where you’re housing the site), should have permissions of 644 & directories/subdirectories of 755. If after the above you still can’t find a .htaccess file, Theme Isle gives some tips on how to create 1: https://themeisle.com/blog/htaccess-file-in-wordpress/

    Is the following the required information about the file permissions?

    root@clive-EB1033:/var/www/wordpress# ls -l .htaccess -rw-r----- 1 www-data www-data 261 Apr 12 06:18 .htaccess

    If we haven’t found success w/these steps, perhaps please consider using pastebin or similar to where we can look at your Apache & PHP configuration files. I have to admit I’m more of an Nginx gal myself, but I can probably find my way through Apache. Nginx can at first be a headache to set up, but the performance is often superior. Since this is a local install, though, the additional work probably isn’t worth it, accept, perhaps, as a learning exercise if the time ever comes to set it up on a VPS. Another thing you might find helpful–& it’s always my first goto when my server’s acting wonky–is to consult my error logs. They’ll either be in /var/log/apache2 or /var/log/httpd. If you’re not quite sure what they’re telling you, then again, perhaps paste 1 into pastebin w/some questions, & we can help w/that. Let’s see what this gets us. We’ll get this resolved.

    Here are the list of the contents of /var/log/apache2 and the contents of some of the files. I can’t see anything immediately relevant to my problem of not be able to upload the WordPress posts and media:

    root@clive-EB1033:/var/log# cd apache2/ root@clive-EB1033:/var/log/apache2# ls access.log access.log.3.gz error.log.1 error.log.4.gz access.log.1 access.log.4.gz error.log.10.gz error.log.5.gz access.log.10.gz access.log.5.gz error.log.11.gz error.log.6.gz access.log.11.gz access.log.6.gz error.log.12.gz error.log.7.gz access.log.12.gz access.log.7.gz error.log.13.gz error.log.8.gz access.log.13.gz access.log.8.gz error.log.14.gz error.log.9.gz access.log.14.gz access.log.9.gz error.log.2.gz other_vhosts_access.log access.log.2.gz error.log error.log.3.gz

    root@clive-EB1033:/var/log/apache2# cat access.log

    root@clive-EB1033:/var/log/apache2# cat error.log.1 [Tue Sep 12 14:21:13.456239 2023] [mpm_prefork:notice] [pid 1340] AH00163: Apache/2.4.52 (Ubuntu) configured -- resuming normal operations [Tue Sep 12 14:21:13.456342 2023] [core:notice] [pid 1340] AH00094: Command line: '/usr/sbin/apache2' [Tue Sep 12 14:43:42.226967 2023] [mpm_prefork:notice] [pid 1340] AH00170: caught SIGWINCH, shutting down gracefully [Tue Sep 12 14:43:43.729282 2023] [mpm_prefork:notice] [pid 6294] AH00163: Apache/2.4.52 (Ubuntu) configured -- resuming normal operations [Tue Sep 12 14:43:43.729561 2023] [core:notice] [pid 6294] AH00094: Command line: '/usr/sbin/apache2' [Tue Sep 12 15:29:39.902467 2023] [mpm_prefork:notice] [pid 6294] AH00170: caught SIGWINCH, shutting down gracefully [Tue Sep 12 15:42:22.811138 2023] [mpm_prefork:notice] [pid 1333] AH00163: Apache/2.4.52 (Ubuntu) configured -- resuming normal operations [Tue Sep 12 15:42:22.856012 2023] [core:notice] [pid 1333] AH00094: Command line: '/usr/sbin/apache2' [Tue Sep 12 22:26:10.937770 2023] [mpm_prefork:notice] [pid 1333] AH00170: caught SIGWINCH, shutting down gracefully [Tue Sep 12 22:26:59.725969 2023] [mpm_prefork:notice] [pid 1250] AH00163: Apache/2.4.52 (Ubuntu) configured -- resuming normal operations [Tue Sep 12 22:26:59.768772 2023] [core:notice] [pid 1250] AH00094: Command line: '/usr/sbin/apache2' [Sun Sep 17 14:06:43.597753 2023] [mpm_prefork:notice] [pid 1250] AH00171: Graceful restart requested, doing restart AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message root@clive-EB1033:/var/log/apache2# cat error.log [Sun Sep 17 14:06:43.974417 2023] [mpm_prefork:notice] [pid 1250] AH00163: Apache/2.4.52 (Ubuntu) configured -- resuming normal operations [Sun Sep 17 14:06:43.974525 2023] [core:notice] [pid 1250] AH00094: Command line: '/usr/sbin/apache2' root@clive-EB1033:/var/log/apache2#

    • This reply was modified 10 months, 3 weeks ago by cliverlong.

    cliverlong, you asked:

    “Is the following the required information about the file permissions?”

    Precise-a-dicely. And the listing you just provided showed me quite clearly what I had suspected right along, that the permissions are incorrect. I’m now going into teaching mode. Perhaps tldr:, but these will be important concepts when learning Linux, so if not from me, then you’ll surely benefit from reading about it from someone. There are assuredly better teachers & writers out there than me, but I’ll have a go.

    The file permissions are the part of the listing that says:

    -rw-r—–

    The first – indicates that .htaccess is a file. Next follow the permissions.

    The permissions are divided into 3 aspects, which are read, write, and execute. These are abbreviated in file listings as r, w, and x, respectively if the permission is present, else a – indicates no permission. Those permissions are given to 3 “entities”. These are the file owner, the group that owns the file, & everyone else. Each permission corresponds to a number. r (the read permission) corresponds to 4, w, the write permission, corresponds to the number 2, and x, the execute permission, corresponds to the number 1. Obviously if the particular permission is absent, as shown by the -, it has a number of 0. This is why we talk about permissions, say, of 755 or 644.

    According to the above, what are the numeric permissions on your .htaccess file? If you said 640, you’re correct. The file owner has a permission of 6 (read+write, 4+2); the group that owns the file has a permission of 4 (read only), and everyone else has 0 permissions. Normally 644 is the permission for .htaccess, so the owner permissions are ok, as are the groups, but usually the everyone group gets read permission in this context. & that might not be necessary for a .htaccess file, but it surely is for others.

    Generally directories are assigned permissions of 755, while files are assigned permissions of 644. These can be altered as required, but it’s a starting point.

    The group that owns your .htaccess file is www-data, which is associated w/the Apache webserver, and sometimes other webservers as well.

    Another switch associated w/the ls command is the -l switch (for long, like this post), and it gives you the file owner, size, date, and other information which is often really good to know when dealing w/all this. I suspect you used it when providing your listings, but just covering bases.

    Usually I go into the /var directory and type:

    chmod -R 755 www

    The -R stands for recursive and tells the operating system to make changes to www and all its subdirectories. Please note the capital R.

    I think once that’s done, your upload woes should be cured. & I hope I’ve’ve taught you something as opposed to boring you to tears.

    Please let us know whether or not this was helpful. Sorry for the longwinded Linux lesson on a weekend.

    Thread Starter cliverlong

    (@cliverlong)

    First , the chown command you documented above seems to have fixed the issues to the import / export plug-ins not running. Thank-you.

    I am working my way through the plug-in: WP All Import. The plug-in is importing posts but I may have a fair amount of work to map fields from the XML file and I’m not clear yet how to import images. If I have specific issues with the use of one of the import plug-ins I will create a new forum post.

    Thanks again.

    cliverlong, would you please then mark this topic as resolved so all the volunteers are clear you’ve been helped to your satisfaction, at least w/this?

    I’ve enjoyed working w/you and I’m glad I was able to help. Let us know any time you need something.

    Thread Starter cliverlong

    (@cliverlong)

    this thread has been marked as resolved.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Cannot upload posts and media to WordPress running on Ubuntu’ is closed to new replies.