I am trying to get a copy of a Wordpress site spun up in my local environment and the home page loads correctly, but when I attempt to load a link from the menu I get a 404.
I have given ownership to www-data, and set folders and files to 755 & 644.
I have the default .htaccess in place.
apache.conf is set so the directory AllowOverwrite is set to ALL
So now when I look at the apache log I see this entry just after loading a page that results in a 404...
[php7:error] [pid 6427] [client ::1:53910] script '/home/my-user/development/index.php' not found or unable to stat, referer: http://localhost/my-wordpress-site/
I have the default .htaccess in place.
That might not do, if you have WP running in a folder, and not at root domain level.
Flush the permalink settings in the admin dashboard (simply save the settings once again), then WP should update the .htaccess itself – provided it is writable.
Related
I've read countless forum posts about this but none of the answers seem to help my situation. Here's the log excerpt:
[proxy_fcgi:error] [pid XXXX] [client redacted] AH01071: Got error 'Unable to open primary script: /home/user-account/public_html/www/index.php (No such file or directory)'
I've verified manually that this file is readable through SSH; also, other non-php files can be accessed through the browser.
My directory structure is as follows:
/home/user-account
/home/user-account/apps
/home/user-account/apps/old
/home/user-account/apps/current
/home/user-account/public_html
/home/user-account/public_html/old > symlink to > /home/user-account/apps/old
/home/user-account/public_html/test > symlink to > /home/user-account/apps/current
/home/user-account/public_html/www > symlink to > /home/user-account/apps/current
I have 2 subdomains on 'domain.com':
old.domain.com
test.domain.com
Therefore due to how cPanel/WHM/Apache writes out their virtualhosts (considering the ServerAlias directive), the resulting domain structure is:
old.domain.com
www.old.domain.com (I ignore this)
test.domain.com
www.test.domain.com (I ignore this)
domain.com (.htaccess redirects to www.domain.com)
www.domain.com (This is the domain with the issue; also domain.com would be an issue if not for the redirect)
Up until now I've been developing my wordpress website under a real directory /home/user-account/public_html/test. The site is in perfect working condition. Then I decided to go live. I moved the real folder to it's current location (/home/user-account/apps/current) and symlinked /home/user-account/public_html/test to it. I restarted Apache and verified the test.domain.com site still operated as expected (testing out the symlink). Feeling confident in the symlink setup, I removed my original symlink of /home/user-account/public_html/www (pointing to my old rails app at /home/user-account/apps/old) and created a new one pointing to /home/user-account/apps/current. This is when the issue started.
httpd.conf:
The only appreciable difference between the test subdomain and the main domain (with www aliased) is that the test subdomain's auto-generated directives point to the true aliased folder location (DocumentRoot/Directory/ScriptAlias all use /home/user-account/public_html/test). I believe this was because I had used cPanel to create a subdomain which had to point to a directory within /home/user-account/public_html. But the main domain's auto-generated directives all point to /home/user-account/public_html instead of /home/user-account/public_html/www.
However, apache 2.4 allows me to include custom virtualhost config options by placing my custom.conf files in the appropriate directories. So I don't need any of them for the test subdomain but I had to use them for the main domain; I know they're working because the error log (found at the top of this post) shows it's using the proper DocumentRoot. Here's an excerpt from the std custom.conf to show that in addition to setting the DocumentRoot I also override the other autogenerated directives explicitly:
DocumentRoot /home/user-account/public_html/www
<IfModule mod_include.c>
<Directory "/home/user-account/public_html/www">
SSILegacyExprParser On
</Directory>
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ /home/user-account/public_html/www/cgi-bin/
</IfModule>
<IfModule ssl_module>
<Directory "/home/user-account/public_html/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
</IfModule>
File permissions:
I haven't changed the file permissions from their original setup and I've already verified they're correct. Again, test.domain.com was working as expected. It's only (www.?)domain.com that isn't.
Other 'fixes' that did nothing:
Rebuilding/restarting PHP-FPM (ineffective)
SetHandler/ProxyOverride (SetHandler is automatically created for me by rebuildhttpdconf and I don't expect it's the issue as it's working for the test subdomain; ProxyOverride doesn't seem to do anything)
Set up wordpress .htaccess (already in place and matches what is shown here. Again, test subdomain is working and it's an alias just like www is)
Server stats:
EasyApache 4 with
Apache 2.4.43
mod_proxy_fcgi
PHP 7.3
php73-php-fpm
Whatever you consider, remember that there's practically no difference between the files in the test subdomain vs the main domain (.htaccess included); they're both aliased to the same directory. The only difference I can see is that test is a registered subdomain and therefore httpd.conf handles it slightly differently than the main domain. However I can't just add a 'www' subdomain through cPanel - it won't let me - probably because it aliases www anyway.
I've been clawing around trying to fix this and my public website has been down for 24+ hours so I would greatly appreciate any help you can provide!
Addendum:
I don't know if it's relevant (it didn't seem to affect my old rails app), but under WHM > Manage SSL Hosts, my main domain and www subdomain point to a document root of /home/user-account/public_html, whereas my subdomains point to the correct respective directories.
I also tried setting the vhost on the main domain to use the test directory (same as the test subdomain) but it's giving me the same error. I don't think it's a permission/file issue.
I also created a test.php file in the /public_html directory in order to test out a direct access. It still erred out and logged:
AH01071: Got error 'Unable to open primary script: /home/user-account/public_html/www/index.php (No such file or directory)', referer: https:// domain.com/test.php
And the answer is that I had to set the doc_root through the PHP-FPM Configuration for the given domain. Why? I don't know - if someone can shed some light on this I'd rather not have to do things through the FPM configuration and set it through Apache if possible. I don't have to do this for subdomains...
I have an issue with my website, I linked it with Wordpress but there's a sub-menu where I get a 403 forbidden error.
This is the folder in iPage
And here's the Wordpress page I want to show up
I tried removing the .htmaccess file and refreshing the permalinks but it didn't work at all.
Any help?
Noo, Wordpress dont need any folders.
Wordpress works with the .htaccess
You can delete this folder and restart your server.
You don't have to add any directories or files after WP installation is finished, all WordPress functions will work via administration panel. But let me explain what is going on.
The 403 forbidden error you are getting is normal and expected webserver behavior in your case.
The webserver checks the request (the URL given) and tries to determine if it is a file or a directory. In your case it is a directory, which (by default) makes your webserver serve index.html or index.php file inside that directory.
However, if no such file exists, the webserver's next step is to list all items in a directory, which you don't want and is disabled in your case (and in most web server's by default for security reasons), thus webserver returning 403 forbidden error.
You can try to add a file named index.html inside your directory and see what happens, the 403 forbidden error will be gone and webserver serve your file.
If you want to serve your WordPress page instead of the actual directory you have on the server, you will have to remove or rename the directory on your server, or rename the permalink for the WordPress page.
I just recently changed to Digital Ocean to have full Shell access and stuff to advance my knowledge of code. I made a script and removed .php from url's to make them look nicer in the url bar and as well i have had to create a ".php" file so i can re-route users to the login.php page. Since i have created the .php file i keep getting a 403 error. Access Denied. Its the same error that shows up when you place "Deny from all" in a .htaccess to block traffic from viewing a includes folder or etc. The error i get in the error log is:
[Fri Jun 30 00:42:21.056280 2017] [authz_core:error] [pid 2808]
[client 76.111.178.215:50805] AH01630: client denied by server
configuration: /var/www/affattraction.com/public_html/login/admin/.php
If anyone has encountered this or knows how i can give permission to access the page ".php" it will be greatly appreciated! This worked on my old cPanel.
Thanks!
https://coinsafe.io/
I recently purchased and applied an SSL certificate.
After getting it all set-up, when I go to the site it downloads the index.php file...
There is code in the file but I cleared it out to see if it was my code causing it, and it downloaded it again and it was empty as expected.
The weird thing is when it downloads, it's not a .php file and it's called "download"
How can I fix this?
Edit
I am now getting this error [Sat Nov 16 04:09:07 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
when I try to start Apache.
Basically, if Apache is trying to send a PHP file to your visitor, it means that Apache doesn't realise that the PHP is a script file.
This in turn means that apache hasn't loaded the php module, even if it's installed.
If you've done nothing else, there should be some sort of hint in your apache error.log, usually located in /var/log/apache2/ on ubuntu.
Also, in ubuntu php, you should have sym-links to php.conf and .load in /etc/apache2/mods-enabled/
While my website works fine on my local environment (MAMP) when I upload the files to my server (bluehost), I run into the following issue:
I have a link with a php get variable (i.e. /xxx.php?p=bob) that invokes a javascript function (popitup) that opens a pop-up window.
The link is structured as follows:
<?php echo "<a href='media_player.php?p=".$listen_now."' onclick=\"return popitup('media_player.php?p=".$listen_now."')\">"
The popitup function is defined as follows:
function popitup(url) {
newwindow=window.open(url,'name','height=700,width=375');
if (window.focus) {newwindow.focus()}
return false;
}
When the pop-up window opens, the page contents do not load, and I get the following message:
[an error occurred while processing this directive]
The main error log shows the following warning:
[Mon May 28 08:23:40 2012] [warn] RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored.
The .htaccess file in my public_html folder does not contain any redirects or rewrites.
Any leads on how I might solve this issue are very much appreciated.
RewriteCond warnings come from Apache's mod_rewrite. You have a broken rewrite rule in either:
.htaccess (directory of .php file or in any directory up the tree to the system root)
Virtual Host configuration
main apache configuration
Find its location and fix it there.