Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by Neo

  1. Following your feedback, I was able to get it fixed with the following permissions @teppo :

    # Reset ownership to my sudo user
    sudo chown -R $USER:$USER /var/www/example.com/public_html
    # Make www-data the owning group of /site/assets 
    sudo chown -R $USER:www-data /var/www/example.com/public_html/site/assets/
    # Give recursively 664 permission to all files within the /site/assets folder 
    find /var/www/example.com/public_html/site/assets/ -type f -exec chmod 664 {} \;
    # Give recursively 775 permission to all directories within the /site/assets folder
    find /var/www/example.com/public_html/site/assets/ -type d -exec chmod 775 {} \;

    User and group can now write files AND directories within /site/assets while the rest of the installation is only owned by my user.

    I am the only user of this VPS.

    I am not getting an error message in the backend any longer when saving and publishing a page change, which now works fine.

    However, the following error persists on page save:

    Notice: A non well formed numeric value encountered in /var/www/example.com/public_html/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module on line 124

    I also get this, when visiting the modules page in the backend:

    Notice: A non well formed numeric value encountered in /var/www/example.com/public_html/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module on line 124
    Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/example.com/public_html/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module on line 439
    Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/example.com/public_html/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module on line 148

    That does not sound like a permission issue, but rather a problem or potential bug in the module that handles the inputfield for file uploads.

    Isn't that a ProcessWire core module?

    On the front-end I am not using any forms that would utilize a file upload field. So I assume this must relate to the standard image upload fields in the backend somewhere, where I did not make any modifications at all. The site is based on ProcessWire 3.0.32.

  2. Following your advice, I adjusted file ownership and permissions accordingly @teppo :

    sudo chown -R MyUser:www-data /var/www/example.com/public_html
    find /var/www/example.com/public_html/site/assets/ -type f -exec chmod 664 {} \;

    All pages are loading fine now... ?

    So I assume that would be a safe configuration to use, considering that only my sudo user and the Apache group now have write access to the files contained in site/assets/, correct?


    When trying to edit and save pages in the backend now, I am encountering a couple of interesting notifications / errors:

    Notice: A non well formed numeric value encountered in /var/www/example.com/public_html/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module on line 124
    Session: destinationPath is not writable


  3. As suggested, I created a test.php with the following content:

    <?php echo exec('whoami');

    Probably as expected, the result is the following:


    When I installed Debian, I created a new sudo user for security reasons, let's call him "MyUser" in this case, and assigned the ownership of the Processwire installation to that user:

    sudo chown -R $USER:$USER /var/www/example.com/public_html

    This is a convenient setup, because it allows me to quickly edit files via SFTP and Filezilla without getting a permission error.

    However, it seems to cause the permission issue now as all files / directories are assigned to owner "MyUser" and group "MyUser".

    So what would be the suggested way to give Apache the required permissions, keep convenient writing access via Filezilla for my sudo user and maintain a secure installation?

  4. Thanks for your feedback, @Edison. You were, right. Let's Encrypt created another virtual host file for port :443 to which I had to add the directory rules and restart the server:

    <Directory /var/www/example.com/public_html/>
    	Options FollowSymLinks
    	AllowOverride All
    	Require all granted

    So my links are working now. However, I am encountering another problem. Some pages are listed as blank.

    When I enable the debug mode, I get the following errors:

    Warning: file_put_contents(/var/www/example.com/public_html/site/assets/cache/FileCompiler/site/modules/AllInOneMinify/AllInOneMinify.module): failed to open stream: Permission denied in /var/www/example.com/public_html/wire/core/FileCompiler.php on line 242
    Warning: file_put_contents(/var/www/example.com/public_html/site/assets/cache/FileCompiler/site/templates/_init.php): failed to open stream: Permission denied in /var/www/example.com/public_html/wire/core/FileCompiler.php on line 242
    Warning: file_put_contents(/var/www/example.com/public_html/site/assets/cache/FileCompiler/site/templates/services.php): failed to open stream: Permission denied in /var/www/example.com/public_html/wire/core/FileCompiler.php on line 242
    Warning: file_put_contents(/var/www/example.com/public_html/site/assets/cache/FileCompiler/site/templates/_func.php): failed to open stream: Permission denied in /var/www/example.com/public_html/wire/core/FileCompiler.php on line 242

    Permissions for directories are set to 755 and for files to 644 in the Processwire installation.

    Any idea what could be wrong?


  5. Hey,

    I am trying to migrate a couple of Processwire sites from their respective, small VPS to a larger VPS on Digitalocean that will host all sites in the future.

    For that purposes, I installed a fresh droplet with Debian 10, Apache 2.4.38, PHP 7.3.4-2 and MariaDB 10.3.15.

    I created separate root directories for every site and a respective Virtual Host configuration file for each domain, for instance:

    sudo mkdir -p /var/www/example.com/public_html
    sudo chown -R $USER:$USER /var/www/example.com/public_html
    sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf

    The content of the Virtual Host configurations looks like this:

    <VirtualHost *:80>
            ServerName example.com
            ServerAlias www.example.com
            ServerAdmin admin@example.com
            DocumentRoot /var/www/example.com/public_html
            <Directory /var/www/example.com/public_html/>
                    Options FollowSymLinks
                    AllowOverride All
                    Require all granted
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    # This part seems to have been added by Let's Encrypt during SSL generation
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =www.example.com [OR]
    RewriteCond %{SERVER_NAME} =example.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

    I then enabled the configuration files and restarted Apache:

    sudo a2ensite example.com.conf
    sudo systemctl restart apache2

    Mod_rewrite has then been enabled via the following:

    sudo a2enmod rewrite


    I migrated the first site and database to the new server and the homepage loads fine via https (both non-www and www versions are available although it should redirect automatically to www which does not work).

    However, any link you try to visit throws a 404 error:

    Not Found

    The requested URL /link/ was not found on this server.
    Apache/2.4.38 (Debian) Server at example.com Port 443

    In order to test if the Processwire .htaccess file is detected, I added some random characters at top, which should break the site and throw a 500 error. However, nothing happens. It still loads the homepage and 404 errors for the subpages. .htaccess syntax checks out ok.

    What am I missing?

    Thanks for your feedback.


  6. Thanks for your feedback.

    Job pages are created using a front end form.

    In order to trash the old jobs, I ended up with the following code:

    $jobs = wire('pages')->find("template=job-template, parent=/expired-jobs/, include=unpublished");
    foreach($jobs as $job) {

    Now, regarding the problem of adding a unique value to each job link, I guess I would have to update Processwire first in order to access the PageNames and WireRandom classes?


    • Like 1
  7. Hey,

    I have a small niche job board that is based on ProcessWire 3.0.62 and encounter 2 problems:

    1. Job pages are unpublished after a certain amount of time using a cron job and then moved as children to the "Expired Jobs" page.

    Now, it is a bit annoying having to delete those old, unpublished job pages individually.

    What is the best way to programmatically delete all children of the "Expired Jobs" page in one go using a protected template in the backend?


    2. I am starting to get a problem with many similar job titles. Although, Processwire will add a number to the end of a link, when a certain job title already exists (e.g. My-Job-1, My-Job-2), this causes problems from time to time with the unpublishing process, for instance

    Can't save page 1997: /expired-jobs/product-designer-2/: Chosen parent '/expired-jobs/' already has a page named 'product-designer-2'

    What would be the best way to add a unique identifier to each link (e.g. combination of 6 or more random numbers and letters) to ensure unique links despite equal job titles?


    Thanks for your feedback.

  8. To provide further details regarding the server configuration:

    httpd -v
    Server version: Apache/2.4.6 (CentOS)
    Server built:   Oct 19 2017 20:39:16
    php -v
    PHP 7.1.16 (cli) (built: Mar 28 2018 13:19:29) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.1.16, Copyright (c) 1999-2018, by Zend Technologies
    mysql -V
    mysql  Ver 15.1 Distrib 5.5.56-MariaDB, for Linux (x86_64) using readline 5.1


    I could post the complete php.ini if required, but will share some key values for the moment:

    output_buffering = 4096
    max_input_time = 60
    memory_limit = 128M
    post_max_size = 8M
    upload_max_filesize = 2M
    max_file_uploads = 20
    default_socket_timeout = 60


    Http and database are running:

    sudo netstat -plunt | grep httpd
    tcp6       0      0 :::80                   :::*                    LISTEN      832/httpd           
    tcp6       0      0 :::443                  :::*                    LISTEN      832/httpd 
    sudo netstat -plunt | grep mysql
    tcp        0      0  *               LISTEN      1085/mysqld 


    Last updates have been installed in March, but this is an issue that happened before.



  9. Hi,

    I am running ProcessWire 3.0.62 on a 512 MB VPS with CentOS 7.3.1611 x64.

    The site operates stable for a couple of days and then suddenly shuts down with an internel server error - 500.

    I first thought this might be a caching issue and I disabled mod_pagespeed, but the problem persists.


    I noticed the following errors in the ProcessWire log that match this timeframe:

    Error: Exception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away (in /var/www/html/wire/core/WireDatabasePDO.php line 454)
    Error: Exception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away (in /var/www/html/wire/core/PagesLoader.php line 1110)
    Error: Exception: SQLSTATE[HY000] [2002] Connection refused (in /var/www/html/wire/core/ProcessWire.php line 377)


    Having a look at /var/log/httpd/error_log shows the following entries:

    [Mon Apr 30 03:36:02.299543 2018] [auth_digest:notice] [pid 835] AH01757: generating secret for digest authentication ...
    [Mon Apr 30 03:36:02.300730 2018] [lbmethod_heartbeat:notice] [pid 835] AH02282: No slotmem from mod_heartmonitor
    [Mon Apr 30 03:36:02.496198 2018] [mpm_prefork:notice] [pid 835] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.1.16 configured -- resuming normal operations
    [Mon Apr 30 03:36:02.496220 2018] [core:notice] [pid 835] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
    [Mon Apr 30 08:58:41.709509 2018] [mpm_prefork:notice] [pid 835] AH00170: caught SIGWINCH, shutting down gracefully
    [Mon Apr 30 11:59:04.905878 2018] [suexec:notice] [pid 832] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
    [Mon Apr 30 11:59:05.452221 2018] [auth_digest:notice] [pid 832] AH01757: generating secret for digest authentication ...
    [Mon Apr 30 11:59:05.456054 2018] [lbmethod_heartbeat:notice] [pid 832] AH02282: No slotmem from mod_heartmonitor
    [Mon Apr 30 11:59:05.922452 2018] [mpm_prefork:notice] [pid 832] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.1.16 configured -- resuming normal operations
    [Mon Apr 30 11:59:05.922522 2018] [core:notice] [pid 832] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

    There is nothing in the log that would immediately catch my attention regarding this 500 error.

    If I reboot the server the site operates normally again.


    Would appreciate your assistance to find the problem.


  10. I am working on a site that needs a simple booking calendar:

    - Visitors can choose a date and time-slot from a calendar on the front-end.

    - Reservations will be listed in the back-end and have to be confirmed by the admin.

    - Once the reservation is confirmed, an email is sent to the visitor. 

    Not sure if there is an existing module out there for not reinventing the wheel. Already had a look at the module section, but couldn't find anything stable so far.

    Would appreciate your ideas.







  11. Thanks for your responses.

    Yes @adrian, the idea to record and send search requests is unusual, but this will not be a high traffic site and there will be additional filters, who can access the search function.

    To summarize your input:

    1. Search: 

    As @Robin S mentioned, can I use a simple GET request to handle the search terms from the form and then process input in a single search template (search.php)? I.e. Get search terms -> sanitize input -> save input to variables -> create PHPMailer object and send input variables -> Show search results on the front-end ?

    2. Database Design: 

    I had a closer look at  the car example of kongondo's post on "Approaches to categorizing site content", i.e. simple multiple categories.

    So the objective is to have typical search requests like this:

    "Show me all red, second-hand vans from Toyota with Diesel engine built in 2012 with a price below 15.000 EUR."

    Instead of adding the required fields directly to my car-template.php, I would create pages with sub-pages as attribute categories and sub-categories in the tree, which will then be referenced in my car-template.php as Page Fieldtypes, correct? I assume this keeps the attributes more manageable if further sub-categories need to be added in the future?

    So I would probably have a tree view similar like this: 


    - Cars (car-template.php) -> this is where new vehicles will be added

    - Make

         -- Toyota

         -- Volkswagen

         -- BMW


    - Year

          -- 2000

          -- 2001

          -- 2002

          -- 2003


    - Color

         -- Red

         -- White

         -- Blue


    - Fuel

         -- Gas

         -- Diesel

         -- Electric


    - Condition

         -- New

         -- Used

    - Gear

         -- Automatic

         -- Manual

         -- Semi-automatic

    - Body

        - Compact

        - Convertible

        - Coupe

        - Off-Road

        - Van


    - etc.



    Now, there will probably be a couple of fields that won't be directly categories, such as price, mileage, description, images.

    Price and mileage, however, should be searchable. 

    I assume those can be added directly to car-template.php instead of creating individual pages?


    Would appreciate your feedback if this makes sense.




    • Like 1
  12. Dealing normally with simpler "brochure-style" websites, I am currently trying to figure out how to approach the following, more "advanced" problem in ProcessWire, so please bear with me:

    I would like to build a database of cars, which needs to be searchable by type, model, brand, registration date, mileage etc.

    For the database organisation, I already found kongondo's great post on "Approaches to categorizing site content". Will have to spend more time on the detailed organisation, while keeping things practical & manageable.

    For the search feature, I had a look at the search functions of Ryan's excellent Skyscrapers Site Profile. This uses the GET method in combination with search.php and the rendering functions in functions.php to request database entries that match the specified terms.

    Now the tricky part: I would like to send the search terms of every search request via email (PHPMailer) and ideally post them to the database as a new hidden page, which would require a POST request. I have created new pages before via the API based on form entries, so this should not be a problem. However, to my knowledge, you cannot POST and GET at the same time and from a security perspective, a GET request shouldn't change data on the server.

    Maybe this sounds trivial to a more experienced developer, but I would appreciate your advice.

    I am sure this is doable in ProcessWire (is there anything that isn't ?!?). ;) 



  13. I tried both methods, adding "br" tags via the source code and also using Shift+Enter. It is always removed on "Save".

    I also tried <br /> and <br/>; same result.

    When I unselect "Remove non-breaking spaces (nbsp)" for the field and I add a line break wrapped in paragraph (which is quiet ugly), the <br> is transformed into nbsp. This creates a space with a new line, but is not really the intended outcome: <p>&nbsp;</p>

    I also tried to explicitly allow br tags in config-body.js without success:

    CKEDITOR.editorConfig = function( config ) {
    	// Define changes to default configuration here. For example:
    	// config.uiColor = '#AADC6E';
      config.autoParagraph = false;
      config.AllowedContent = 'br[clear]';

    Not sure if this is an issue with the CKEDitor plugin.

    Also tried the "Newlines to XHTML Line Breaks" but that creates a mess with a <br /> for every new line, which is the idea of the module, but does not give you much control.

    The site is running on Processwire 3.x version, which is currently my only installation on localhost, so I have not been able to verify this behavior yet in other or "clean" installations.

  14. I am trying to allow <br> tags (line breaks) in the input field of the CKeditor, which are currently stripped.

    The field does not use a text formatter, the content type is set to "Markup/HTML" and ACF and HTML Purifier have been switched off.

    I have also added "br" to the extra allowed content. 

    It is still removed. Any idea how to get this working?



  15. So, basically you would just return the JSON-array without writing it to the file?

    Something like 

    return json_encode($json);

    Using "echo" would directly print it to the page. 

    However, in this case I guess I would have to provide the template location in my JS:


    which actually does not work. It does not throw an error, but only works with the actual JSON-file specifically provided as a URL, i.e. http://localhost/My_Project/site/templates/posts.json


    So I assume the JSON is not returned in the right way?


    • Like 1
  16. I have a site with a blog section (every blog post is a page), which I don't want to populate in the list view via the ordinary pagination.

    Instead, I have written a bit of JS to load the blog posts after each other: in this case always 2 blog posts by the click of a button via $.getJSON(). So I use a JSON file to get my page data from Processwire.

    On the ProcessWire site, I have written the following code on the top of my blog.php list view template:

      $json = array();
      $posts = wire('pages')->find('template=blog-post, sort=-blog_date');
      foreach($posts as $post) {
        $json[] = array(
          'link' => $post->url,
          'date' => $post->blog_date,
          'title' => $post->title
          //'preview' => substr($post->body, 0, 250)
      file_put_contents('posts.json', json_encode($json));

    So this basically creates the posts.json file in http://example.com/My_Project/site/templates/posts.json every time the template is accessed. 

    This works, the data is populated in the view.

    However, I am not sure if this is the best way to approach this considering performance as the json file is created every time the page is requested.

    Would appreciate your advice.


  • Create New...