Home | News | Download | Packages | Forum | Wiki | Github

[solved] Running php scripts with Apache

(Jean-Pierre Rivière) #1

I want to use Apache and have it serve my php pages. My databases are stored on another server so I don’t want to use phpMyAdmin and I did not installed it.

I am under the latest release of void linux

what I have installed:

# xbps-query -s php
[*] php-7.1.5_1        An HTML-embedded scripting language
[*] php-apache-7.1.5_1 An HTML-embedded scripting language - Apache SAPI
[*] php-embed-7.1.5_1  An HTML-embedded scripting language - Embed SAPI
# xbps-query -s apache
[*] apache-2.4.25_4    The Number One HTTP Server On The Internet
[*] apr-1.5.2_4        Apache Portable Runtime Library
[*] apr-util-1.5.4_9   The Apache Portable Runtime Utility Library
[*] php-apache-7.1.5_1 An HTML-embedded scripting language - Apache SAPI

The end of my otherwise standard /etc/apache/httpd.conf is:

# tail -4 /etc/apache/httpd.conf 

LoadModule php7_module /usr/libexec/httpd/modules/libphp7.so
Include /etc/apache/extra/php7_module.conf

I checked that /usr/libexec/httpd/modules/libphp7.so and /etc/apache/extra/php7_module.conf were there.

I also made the required linking for the apache service:

# ln -s //etc/sv/sshd /var/service/

Apache is launched by default. But I know and can restart it with

# sv restart apache

OK. Now for the problem: The apache server is now broken. Any http query to my server are resulting in a ‘no connexion to server’ error message in my browser.

If I comment the LoadModule for php in my httpd.conf, and restart apache, then apache is fine and connexion are served. But of course my php files are not treated by php then!

As for the logs, I cannot see anything useful. I am with the LaodModule directive activated here;

# rm /var/log/httpd/*_log 
# sv restart apache
ok: run: apache: (pid 8019) 0s
# ls -l /var/log/httpd
total 0

Now trying to connect to the server. Got the no connexion error.

# ls -l /var/log/httpd
total 0

Quite normal. dmesg do not seem to help much. Here is the tail of it:

[ 2239.077108] WARNING: CPU: 0 PID: 7460 at ./arch/x86/include/asm/fpu/internal.h:528 fpu__restore+0x103/0x140
[ 2239.077111] Modules linked in: cfg80211 joydev iTCO_wdt iTCO_vendor_support uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 psmouse videobuf2_core input_leds pcspkr videodev lpc_ich i2c_i801 rng_core media snd_hda_codec_realtek atl2 snd_hda_codec_generic shpchp snd_hda_intel thermal snd_hda_codec snd_hda_core snd_hwdep fjes snd_pcm battery acpi_cpufreq eeepc_laptop ac sparse_keymap evdev tpm_tis mac_hid intel_agp tpm_tis_core hwmon tpm snd_seq snd_seq_device snd_timer snd soundcore vhost_net vhost macvtap macvlan uhid hid hci_vhci bluetooth vfio_iommu_type1 rfkill vfio dm_mod uinput userio ppp_generic slhc tun loop crc32c_generic btrfs xor raid6_pq cuse fuse ext4 crc16 jbd2 mbcache uas usb_storage sd_mod ata_generic pata_acpi i915 ata_piix intel_gtt ahci i2c_algo_bit libahci drm_kms_helper
[ 2239.077261]  libata uhci_hcd syscopyarea sysfillrect sysimgblt fb_sys_fops ehci_pci ehci_hcd drm serio_raw scsi_mod usbcore agpgart video button
[ 2239.077296] CPU: 0 PID: 7460 Comm: run Tainted: G        W       4.10.17_1 #1
[ 2239.077299] Hardware name: ASUSTeK Computer INC. 701/701, BIOS 1001    05/04/2008
[ 2239.077303] Call Trace:
[ 2239.077318]  ? dump_stack+0x55/0x7c
[ 2239.077327]  ? __warn+0x105/0x120
[ 2239.077332]  ? fpu__restore+0x103/0x140
[ 2239.077337]  ? fpu__restore+0x103/0x140
[ 2239.077344]  ? warn_slowpath_null+0x1f/0x30
[ 2239.077349]  ? fpu__restore+0x103/0x140
[ 2239.077355]  ? __fpu__restore_sig+0x1c3/0x4b0
[ 2239.077365]  ? restore_sigcontext.isra.1+0xd5/0xf0
[ 2239.077371]  ? sys_sigreturn+0xa8/0xc0
[ 2239.077377]  ? do_int80_syscall_32+0x54/0xc0
[ 2239.077388]  ? entry_INT80_32+0x31/0x31
[ 2239.077393] ---[ end trace 7380adee4a718a41 ]---
[ 2317.114439] perf: interrupt took too long (3966 > 3953), lowering kernel.perf_event_max_sample_rate to 50000

I am using kernel 4.10.17_1 in 32bit on a 32bit x86 CPU.

[solved] Cannot find package for python, rubby, phpmyadmin, ectc
(Stefan Mühlinghaus) #2

Restart the service with its whole path, e.g.

sv restart /var/service/apache

not just

sv restart apache

You will probably get a notice that the service could not be started (timeout) and now there should be something in /var/log/httpd/error_log. For errors from runit-services you can also check the runsvdir process:

ps ax | grep runsvdir

If there is a message stating that the PHP module is not compiled to run in a threadeded Apache MPM go back to your /etc/apache/httpd.conf, deactivate the mpm_event_module and activate the mpm_prefork_module so that it looks like this:

#LoadModule mpm_event_module /usr/libexec/httpd/mod_mpm_event.so
LoadModule mpm_prefork_module /usr/libexec/httpd/mod_mpm_prefork.so

Then restart apache again.

(Jean-Pierre Rivière) #3

Thanks a lot once again @jazzman!

Id did not get any error when restarting the service, and still no log.

I then chex for runsvdir as you indicated and it told me that the error was indeed what you had in mind!

# ps ax | grep runsvdir

528 ? Ss 1:12 runsvdir -P /run/runit/runsvdir/current log: 24221:tid 3074897024] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP. AH00013: Pre-configuration failed [Thu Jun 15 10:54:34.681632 2017] [php7:crit] [pid 24225:tid 3075085440] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP. AH00013: Pre-configuration failed
24230 pts/0 S+ 0:00 grep runsvdir

So I did modify httpd.conf as you suggested and this solved the problem.


Bonjour Jean-Pierre,
This error with Apache is well known, see Apache_HTTP_Server on the Arch wiki.
That’s exactly what @jazzman suggested you.

(Jean-Pierre Rivière) #5

Thank you @cr6.

I’m afraid I have not yet caught that Arch Linux is a trove for solutions on Void Linux. May your counsel serve me well… later!