I setup a new LAMP stack on Ubuntu 16.04 via Virtualmin. I needed php5, so I added the ondrej repo (sudo add-apt-repository ppa:ondrej/php) and installed the packages I needed. Then I enabled php5 on apache (sudo a2enmod php5.6).
Usually when I do this I can change the php verion in my apache vhost configuration files.
Now here is the twist, apache will only run php5.6 now. If I disable it, uninstall it, etc, it just downloads the php files. I have combed over ever configration file and I cannot find where php7.0 is treated any differently that php5.6.
Also, it seems to be running under www-data instead of the virtual server owner regardless of the configurations.
I have trued to compare every configuration file (/etc/apache2) to a working setup on a different server, but I cannot find a significant difference.
Any intuition on this is appreciated.
Related
I've recentlly got a problem with my local virtual hosts after installing php 5.6 next to php 7.0. I'm using Ubuntu 16.04 with Apache, MySQL etc. configured for Laravel projects and everything was working perfectly fine with php 7.0 until I had to work with another project. This non-laravel project required php 5.6 to work, so I installed it next to php 7.0 together with some modules for phpmyadmin (as it didn't work after I switched server to php 5.6). So what I did after installing php 5.6 was:
sudo a2dismod php7.0
sudo a2enmod php5.6
sudo service apache2 restart
Added a new host for my php 5.6 project in /etc/hosts as 127.0.0.1 www.myhost.local.
Added a new config in sites-available, enabled it, restarted the server.
Installed few required by phpmyadmin modules to configure database for the new project.
Worked with my php 5.6 project.
When I wanted to switch back to my Laravel projects I made:
sudo a2dismod php5.6
sudo a2enmod php7.0
sudo service apache2 restart
And none of the laravel hosts worked. The error I get from Google Chrome is:
This site can’t be reached
www.myhost.local’s server IP address could not be found.
ERR_NAME_NOT_RESOLVED
And I DIDN'T CHANGE configs of Laravel projects! I didn't edit neither sites-availavle configs, nor etc/hotst except for adding the line with my php 5.6 project. I've tryed:
Checking /etc/apache2/mods-enabled where are php7.0.load and php7.0.conf enabled.
Checking service apache2 status and got Apache active (running).
Checking http://localhost/ and got the default apache page.
Checking http://localhost/php.info which showed me that server is running with php 7.0
Deleting php 5.6 host from etc/hosts and disabling same config in sites-available.
Adding < VirtualHost 127.0.0.1:80 > instead of < VirtualHost *:80 > in the beginning of my Laravel host config. Which made some inner pages work if loaded without www and home page still didn't and www was added to url every time I tryed to load it. However some inner pages began later to generate www too and nothing helped :(
Checking apache logs and got warnings only.
Some other minor things I can't remember now...
Can anyone help please? Or is it easier to reinstall php completely?
Thanks everyone! That was browser cache (although I've checked other browsers I never opened my projects in). So it finally worked in incognito window and after I cleared Chrome's and FF's cache.
I am using https://github.com/wilmoore/php-version to switch between php versions on my local machine, installed within ~/php/versions. Currently setting up separate VMs with different versions of php installed is not an option.
When I switch php version through the command line using the linked tool, I see it listed as php 7. This also works when using php -v. I have restarted terminal and the machine and it still says php 7.
I have updated composer.json to require php 7.0.2 and greater. Yet when I use phpinfo() in my laravel application, it always states the default PHP Version 5.5.9-1ubuntu4.14.
Where is laravel pointing to the php distribution in my Ubuntu 14.04.3 machine and where can I change this path?
EDIT: I am using Apache. I can see in the phpinfo() output that it is reading the ini file from /etc/php5/apache2/php.ini. I have looked in this file but cannot see where to point to the php distribution.
first make sure that php7.*.conf and php7.*.load files are exist in /etc/apache2/mods-available directory.
then use sudo a2enmod php7.* to enable the mod
use sudo a2dismod php5.* to disable the mod
after running the two commands restart your apache2 server
using sudo systemctl restart apache2
The Apache loads the php5_module library in /etc/apache2/mods-available/php5.load.
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
If you know the loactions of your alternative libraries you can change them in this file.
After editing you need to restart your apache. sudo service apache2 restart or sudo systemctl restart apache2.service
Had the same issue on ubuntu16.
ls -l /etc/apache2/mods-available/php7* ,
showed 2 versions -
/etc/apache2/mods-available/php7.0.conf
/etc/apache2/mods-available/php7.2.conf
Deleted the /etc/apache2/mods-available/php7.0.conf, restarted apache2, and phpinfo() via apache2 showed php7.2
I'm having some trouble getting PHP to run under Apache after updating my software. On my Amazon AWS running AMI, I followed this guide here, with the specific commands:
sudo yum remove httpd* php*
sudo yum install httpd24 php55
After updating the apache config files to use the newer directives, I can get to the server, but the PHP is just echoing out on the screen.
I checked to make sure that there is a php.ini file being read, that the module is loaded in Apache, the server is running, and I can execute php from the command line.
Anyone have any ideas on what I should check next?
I have a problem with apache2, wordpress and php.
I configured virtual hosts and copied the existing wordpress (installed in single host).
The web server is working fine and loads the index.php, but doesn't execute it.
Check mod-enabled folder in your apache. You must have two files their php5.load and php5.conf. If not present, its means php support is not their.To enable php support use command a2enmod php5
It is because your apache2 can't execute php.
In my case, I install libapache2-mod-php by:
aptitude install libapache2-mod-php7.0
Then restart apache by:
/etc/init.d/apache2 restart
May it help you.
I am trying to enable XSL on Ubuntu 12.04 but its failing. I did this locally on my Ubuntu 13.04 and it was successful. Basically the following worked on my local computer.
apt-get install php5_xsl
edit php.ini file and add extension=php5_xsl.so
restart apache
I repeated the same procedures on my production server running Ubuntu 12.04 and PHP version 5.5.12 but the extension is not getting loaded from the phpinfo. I have also changed the extension=php5_xsl.so to extension=xsl.so because this is what in the extension directory.
I read that I might need to recompile PHP but I am not sure of this steps.
Try this:
sudo apt-get install php5-xsl
sudo php5enmod xsl
sudo service apache2 restart
Why:
http://www.lornajane.net/posts/2012/managing-php-5-4-extensions-on-ubuntu
What's happened here is that all debian-flavoured unixes have adopted
this standard for their PHP 5.4 packages, so if you're using debian,
ubuntu, or any of their relatives with PHP 5.4, you'll see a directory
structure like this. When you add a module to PHP, you'll add a file
to the mods-available directory enabling the module and adding any
config specific to it. If you want to enable the module, just do:
php5enmod http
This simply creates a symlink from the usual conf.d directory to point
to where the real files are in mods-available, prefixed with a number
that indicates the priority of the module. By default, the priority is
20.
Using this approach means we can toggle things on and off without
commenting out big chunks of config files and leaving them lying
around - if this seems familiar then that's no surprise; debian-like
linuxes manage their apache configuration in just the same way. Any
packages that you install using aptitude will use these exact same
commands to set up the configuration and then symlink it correctly. To
unlink, use the delightfully predictably-named php5dismod :)