My info.php
is not resolving.
Can anyone see what I could have missed by installing Apache with this code?
PHP:
<?php phpinfo(); ?
Can anyone see what I could have missed by installing Apache with this code?
sh:
#!/bin/sh
# Ensure the script is run as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root!"
exit 1
fi
# Step 1: Update system and install required packages
echo "Updating the system and installing Apache, PHP-FPM, and required modules..."
pkg update && pkg upgrade -y
pkg install -y apache24 php84 php84-mysqli php84-mbstring php84-session php84-gd php84-curl php84-zip
# Step 2: Enable and start Apache and PHP-FPM services
echo "Enabling and starting Apache and PHP-FPM services..."
sysrc apache24_enable=yes
sysrc php_fpm_enable=yes
service apache24 start
service php-fpm start
# Step 3: Configure Apache to use PHP-FPM
echo "Configuring Apache to use PHP-FPM..."
echo "LoadModule proxy_fcgi_module libexec/apache24/mod_proxy_fcgi.so" >> /usr/local/etc/apache24/httpd.conf
echo "AddHandler php-fcgi .php" >> /usr/local/etc/apache24/httpd.conf
echo "Action php-fcgi /php-fcgi" >> /usr/local/etc/apache24/httpd.conf
echo "Alias /php-fcgi /usr/local/www/php-fpm" >> /usr/local/etc/apache24/httpd.conf
echo "FastCgiExternalServer /usr/local/www/php-fpm -socket /var/run/php-fpm.sock -pass-header Authorization" >> /usr/local/etc/apache24/httpd.conf
# Step 4: Configure PHP-FPM to use Unix socket
echo "Configuring PHP-FPM pool to use Unix socket..."
echo "listen = /var/run/php-fpm.sock" >> /usr/local/etc/php-fpm.d/www.conf
echo "listen.owner = www" >> /usr/local/etc/php-fpm.d/www.conf
echo "listen.group = www" >> /usr/local/etc/php-fpm.d/www.conf
echo "listen.mode = 0660" >> /usr/local/etc/php-fpm.d/www.conf
echo "user = www" >> /usr/local/etc/php-fpm.d/www.conf
echo "group = www" >> /usr/local/etc/php-fpm.d/www.conf
# Step 5: Restart services to apply changes
echo "Restarting Apache and PHP-FPM services..."
service apache24 restart
service php-fpm restart
# Step 6: Create a PHP info page to test the installation
echo "Creating a PHP info page..."
echo "<?php phpinfo(); ?>" > /usr/local/www/apache24/data/info.php
# Step 7: Enable PF firewall and allow HTTP/HTTPS traffic (if PF is enabled)
echo "Configuring firewall to allow HTTP/HTTPS traffic..."
sysrc pf_enable=yes
echo "pass in on egress proto tcp to any port {80, 443}" >> /etc/pf.conf
service pf start
# Final message
echo "PHP-FPM and Apache setup complete!"
echo "You can test your setup by visiting http://your-server-ip/info.php"
echo "Remember to delete the info.php page after testing: rm /usr/local/www/apache24/data/info.php"