I'm new with Vagrant, and I'm having trouble to up my Vagrant server with ZendFramework 2. Below goes my configuration file...
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = '2'
#script = <<SCRIPT
DOCUMENT_ROOT_ZEND="/var/www/zf/public"
apt-get update
apt-get install -y apache2 git curl php5-cli php5 php5-intl libapache2-mod-php5
echo "
<VirtualHost *:80>
ServerName skeleton-zf.local
DocumentRoot $DOCUMENT_ROOT_ZEND
<Directory $DOCUMENT_ROOT_ZEND>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
" > /etc/apache2/sites-available/skeleton-zf.conf
a2enmod rewrite
a2dissite 000-default
a2ensite skeleton-zf
service apache2 restart
cd /var/www/zf
curl -Ss https://getcomposer.org/installer | php
php composer.phar install --no-progress
echo "** [ZEND] Visit http://localhost:8085 in your browser for to view the application **"
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'bento/ubuntu-14.04'
config.vm.network "forwarded_port", guest: 80, host: 8085
config.vm.hostname = "skeleton-zf.local"
config.vm.synced_folder '.', '/var/www/zf'
config.vm.provision 'shell', inline: #script
config.vm.network "private_network", ip: "0.0.0.0"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
end
When I try to acess the 8085 port I got a blank page with HTTP code 500, and in every rout I try to access, existing or not, I got the same error. Below goes my php version at Vagrant:
vagrant#skeleton-zf:~$ php -v
PHP 5.5.9-1ubuntu4.13 (cli) (built: Sep 29 2015 15:24:49)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
vagrant#skeleton-zf:~$
And when I try to run any comand in apache, I got this:
vagrant#skeleton-zf:~$ apache2 -V
[Fri Oct 02 16:19:06.465441 2015] [core:warn] [pid 5758] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Fri Oct 02 16:19:06.466385 2015] [core:warn] [pid 5758] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Fri Oct 02 16:19:06.466830 2015] [core:warn] [pid 5758] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Fri Oct 02 16:19:06.469081 2015] [core:warn] [pid 5758] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Fri Oct 02 16:19:06.469143 2015] [core:warn] [pid 5758] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Fri Oct 02 16:19:06.474489 2015] [core:warn] [pid 5758] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
My problem was a hidden 500 error message, because I didnt installed the php5-mysql package. The configuration is ok.
Related
I was about to test if Windows 10 Pro with WSL running Ubuntu LAMP stack is already a good options for web development.
I tested 2 guides:
https://www.freecodecamp.org/news/setup-a-php-development-environment-on-windows-subsystem-for-linux-wsl-9193ff28ae83/
https://nickjanetakis.com/blog/using-wsl-and-mobaxterm-to-create-a-linux-dev-environment-on-windows
First I tested with Nginx and PHP7.2 but I had the issue that PHP was not executed but displayed. Then I gave Apache2 a try with PHP7.0 and I have the same issue.
sudo a2enmod php7.0
Considering dependency mpm_prefork for php7.0:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php7.0:
Module php7.0 already enabled
sudo update-alternatives --set php /usr/bin/php7.0
There was never a PHP5 installed and there is nothing in apache about PHP5.
/etc/apache2/mods-available contains
-rw-r--r-- 1 root root 867 Sep 2 15:31 php7.0.conf
-rw-r--r-- 1 root root 102 Sep 2 15:31 php7.0.load
/etc/apache2/mods-enabled contains the symlinks
lrwxrwxrwx 1 root root 29 Oct 22 12:03 php7.0.conf -> ../mods-available/php7.0.conf
lrwxrwxrwx 1 root root 29 Oct 22 12:03 php7.0.load -> ../mods-available/php7.0.load
php7.0.load contains
LoadModule php7_module /usr/lib/apache2/modules/libphp7.0.so
The module exists at this location.
Apache error.log looks also ok
[Tue Oct 22 14:06:32.548315 2019] [mpm_event:notice] [pid 1779:tid 140213335231424] AH00491: caught SIGTERM, shutting down
[Tue Oct 22 14:06:34.732188 2019] [mpm_prefork:notice] [pid 24776] AH00163: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[Tue Oct 22 14:06:34.732298 2019] [core:notice] [pid 24776] AH00094: Command line: '/usr/sbin/apache2'
vHost
<VirtualHost *:80>
ServerAdmin admin#localhost.com
ServerName www.test.me
DocumentRoot /var/www/dev/test
<Directory /var/www/dev/test/>
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error_www.test.me.log
LogLevel warn
</VirtualHost>
/var/www/dev is a symlink to the mounted windows user dev folder
lrwxrwxrwx 1 root root 19 Oct 22 11:30 dev -> /c/Users/name/dev/
Since Apache and Nginx have have the same issue it might be about the path to or the user/permissions but I couldn't find anything so far.
Would be nice if someone has an idea whats wrong.
I have what used to be a typical Apache 2.4 installation on an Ubuntu 16.04 LTS.
There is a /etc/apache2/sites-available/ directory where all configuration files are stored and from where one can enable sites.
Here is one of them titled localhost.conf
<VirtualHost *:80>
ServerName 127.0.0.1
ServerAlias sites.dev
DocumentRoot /var/www/sites/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/sites>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
I have enabled this site. When I navigate to sites.dev, I see the contents of that directory being listed since it does not have an index.php file. So far, so good.
I then add a info.php file to the same directory which looks like this
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Now, when I navigate to sites.dev/info.php, I see a blank page.
Furthermore, when I look at the /var/log/apache2/error.log, I see entries like these
[Tue Feb 05 22:21:44.281005 2019] [mpm_prefork:notice] [pid 2149] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operat$
[Tue Feb 05 22:21:44.281059 2019] [core:notice] [pid 2149] AH00094: Command line: '/usr/sbin/apache2'
[Tue Feb 05 22:24:55.006296 2019] [mpm_prefork:notice] [pid 2149] AH00169: caught SIGTERM, shutting down
[Tue Feb 05 22:24:56.064108 2019] [mpm_prefork:notice] [pid 2320] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operat$
[Tue Feb 05 22:24:56.064149 2019] [core:notice] [pid 2320] AH00094: Command line: '/usr/sbin/apache2'
Could someone tell me what is happening? How can I fix this localhost and the local development environment?
I solved it using the following sequence of steps:
Install PHP 7 (even though it was already installed)
apt-get install php
apt-get install php-pear php7.0-dev php7.0-zip php7.0-curl php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-xml libapache2-mod-php7.0
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
sudo service apache2 reload
I have multiple php versions installed on my Ubuntu 18.04 - php7.1 php5.6
When I'm using php7.1 apache restarts successfully.
But when I switch to php5.6 using this command:
sudo a2dismod php7.1 ; sudo a2enmod php5.6 ; sudo service apache2 restart
Apache gives me this error:
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
systemctl status apache2.service result:
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Sat 2018-10-27 13:19:32 +06; 7s ago
Process: 6458 ExecStart=/usr/sbin/apachectl start (code=exited, status=139)
Oct 27 13:19:32 protectedfor apachectl[6458]: AH00112: Warning:
DocumentRoot [/home/protectedfor/scj] does not exist
Oct 27 13:19:32 protectedfor apachectl[6458]: AH00112: Warning:
DocumentRoot [/var/www/worldclass/worldclass.kg] does not exist
Oct 27 13:19:32 protectedfor apachectl[6458]: [Sat Oct 27 13:19:32.683512 2018] [alias:warn] [pid 6469] AH00671: The Alias directive in /etc/apache2/apache2.conf at line
Oct 27 13:19:32 protectedfor apachectl[6458]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerNa
Oct 27 13:19:32 protectedfor apachectl[6458]: Segmentation fault (core dumped)
Oct 27 13:19:32 protectedfor apachectl[6458]: Action 'start' failed.
Oct 27 13:19:32 protectedfor apachectl[6458]: The Apache error log may have more information.
Oct 27 13:19:32 protectedfor systemd[1]: apache2.service: Control process exited, code=exited status=139
Oct 27 13:19:32 protectedfor systemd[1]: apache2.service: Failed with result 'exit-code'.
Oct 27 13:19:32 protectedfor systemd[1]: Failed to start The Apache HTTP Server.
Apache log:
[Sat Oct 27 12:43:02.172511 2018] [mpm_prefork:notice] [pid 6518] AH00169: caught SIGTERM, shutting down
[Sat Oct 27 12:43:10.498278 2018] [so:warn] [pid 5126] AH01574: module php7_module is already loaded, skipping
[Sat Oct 27 12:43:10.544626 2018] [mpm_prefork:notice] [pid 5137] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Sat Oct 27 12:43:10.544656 2018] [core:notice] [pid 5137] AH00094: Command line: '/usr/sbin/apache2'
[Sat Oct 27 12:43:28.243406 2018] [mpm_prefork:notice] [pid 5137] AH00169: caught SIGTERM, shutting down
Any advices really appreciated. Thanks!
Its not just disable the module. You have to set some defaults in order to make that work
Please try this
set from 7.x to 5.x
sudo a2dismod php7.1
sudo a2enmod php5.6
sudo update-alternatives --set php /usr/bin/php5.6
sudo update-alternatives --config php
sudo update-alternatives --set phar /usr/bin/phar5.6
sudo systemctl restart apache2
set from 5.x to 7.x
sudo a2enmod php7.1
sudo a2dismod php5.6
sudo update-alternatives --set php /usr/bin/php7.1
sudo systemctl restart apache2
Similar question have been asked many times and I have gone through most of them and still I am not able to solve the problem.
I am running Apache2 and PHP 7 FPM in different docker containers and they are not able to connect to each other. The connection fails with following errors.
[Tue Sep 19 00:05:51.743322 2017] [proxy:debug] [pid 336:tid 140441754191616] proxy_util.c(2422): [client 172.18.0.1:36332] AH00947: connected /var/www/html/info.php to 127.0.0.1:9000
[Tue Sep 19 00:05:51.743387 2017] [proxy:error] [pid 336:tid 140441754191616] (111)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:9000 (*) failed
[Tue Sep 19 00:05:51.743405 2017] [proxy_fcgi:error] [pid 336:tid 140441754191616] [client 172.18.0.1:36332] AH01079: failed to make connection to backend: 127.0.0.1
[Tue Sep 19 00:05:51.743410 2017] [proxy:debug] [pid 336:tid 140441754191616] proxy_util.c(2175): AH00943: FCGI: has released connection for (*)
[Tue Sep 19 00:05:56.809604 2017] [authz_core:debug] [pid 336:tid 140441672480512] mod_authz_core.c(809): [client 172.18.0.1:36442] AH01626: authorization result of Require all granted: granted
[Tue Sep 19 00:05:56.809646 2017] [authz_core:debug] [pid 336:tid 140441672480512] mod_authz_core.c(809): [client 172.18.0.1:36442] AH01626: authorization result of <RequireAny>: granted
[Tue Sep 19 00:05:56.809676 2017] [proxy:debug] [pid 336:tid 140441672480512] mod_proxy.c(1160): [client 172.18.0.1:36442] AH01143: Running scheme fcgi handler (attempt 0)
[Tue Sep 19 00:05:56.809687 2017] [proxy_fcgi:debug] [pid 336:tid 140441672480512] mod_proxy_fcgi.c(879): [client 172.18.0.1:36442] AH01076: url: fcgi://127.0.0.1:9000/var/www/html/info.php proxyname: (null) proxyport: 0
[Tue Sep 19 00:05:56.809694 2017] [proxy_fcgi:debug] [pid 336:tid 140441672480512] mod_proxy_fcgi.c(886): [client 172.18.0.1:36442] AH01078: serving URL fcgi://127.0.0.1:9000/var/www/html/info.php
[Tue Sep 19 00:05:56.809703 2017] [proxy:debug] [pid 336:tid 140441672480512] proxy_util.c(2160): AH00942: FCGI: has acquired connection for (*)
[Tue Sep 19 00:05:56.809712 2017] [proxy:debug] [pid 336:tid 140441672480512] proxy_util.c(2213): [client 172.18.0.1:36442] AH00944: connecting fcgi://127.0.0.1:9000/var/www/html/info.php to 127.0.0.1:9000
[Tue Sep 19 00:05:56.809840 2017] [proxy:debug] [pid 336:tid 140441672480512] proxy_util.c(2422): [client 172.18.0.1:36442] AH00947: connected /var/www/html/info.php to 127.0.0.1:9000
[Tue Sep 19 00:05:56.809927 2017] [proxy:error] [pid 336:tid 140441672480512] (111)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:9000 (*) failed
[Tue Sep 19 00:05:56.809946 2017] [proxy_fcgi:error] [pid 336:tid 140441672480512] [client 172.18.0.1:36442] AH01079: failed to make connection to backend: 127.0.0.1
[Tue Sep 19 00:05:56.809953 2017] [proxy:debug] [pid 336:tid 140441672480512] proxy_util.c(2175): AH00943: FCGI: has released connection for (*)
Below is my docker-compose file
version: '2'
services:
php:
build: ./etc/php/
volumes:
- ./etc/php/config/php.ini:/etc/php/7.1/fpm/php.ini
- ./etc/php/config/www.conf:/etc/php/7.1/fpm/pool.d/www.conf
- ./etc/php/config/php-fpm.conf:/etc/php/7.1/fpm/php-fpm.conf
- ./etc/php/logs/php-fpm.log:/var/log/php-fpm.log
- ./etc/php/logs/fpm-php.www.log:/var/log/fpm-php.www.log
- ./source/:/var/www/html/
expose:
- 9000
ports:
- "9000:9000"
links:
- mysql
apache2:
build: ./etc/apache/
volumes:
- ./source/:/var/www/html/
- ./etc/apache/config/sites-enabled/:/etc/apache2/sites-enabled/
- ./etc/apache/config/conf-enabled/:/etc/apache2/conf-enabled/
- ./etc/apache/logs/error.log:/var/log/apache2/error.log
- ./etc/apache/logs/access.log:/var/log/apache2/access.log
- ./etc/apache/logs/sm-error.log:/var/log/apache2/sm-error.log
- ./etc/apache/logs/sm-access.log:/var/log/apache2/sm-access.log
expose:
- 80
- 443
ports:
- "8080:80"
- "443:443"
links:
- php
mysql:
image: mysql:latest
volumes:
- ./etc/mysql/data/:/var/lib/mysql/
- ./etc/mysql/config/:/etc/mysql/conf.d/
ports:
- "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: sp
MYSQL_USER: spadmin
MYSQL_PASSWORD: root
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- "8081:80"
links:
- mysql
environment:
PMA_HOST: mysql
Below is my docker file for apache2.
#Get the base image
FROM ubuntu:16.04
#Install Apache
RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y \
apache2 \
apache2-utils
# Enable modules
RUN a2enmod rewrite
RUN a2enmod proxy
RUN a2enmod proxy_fcgi
# Add user to www-data
RUN groupadd 1000
RUN usermod -a -G 1000 www-data
RUN usermod -a -G staff www-data
RUN service apache2 restart
# Run config
ENTRYPOINT [ "/usr/sbin/apache2ctl" ]
CMD [ "-D", "FOREGROUND" ]
Below is my virtual host file for apache2.
<VirtualHost *:80>
ServerName localhost
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
DocumentRoot /var/www/html
<Directory /var/www/html>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/sm-error.log
CustomLog /var/log/apache2/sm-access.log combined
</VirtualHost>
Below is my PHP-FPM docker file.
FROM ubuntu:16.04
# Install PHP
RUN apt-get clean && \
apt-get -y update && \
apt-get install -y locales \
curl \
software-properties-common \
git && \
locale-gen en_AU.UTF-8
RUN LC_ALL=en_AU.UTF-8 add-apt-repository ppa:ondrej/php
RUN apt-get update
RUN apt-get install -y --force-yes php7.1-bcmath \
php7.1-bz2 \
php7.1-cli \
php7.1-common \
php7.1-curl \
php7.1-cgi \
php7.1-dev \
php7.1-fpm \
php7.1-gd \
php-ldap \
php7.1-gmp \
php7.1-intl \
php7.1-json \
php7.1-mbstring \
php7.1-mcrypt \
php7.1-mysql \
php-sqlite3 \
php7.1-opcache \
php7.1-phpdbg \
hp7.1-pspell \
php7.1-readline \
php7.1-recode \
php7.1-soap \
php7.1-tidy \
php7.1-xml \
php7.1-xmlrpc \
php7.1-xsl \
php7.1-zip \
php-xdebug
# Install Composer
RUN curl https://getcomposer.org/installer > composer-setup.php && php composer-setup.php && mv composer.phar /usr/local/bin/composer && rm composer-setup.php
# Clean files
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Run PHP-FPM
CMD ["php-fpm7.1"]
Below is the output of docker ps command.
a85830192ad4 spendingmanager_apache2 "/usr/sbin/apache2..." 15 minutes ago Up 15 minutes 0.0.0.0:443->443/tcp, 0.0.0.0:8080->80/tcp spendingmanager_apache2_1
4574c977d0d4 phpmyadmin/phpmyadmin "/run.sh phpmyadmin" 15 minutes ago Up 15 minutes 0.0.0.0:8081->80/tcp spendingmanager_phpmyadmin_1
82735fa580e8 spendingmanager_php "php-fpm7.1" 15 minutes ago Up 15 minutes 0.0.0.0:9000->9000/tcp spendingmanager_php_1
32422e934247 mysql:latest "docker-entrypoint..." 15 minutes ago Up 15 minutes 0.0.0.0:3307->3306/tcp spendingmanager_mysql_1
Note: PHP-FPM is listening for connections on port 9000 and its working properly. When I try to access it from my host OS (for instance http://localhost/ instead of http://localhost:8080 I am able to connect and get the desired output).
I have also tried setting up permission on the www/html and try making www-data the owner.
Can someone please help me get this working?
Thanks in advance for your help.
In your examples localhost or 127.0.0.1 is local to the containers (not the host). So, when Apache tries to connect to FPM at 127.0.0.1:9000, it is actually trying to connect to itself (the Apache container only).
What you want to do is have Apache connect to the FPM container. The easiest way to do this with Docker networking is to use the service name from Docker Compose. In your case, the service name is php and will be available at the DNS name php from the Apache container.
Thus, your Apache configuration should be:
SetHandler "proxy:fcgi://php:9000"
I've got the same error and just figured out the reason by struggling almost a whole day.
In my case, the problem was having IP v6 enabled in my VPS while there was no real IP6 address assigned into my interface.
I just disabled the IPV6 and things started work normally again. (Disable IPv6/IPv4 if it is not in use )
step 1 - edit the sysctl.conf file using the following command in your shell
vi /etc/sysctl.conf
step 2 - add the following two lines to disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
step 3 - save and close the file (Esc -> :wq)
step 4 - for immediate effect run the following code in shell
sysctl -p
I am having a strange error (system is Ubuntu 16.04):
[Mon Sep 04 13:07:17.219992 2017] [mpm_prefork:notice] [pid 27798] AH00169: caught SIGTERM, shutting down
[Mon Sep 04 13:07:17.302181 2017] [so:warn] [pid 27874] AH01574: module php7_module is already loaded, skipping
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_curl.dll' - /usr/lib/php/20151012/php_curl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[Mon Sep 04 13:07:17.322006 2017] [mpm_prefork:notice] [pid 27875] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Mon Sep 04 13:07:17.322026 2017] [core:notice] [pid 27875] AH00094: Command line: '/usr/sbin/apache2'
PHP version is 7.1.19. I installed curl (apt-get install php7.1-curl), in the php.ini I added extension=curl.co (and commented out extension=php_curl.dll), restarted the apache service, and the error is still there (I tried commenting out extension=curl.co but the error is still there).
This is an error I am getting on the page (Laravel setup):
Call to undefined function App\curl_init()
Everything is installed and config files are as required and I don't know what could be wrong here.
The /etc/php/7.1/mods-available/curl.ini file content should be:
extension=curl.so
Please notice the extension is .so, and not .co.
Then you can enable the module in your PHP by running:
$ sudo phpenmod curl
Finally, you may need to restart your Apache:
$ sudo systemctl restart apache2