Compiled nginx doesn't work with PHP - nginx

I have a properly installed (apt-get) nginx that works perfectly with html and php but when I download the source of the same version (I don't modify it for testing purposes), I configure it with sudo ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin --without-http_gzip_module then make, install, reload and restart it all the PHP files stop working, they are being served as binary so the browser prompts to save them, HTML files continue to be served properly.
Any insights on where to start debugging this issue? All the configs remained the same from the working version, the only difference is that .php files don't work.

Related

Permissions and performance issues using Windows 11 + WSL2 (Ubuntu), Docker Desktop & WordPress via docker-compose local environment

I am working on a project handed over by a previous developer which utilises docker desktop and a docker-compose.yml file to bring up a WordPress project on my Windows PC. This worked okay on my last PC (Windows 10), I've now upgraded to a new PC running on Windows 11.
The project worked fine with a non WSL version of docker, just using hyper-v and docker-compose with some mounted volumes to create the containers and code up a bespoke WordPress theme (running on roots/sage 8).
Since moving to Windows 11, the project has been almost unusable due to massively slow pagespeed (30 seconds minimum to load just about anything).
I tried to solve this by switching to WSL2. I followed tutorials from Microsoft & Docker to get WSL2 setup with Ubuntu.
I did a totally clean install of:
WSL2
Ubuntu
Docker Desktop
VS Code
My understanding is that adding the project files directly into Ubuntu is the best way to go as it should be a lot faster than trying to mount the files from Windows, so I setup SSH keys and cloned the repo into my /home/andy/ directory.
Running docker-compose up successfully fires up the website but I then get hit with loads of issues I never encountered while running the project via docker desktop without WSL2.
WordPress or the web user seems to be lacking permissions to write to the wp-content directory
-- Can't install any plugins
-- Can't upload media
VS code (launched via code . in the project directory) doesn't have permission to write to anywhere in wp-content
FileZilla is unable to create any folders within wp-content including in wp-content/uploads
I need to get this project working, I'm obviously not a docker or linux expert, I just need to get it fired up so I can continue coding with WordPress!
I've trawled through most pages of Google's search results for people having similar issues and I've done a fresh install of the WSL2/Docker setup multiple times after trying different things to get this to work but nothing is working.
I've tried:
adding to the docker-entrypoint.sh chown -R www-data:www-data /var/www/html
-- This was to try and give the www-data user ownership of everything mounted into the var/www/html directory, which appeared initially to help but broke other permissions, like Filezilla being able to write to wp-content
Ensured that all the directories/files in my project folder had the correct permissions for WordPress 755 for directories & 644 for files
-- Had no effect on the issue
Attempted to set 777 recursively on the entire project directory in Ubuntu
-- Still had issues with FileZilla & VS Code, and for some reason, when I did docker-compose up the permissions on wp-content reset themselves from 777 to 755
Added user:$USER within the wordpress part of the docker-compose.yml file, and then did USER=root docker-compose up
-- This appeared to give WordPress the permissions/access needed in order to write to wp-content as I could now download and install plugins, and upload media, but the entire backend of WordPress was very slow and I still couldn't save files with VS code, or download with FileZilla.
Attempted to take ownership of the /home/andy directory where my project files live via sudo chown -R andy /home/andy/
-- This allowed VS Code & FileZilla to both work as expected, saving files and downloading files from a remote server into Ubuntu via WSL2
With weird root user hacky solution + chown on the user directory, I appeared to have got everything "working", but wp-admin was so ridiculously slow, it was barely usable.
Another post I came across said that using .local to access the site was a bad idea since that could cause slow performance with docker, so I then changed the website url in my hosts file, and did a find and replace on the DB/Files to reflect the change, and now the backend of WordPress works fast, but appears to have permissions issues as lots of plugins are complaining about not having the correct permissions and I'm unable to download / install or even deactivate existing plugins.
I'm basically at a total loss at this point as for how to get this working. If anyone has any suggestions I'd be very grateful.
Thanks!

Will reinstalling nginx remove configs

I want to add a new module to nginx but its on production and deleting nginx configuration is not an option.
After a bit of research I noticed that I have to reinstall nginx in order to add a module to it.
So my question is, is it possible in any way to reinstall nginx (and executing the ./configure command without messing up the current nginx configuration?
All I need is to generate the .so file to copy it to the existing /usr/lib64/nginx/modules directory.

Wamp 3.0.6 server can not run Composer and Symfony

Please I need help on this project, I have wamp server to run the project on symphony.Look at the error display on my web browser ,when load the project from wamp server
If I run this code from my command prompt see the results php app/check.php
If I run this code from my command prompt see the results php app/check.php
php app/console server:run
It looks like you also have XAMPP installed on your system, or did at one time.
See the line that says
Configuration file used in PHP : C:\xampp\php\php.ini
^^^^^
I would suggest that you check your Windows PATH. I guess XAMPP might have added it's own PHP version into the PATH.
Alternatively you could uninstall XAMPP, but make sure you back everything up, code/databases etc before you uninstall it.
WAMPServer does not need anything placed on the Windows PATH, and if you do it makes switching versions of PHP far more complicated and prone to mistakes.
Have a look at this answer for how to make the PHP CLI as flexible as WAMPServer when it comes to running PHP code on different versions of PHP from the command line.
It also looks like you have not istalled composer. Follow the instructions on how to instal composed from the error messages. Or have a look at the composer site for help

Recompile Nginx with additional modules

I installed Nginx via apt-get on Debian a while ago, and I've got a couple of sites live on it. Now I need to install some additional modules, and as I don't want to mess anything up I'd like to double check my process before I perform it. Hopefully this will also help others that are unsure about this part.
As I've understood it I have to do the following to minimize the downtime:
Download the source for Nginx
Add the additional modules with ./configure --additional-module
Compile Nginx with make
Stop the current server (service nginx stop)
Install Nginx with make install
Start the new server (service nginx start)
Or do I have to uninstall Nginx first, as it's not compiled from source at this point?
Having done something similar on Ubuntu before, the installation should overwrite the existing nginx binaries with the newly compiled ones, so long as yes, you ensure nginx isn't running on the system at the time.
I'd recommend trying to install nginx elsewhere on the system, so in case you can't get it to work quickly, you can restart your web server with the old nginx binaries and not have significant downtime.
nginx -V - helpful command which shows options for .\configure which was used to make nginx, which is actually working.
Helpful to get detail imagination about.
apt-get source nginx - to get source
install will automatically substitute actual installed version by new one
Keep also in mind that some nginx-modules can require additional libs on server. geoip module is classical example of it

Forbidden message when serving a sinatra local site using nginx passenger

I've followed the instructions for installing phusion passenger with nginx in ubuntu. I had some issues while installing since I use rvm and I had to install as root and the installer was failing to find rake so i temporarily chmoded /opt to be owned by my user and after installation I resetted ownership to root. I can see nginx welcome page but when I try to visit a sinatra app I get forbidden, the virtual host is pointed to the sinatra app public dir and the permissions for the whole app are 777.
Try Passenger 3. It automatically detects most permission problems and tells you how to fix them.
If this is for a production system, you really don't need the flexibility of RVM as you should be using a single stable version of Ruby and Rails for Phusion. Install the version you need, using Aptitude if that version is available, and be done with it.
Because this is the page that Google brought me to for my issue, which isn't a Passenger issue, but a Nginx reverse-proxy issue, you need to add the line
disable :protection
somewhere in your sinatra app. I have mine at the very end, outside any method (in global scope).
Well my mistake was not using rvmsudo to install nginx with passenger, instructions here: http://rvm.io/integration/passenger/.

Resources