The officially official Devuan Forum!

You are not logged in.

#1 2020-08-18 18:33:01

walterbyrd
Member
Registered: 2018-07-30
Posts: 38  

How to install Nginix + Postgres + PHP

I think I have nginix and postgres installed. I just mentioned those because I don't want to install PHP for apache2 or mysql.

I guessing it won't hurt anything to install all that apache2 stuff, or sqlite3, but I would prefer to install just for nginx and postgres.

# apt install php7.0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.0 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap php-common
  php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.0 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap php-common
  php7.0 php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline
0 upgraded, 16 newly installed, 0 to remove and 2 not upgraded.
Need to get 5,592 kB of archives.
After this operation, 20.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.

Offline

#2 2020-08-19 03:06:17

jobbautista9
Member
From: Philippines
Registered: 2020-07-11
Posts: 19  
Website

Re: How to install Nginix + Postgres + PHP

Try using 'apt install php7.0 apache2- apache2-bin-'. apache is just a recommends in php7.0, so it should be possible to install php without apache.

Offline

#3 2020-08-19 08:22:37

szutt
Member
Registered: 2019-02-03
Posts: 27  

Re: How to install Nginix + Postgres + PHP

It's an hard dependency :

apt-cache show php7.0
Package: php7.0
Version: 7.0.33-0+deb9u8
Depends: libapache2-mod-php7.0 | php7.0-fpm | php7.0-cgi, php7.0-common

So, instead of installing a meta package you should install packages independently like https://hostup.org/blog/how-to-install- … debian-10/

Offline

#4 2020-08-19 14:08:47

walterbyrd
Member
Registered: 2018-07-30
Posts: 38  

Re: How to install Nginix + Postgres + PHP

No problem. I just installed PHP with the apache2 stuff. I don't think it will hurt anything. I think there is some other PHP package I'm supposed to install for Postgres, I am not sure if I have that.

Although I have Nginx installed, I do not have it configured. All the documentation that I am finding is for debian/ubuntu. Does anybody know of any documentation for Nginx that will work with Devuan?

I removed apache2. Trying to follow the instructions here:

https://www.raspberrypi.org/documentati … r/nginx.md

Still having trouble.

# /etc/init.d/nginx start
[FAIL] Starting nginx: nginx failed!
# cat /var/log/nginx/error.log
2020/08/19 05:02:31 [emerg] 1731#1731: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2020/08/19 05:02:31 [emerg] 1731#1731: listen() to [::]:80, backlog 511 failed (98: Address already in use)
2020/08/19 05:02:31 [emerg] 1731#1731: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2020/08/19 05:02:31 [emerg] 1731#1731: listen() to [::]:80, backlog 511 failed (98: Address already in use)
2020/08/19 05:02:31 [emerg] 1731#1731: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2020/08/19 05:02:31 [emerg] 1731#1731: listen() to [::]:80, backlog 511 failed (98: Address already in use)
2020/08/19 05:02:31 [emerg] 1731#1731: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2020/08/19 05:02:31 [emerg] 1731#1731: listen() to [::]:80, backlog 511 failed (98: Address already in use)
2020/08/19 05:02:31 [emerg] 1731#1731: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2020/08/19 05:02:31 [emerg] 1731#1731: listen() to [::]:80, backlog 511 failed (98: Address already in use)
2020/08/19 05:02:31 [emerg] 1731#1731: still could not bind()
2020/08/19 08:11:25 [emerg] 9843#9843: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2020/08/19 08:11:25 [emerg] 9843#9843: listen() to [::]:80, backlog 511 failed (98: Address already in use)
2020/08/19 08:11:25 [emerg] 9843#9843: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2020/08/19 08:11:25 [emerg] 9843#9843: listen() to [::]:80, backlog 511 failed (98: Address already in use)
2020/08/19 08:11:25 [emerg] 9843#9843: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2020/08/19 08:11:25 [emerg] 9843#9843: listen() to [::]:80, backlog 511 failed (98: Address already in use)
2020/08/19 08:11:25 [emerg] 9843#9843: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2020/08/19 08:11:25 [emerg] 9843#9843: listen() to [::]:80, backlog 511 failed (98: Address already in use)
2020/08/19 08:11:25 [emerg] 9843#9843: listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
2020/08/19 08:11:25 [emerg] 9843#9843: listen() to [::]:80, backlog 511 failed (98: Address already in use)
2020/08/19 08:11:25 [emerg] 9843#9843: still could not bind()
2020/08/19 08:26:43 [emerg] 10160#10160: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default:22
2020/08/19 08:41:44 [emerg] 10569#10569: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default:22
2020/08/19 08:42:51 [emerg] 10826#10826: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default:22
2020/08/19 08:49:33 [emerg] 10954#10954: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default:22

Last edited by walterbyrd (2020-08-19 15:28:23)

Offline

#5 2020-08-20 09:57:33

juic3
Member
Registered: 2018-11-27
Posts: 8  

Re: How to install Nginix + Postgres + PHP

Are you sure your config id ok? You can test it with -t flag (or -T).
Is apache running and serving in port 80?

edit:
Just tested installing ngix and that was all I had to do. worked out of box.
So I think you have apache running. Try stopping apache service.

edit2:
The raspberry intructions seemed legit. Digitalocean ( https://www.digitalocean.com/community/ … ntu-16-04) has similar instructions with some security settings. Just replace systemd commands with sysv equivalents.

Last edited by juic3 (2020-08-20 10:16:57)

Offline

#6 2020-08-20 20:02:15

walterbyrd
Member
Registered: 2018-07-30
Posts: 38  

Re: How to install Nginix + Postgres + PHP

Apache2 was running, but I shut it down and removed it.

I re-installing nginx.

I may have nginx somewhat working.

in the /etc/nginx/sites-enabled/default file, there was a # in front of a } where there should not be:

       
 location ~ \.php$ {
                include snippets/fastcgi-php.conf;

# With php-fpm (or other unix sockets):
 fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# With php-cgi (or other tcp sockets):
#   fastcgi_pass 127.0.0.1:9000;
# }

I am not sure how that got there, but I removed that.

Also in the /etc/nginx/sites-enabled/default file, when trying to fix it (I guess), I uncommented these two listen statements. So I re-commented them.

server {
	# listen 80 default_server;
	# listen [::]:80 default_server;

It will load an html file, but not a php file. When I try to load 'index.php' which just contains <?php echo phpinfo(); ?>  I get a '500 Internal Server Error'. Not sure why.

I added index.php to /etc/nginx/sites-enabled/default

# Add index.php to the list if you are using PHP
index index.php index.html index.htm;

I also installed php-fpm

# apt install php-fpm

# whereis php-fpm
php-fpm: /usr/sbin/php-fpm7.0

# ls /var/run/php/
php7.0-fpm.pid	php7.0-fpm.sock

# cat /var/log/nginx/error.log
2020/08/20 15:09:14 [error] 21338#21338: *1 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 127.0.0.1, server: myserver, request: "GET / HTTP/1.1", host: "127.0.0.1"

Last edited by walterbyrd (2020-08-20 21:14:12)

Offline

#7 2020-08-21 06:10:35

juic3
Member
Registered: 2018-11-27
Posts: 8  

Re: How to install Nginix + Postgres + PHP

I think those listen lines should be enabled.
Here is my sites-available/default

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
	listen 80 default_server;
	listen [::]:80 default_server;

	# SSL configuration
	#
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	#
	# Note: You should disable gzip for SSL traffic.
	# See: https://bugs.debian.org/773332
	#
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See: https://bugs.debian.org/765782
	#
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	#
	# include snippets/snakeoil.conf;

	root /var/www/html;

	# Add index.php to the list if you are using PHP
	index index.php index.html index.htm index.nginx-debian.html;

	server_name _;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
	}

	# pass PHP scripts to FastCGI server
	#
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
	#
	#	# With php-fpm (or other unix sockets):
		fastcgi_pass unix:/run/php/php7.3-fpm.sock;
	#	# With php-cgi (or other tcp sockets):
	#	fastcgi_pass 127.0.0.1:9000;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	location ~ /\.ht {
		deny all;
	}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#	listen 80;
#	listen [::]:80;
#
#	server_name example.com;
#
#	root /var/www/example.com;
#	index index.html;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}

Last edited by juic3 (2020-08-21 06:11:08)

Offline

#8 2020-08-21 15:56:39

walterbyrd
Member
Registered: 2018-07-30
Posts: 38  

Re: How to install Nginix + Postgres + PHP

I backed up my /etc/nginx/sites-enabled/default file, and used the one you posted. I started nginx, and got this:

# cat /var/log/nginx/error.log
2020/08/21 09:52:07 [emerg] 7888#7888: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default:22

When I comment those lines out, nginx will run, and it will load an html file, but it will not load a php file.

Last edited by walterbyrd (2020-08-21 16:04:08)

Offline

#9 2020-08-21 16:38:29

walterbyrd
Member
Registered: 2018-07-30
Posts: 38  

Re: How to install Nginix + Postgres + PHP

I blew the entire thing away. Removed the entire /etc/nginx directory.

I thought an apt install would install that directory, but it doesn't. May be just as well. Beyond frustrated.

Offline

#10 2020-08-21 18:23:44

walterbyrd
Member
Registered: 2018-07-30
Posts: 38  

Re: How to install Nginix + Postgres + PHP

I could not let it go.

I reinstalled files, and got it working.

I am not even sure of what all I did.

In the snippets/fastcgi_params file, I replaced 'include fastcgi-php.conf' with 'include fastcgi_params'

Then, I had to add a /etc/nginx/fastcgi_params file, which I copied from a sample file on the nginx site.

Still not working for Moodle. Nginx will not load javascript.

I tried nginx, a long time ago, and found fairly easy to use. Now I am finding it extremely difficult.

Last edited by walterbyrd (2020-08-24 17:41:22)

Offline

#11 2020-08-25 14:56:09

walterbyrd
Member
Registered: 2018-07-30
Posts: 38  

Re: How to install Nginix + Postgres + PHP

Giving up in frustration. Will try lighttpd.

Offline

#12 2020-08-25 23:37:41

aitor
Member
From: basque country
Registered: 2016-12-03
Posts: 35  
Website

Re: How to install Nginix + Postgres + PHP

I've got it working time ago:

http://dev1galaxy.org/viewtopic.php?id=2405

This howto is in spanish because i wrote it for the developers of EterTics (Argentina). It may be a bit obsolete, but you can find there the configuration I used.
On the other hand, you don't need to remove apache2. Stopping it is enough.

By the way, SteveT has a tutorial about nginx in his website:

http://www.troubleshooters.com/linux/nginx/

Last edited by aitor (2020-08-25 23:52:21)

Offline

#13 2020-08-26 07:40:31

xinomilo
Member
Registered: 2017-07-02
Posts: 126  

Re: How to install Nginix + Postgres + PHP

walterbyrd wrote:

I think I have nginix and postgres installed. I just mentioned those because I don't want to install PHP for apache2 or mysql.

just install php-fpm and remove apache* packages. you don't need the complete php7.0 metapackage with nginx.  just necessary php modules and php-cli if you need to also run php commands by hand.

Last edited by xinomilo (2020-08-26 07:41:13)

Offline

Board footer