nginx: [emerg] open() "/www/server/nginx/conf/enable-php.conf" failed - php

ERROR: An error was detected in the configuration file. Please solve it before proceeding
nginx: [emerg] open() "/www/server/nginx/conf/enable-php.conf" failed (2: No such file or directory) in /www/server/nginx/conf/nginx.conf:68
nginx: configuration file /www/server/nginx/conf/nginx.conf test failed
AAPanel with Apache
While Adding new Site it's give this error

Just run this command and try again:
touch /www/server/nginx/conf/enable-php.conf

Related

Laravel: Can't access app from different URLs (with also different ports and servers) at the same time

Previously, I've asked for a Laravel issue in this question:
Laravel: Routing conflict when launching app by accesing "http://localhost/<myapp>/public", when project folder is placed in default Apache directory
There, I've mentioned that I have a Laravel project folder placed into the default Apache root directory. That's it, the one that is used for placing the content of any website. In my Linux Mint installation, that directory is: "/var/www/html/", so my project is in a subdirectory called "infoalq".
Also, I've mentioned I had two ways for viewing the content of the project. One of them is running the command "php artisan serve" in the terminal, while placed in the project folder (in my case, "/var/www/html/infoalq/") and then, going to the URL "http://localhost:8000" (using port 8000) in the browser.
The other way is just going to the URL "http://localhost/infoalq/public/" (using the HTTP port 80, like is configured in Apache by default), just with having the Apache server active.
The issue is this one: I can't access simultaneously to the content of the app in both ways. I mean, if I access to it by going to "http://localhost:8000", it shows perfectly the welcome view, but then, if I go to "http://localhost/infoalq/public/" in another tab in the same session, I get an error page showing this:
UnexpectedValueException
The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/infoalq/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: file_put_contents(/var/www/html/infoalq/storage/framework/sessions/adfnCUfB0vFv305r0P8mUgkdJHbvlfqctbHu6etu): Failed to open stream: Permission denied Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}}
Something similar happens in the opposite case. When I try to access the website by the URL "http://localhost:8000" in another tab, after accessing to it by the URL "http://localhost/infoalq/public/" (which initially works fine), I get an error page showing this:
ErrorException
file_put_contents(/var/www/html/infoalq/storage/framework/sessions/IlqNl7oqUUAiMPAUjx6FlQOvOsNcHadDLNePjvG3): Failed to open stream: Permission denied
So then, I have to restart the browser every time I want to view the app running with any of those ways.
As I've mentioned in the other post, I'm using:
Linux Mint 21 Vanessa
Apache/2.4.52 (Ubuntu)
PHP 8.2.1
Laravel v9.48.0
Does anyone knows if is there a solution for this? Or it's just like this and there's nothing to do? I mean, perhaps there is no way to run the project simultaneously in both ways, without restarting the browser. I think there it must be a conflict between the Apache server and the PHP server. If there's any concept that I'm not clear about or I'm confusing about, please let me know.
Thank you very much!
Leandro
Using the terminal in /etc/apache2/sites-available/, create a file with the following name: infoalq.local.conf
Add the following content to it:
<VirtualHost *:80>
ServerName infoalq.local
ServerAlias www.infoalq.local
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/infoalq
<Directory /var/www/html/infoalq>
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
After that you have to ensite the domain name:
sudo a2ensite infoalq.local
sudo systemctl reload apache2.service
Into /etc/hosts add the following line:
127.0.0.1 infoalq.local www.infoalq.local
Use the following URL address: http://infoalq.local

Laravel Valet not resolving sites after install

Having a terribly frustrating time not having valet working on a fresh install. Going to any *.test site in my browser just hangs and eventually gets the error message This site can’t be reached, "ping app.test" hangs as well, and eventually errors with "ping: cannot resolve app.test: Unknown host". However pinging a different domain (such as ping.xyz errors immediately, as opposed to after ~20 seconds like with *.test).
On Os Sierra, my composer.json looks like the following
{
"require": {
"laravel/installer": "^1.5",
"laravel/valet": "dev-master"
}
}
Since I've seen that dev-master resolved this for some people. All my processes seem to be running:
However some clues are that http://localhost/ in my browser returns a page 404 - not found, and running sudo nginx returns a bunch of already in user errors:
❯ pwd
/Users/schorr/.valet
schorr#Andrew-Schorr ~/.valet
❯ sudo Nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
and valet fetch-share-url returns
❯ valet fetch-share-url [17:04:53]
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
...
Any help is greatly appreciated. thanks!
Finally figured this out, for anyone else in my very specific situation:
I had changed my user name on the same machine, and for whatever reason installing dnsmasq wasn't overwriting the old /Users/user/.valet/dnsmasq.conf file. So at the very bottom I had:
conf-file=/Users/OLD_USER_NAME/.valet/dnsmasq.conf
conf-file=/Users/NEW_USER_NAME/.valet/dnsmasq.conf
So all I had to do was comment out the OLD_USER_NAME line and was good to go :|
Append http:// to the url the first time you hit it. For example use http://websitedir.test
I hope it's this simple, let me know.
Try the command 'valet paths' and let me know what that spits out.

Nginx server error connect to the port

I'm trying to connect my port 7979 to nginx and it doesn't work.
I was on localhost:7979/myproject/app/index.php but when I restarted my mac and I updated it, I now see the error message:
ERR_CONNECTION_REFUSED
When I try sudo nginx I see the following messages.
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] still could not bind()
Port 80 is functioning. If I go to localhost:80 I see this message in the html page:
Default website Congratulations, your Nginx seems to work just fine.
:)
Why am I unable to use port 7979?
I changed the root and the port and it worked on site-available/default.
The root by default wasn't good i don't know why it changed when i restarted my mac.
THan
It's difficult to troubleshoot with this little info available. So first:
An error message like nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use) indicates that something is already listening on port 80 and hence nginx can't do that as well when you start it.
Assuming your configuration files are perfectly ok, you'll have to figure out what is already listening on ports 80, 443 and 306. It might be an instance of nginx that's running with an older configuration but without much more details thats' just a guess.
See what processes are running:
$ ps -ax
See if there's an nginx instance running:
$ ps -ax | grep nginx
Netstat can give you what ports are being listened to:
$ nestat -an | grep LISTEN
To find out which process is listening to a given port:
$ sudo lsof -i :631
(631 is just an example)
What I suspect: you're starting nginx while it's already running. If it's already running, you should restart it instead of starting a new copy.
This might be of help: https://serverfault.com/questions/225948/how-to-restart-nginx-on-mac-os-x
In essence:
$ sudo nginx -s reload
Just a warning I don't run nginx on macOS, but it should work if nginx on macOS reacts like it does on FreeBSD (which macOS uses as a long distant base)

error 7#7: *1 upstream prematurely closed connection while reading response header from upstream

I have just compiled php7 in a docker container, and try to serve it with ngnix (which is also in a docker container).
and using php-fpm ...
I just serve a simple php file index.php with a simple line: echo "Hello World"; for a test. In the log of docker-compose up, for the ngnix server I have the error message:
error 7#7: *1 upstream prematurely closed connection while reading response header from upstream
Why is this happening?

restarting nginx by php doesn't work

I'm trying to restart nginx from php
The problem is when I type the code from my command line everything work fine
but from my php
i got this as an output
* Restarting nginx nginx ...fail!
My php code is
echo shell_exec ("service nginx restart");
file permission 7777
nginx error log
2016/09/15 15:17:13 [emerg] 2872#0: open() "/run/nginx.pid" failed (13: Permission denied)
2016/09/15 15:30:30 [warn] 2997#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2016/09/15 15:30:30 [emerg] 2997#0: open() "/run/nginx.pid" failed (13: Permission denied)
I solved the problem by adding this command inside sudo users
what i did is
1-visudo
2-go to the last line and add this
www-data ALL = NOPASSWD: /etc/init.d/nginx reload
and the problem is fixed

Categories