I'd like to know a basic run down of command line inputs to install Apache, PHP and a SQL database on a VPS.
I'm not sure if sudo apt-get install php5 is enough to install php5 while getting the dependencies such as gcc.
I'm looking at Debian (Wheezy) as that is what a friend of mine suggested. I'm testing different websocket/wamp router solutions probably alongside if not dependent on node.js eg. socket.io or crossbar.io.
sudo apt-get install mysql-server
sudo apt-get install apache
sudo apt-get install php5-common libapache2-mod-php5 php5-cli
There are additional instructions for installing the mysql-server:
http://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/
Related
Linux newbie here and just installed Linux Mint version 20.
To install Apache, PHP, and MySQl on the system I chose the following instructions I found on the web...
1 - sudo apt install apache2
2 - sudo apt install mysql-server
3 - sudo apt install php7.4
4 - sudo apt install libapache2-mod-php7.4
5 - sudo apt install php7.4-mysql
6 - sudo service apache2 restart
I have already executed the first two lines of the above am ready to do the remaining steps and install php but first... to double check...
My Questions:
a - Are the steps listed above correct?
b - Line two in the above instructions installs mysql-server so why is mysql listed again in line five?
c - What about php7.4-mysqli ?
c1 - Should I remove mysql-server and install mysqli-server?
c2 - Should I install php7.4-mysqli instead of php7.4-mysql?
Thanks for any help. I don't want to mess up on this install.
-- Note: I'll be using Apache, PHP, and MySQL only on the local machine for developing and testing code before it goes live on the net.
-- Note: There are many different and confusing steps on the web so I chose the above steps.
-- Note: The instructions used php7.0 but I used php7.4 because...
sudo apt search php7
seems to tell me php version php7.4 is the latest in the repository
a - Are the steps listed above correct?
they are great
b - Line two in the above instructions installs mysql-server so why is mysql listed again in
line five?
in line 5 is not mysql the server, it is a mysql library for php
c - What about php7.4-mysqli ?
see answer above
mysql-server and install mysqli-server?
I am not sure but I think there is no such package called mysqli-server, at least in debian we do not have it. mysqli is not a server
you can check it out :
apt search <package>
php7.4-mysqli instead of php7.4-mysql?
mysqli is a extension of php but there is no such package.
c1 - Should I remove...
c2 - Should I install ...
you can not because there are no such packages ..
This worked for me on Linux Mint.
COMMANDS
sudo apt-get update
sudo apt-get install php7.2
sudo apt-get install php7.2-sqlite3
sudo apt-get install php7.2-curl
THESE MODULES WERE ALREADY INCLUDED WITH PHP:
sudo apt-get install libapache2-mod-php7.2
sudo apt-get install php7.2-common
sudo apt-get install php7.2-cli
sudo apt-get install php7.2-json
I tried installing php in ubuntu 16.04 using following command:
sudo apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7
but it says
Unable to locate package libapache2-mod-php7
Should I skip this or install by an alternative way?
The name of the package is libapache2-mod-php7.0
Try again by having that .0 at the end and it should work.
On Ubuntu 18.04, I had to add the repository below first. Once the repo was added I was able to install the php7.x items.
sudo add-apt-repository ppa:ondrej/php
Source: https://websiteforstudents.com/apache2-with-php-7-1-support-on-ubuntu-18-04-lts-beta-server/
If you are using Ubuntu 17.04/17.10 or above use php7.1 instead of 7.0 since it is no longer available.
sudo apt-get install php7.1
At the time of the post Ubuntu 16.04 was one of the newer versions and as such the packages changed to php7.0 but as time goes on it will be 7.1 to 7.2 etc... and I don't have the time to figure out what was the latest package and I'm not dependent on a specific version.
So if you want the latest version of packages to install without having to know the correct version number just drop the version number and the latest applicable to the distribution you are using will be installed.
In my case I was using Ubuntu 17.10 and the php version is different so I used the following command line to get the latest.
sudo apt-get install apache2 php-mysql libapache2-mod-php mysql-server
It installed php 7.1 and all of the correct dependencies.
So if you don't require a specific version but just want the latest that works with the distribution drop the version number and use the command line above.
It is likely the case that your local package index is not updated; try
sudo apt-get update
and then run the previous command again.
As an aside, there is now a program apt that is supposedly more user-friendly than apt-get, apt-cache etc. (see this question on Ask Ubuntu). So your commands could have been replaced by
sudo apt update
sudo apt install <the packages>
to get a slightly nicer user interface.
Probably this question would have been better suited to the Ask Ubuntu community.
Apache server can't start because libapache2-mod-php7.0 is not installed:
by default aptitude or apt install php7.0-common version 7.8.13 which is not adaptable and libapache2-mod-php need 7.0.8
remove php-common
download http://packages.ubuntu.com/xenial/php7.0-common deb package and install it if it compains about php7.0-json, readline,cli,opache
then seatch in upper textbox about those library and install them in this manner
json
opach
cli
readline
install libapache2-mod-php7.0
RESTART APACHE 2
service apache2 restart
it must working probably
Good Luck!
Try for Ubuntu 16.04:
sudo apt-get update;
sudo apt-get install php7.0-fpm php7.0-mysql <other packages>;
for Ubuntu 14.04:
sudo apt-get update;
sudo apt-get install php5-mysql php5-mysql <other packages>;
It should be:
sudo apt-get install libapache2-mod-php7.0
sudo apt-get install libapache2-mod-php7.1
worked for me (16.04Ubuntu).
If you getting error like php7.2 php7.2-curl libapache2-mod-php doesn't have installable candidate or not locate any package or dependencies is php7.2-common Or libcurl3 Do this . Remeber Change your package name as per your requirements
You have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.
apt-get install aptitude
Now you have to check if aptitude can download it or not if download it follow instructions
sudo aptitude install php7.2-curl
If you have gotten any error like this
E: Unable to locate package php7.2-curl
E: Couldn't find any package by glob 'php7.2-curl'
Any type on error i'm not talking about proper these errors
Try to add php package again
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
Now try this command
sudo aptitude install php7.2-curl
Aptitude will ask you you want to keep current version of all dependencies
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) php7.2-curl [Not Installed]
Accept this solution? [Y/n/q/?]
Type n then Enter
Aptitude will find all dependencies and ask you to install all package type
y
Again
y
Then
systemctl restart apache2
For centos of rhel
systemctl restart httpd
It will Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.
Upvote if you find your solution
Looks like we need to install the same version of libapache2-mod-php as the version of php present .I had php 7.4 installing libapache2-mod-php7.4 solved the problem.Thanks
just test upper versions of php
for example run:
sudo apt-get install php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.0 libapache2-mod-php7.4
I want to install PHP5-Curl in my Debian server. But when I run this command:
apt-get install PHP5-Curl
I got an error like:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package PHP5-Curl is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
E: Package 'PHP5-Curl' has no installation candidate
Use sudo apt-get install php5.6-curl
Try searching for the available version that suits for you with sudo apt-cache search curl | grep php and then sudo apt-get install php<x>-curl.
In my case it was php7.0-curl.
First search for your php version using command php -v and then download the respective version of php(version)-curl.
It looks like you have multiple, conflicting versions of PHP installed. First, let's clean up. Back up your configuration files first, as this will remove them.
dpkg --purge --force-all php5-curl
apt-get remove php5-*
apt-get purge php5-*
apt-get autoremove
Now, run dpkg -l | grep php5 again, and make sure that no php5-... packages are installed.
Then, let's start fresh:
apt-get install php5-cli php5-curl
If you need the Apache module:
apt-get install libapache2-mod-php5
Or if you need the FPM module:
apt-get install php5-fpm
Just today I signed up with Google Cloud Compute Engine. I did everything but then I stuck into an error while installing php5-mcrypt extension.
Error:
root#instance-2:~# sudo apt-get install php5-mcrypt
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php5-mcrypt : Depends: phpapi-20121212
Depends: php5-common (= 5.5.24+dfsg-1+deb.sury.org~vivid+1) but 5.6.4+dfsg-4ubuntu6 is to be installed
E: Unable to correct problems, you have held broken packages.
I searched everywhere and then I came here. Please help.
sudo service apache2 restar
apt-get install php5-common
Or, if you dont need to keep configurations:
apt-get purge php5-common
apt-get install php5-common
Do you get any output from apt-mark showhold?
If it does not solve your problem, you should try install it with aptitude:
sudo apt-get install aptitude
sudo aptitude install php5-mcrypt
Finally reatast the server
sudo service apache2 restart
Had exactly the same problem. The accepted solution did not work for me. Took me eternities to figure a way.
sudo add-apt-repository -r ppa:ondrej/php5
sudo add-apt-repository -r ppa:ondrej/php5-oldstable
sudo add-apt-repository -r ppa:ondrej/php5-5.6
sudo apt-get purge php5* apache2* mcrypt*
sudo apt-get update
sudo apt-get upgrade
(WARNING: You'll lose all settings for your PHP and Apache installation!)
reinstall:
sudo apt-get install php5 php5-mcrypt php5-curl apache2
and enable the extensions
sudo php5enmod mcrypt
sudo php5enmod curl
Magic.
This is horrible, horrible, horrible. Adding ppa:ondrej/php5-5.6 together with ppa:ondrej/php5 and ppa:ondrej/php5-oldstable will bring you nothing at all, as you need exactly one of these (as one contains PHP 5.4, second PHP 5.5 and third PHP 5.6). Purging php5* and apache2* is also not necessary, you might want to purge apache2.2-common if you encounter an error upgrading, but that's it. And then mcrypt and curl modules will get enabled automatically (unless you have disabled them in the past), so php5enmod mcrypt and php5enmod curl is extra (but not harmful).
The most common instructions to installing php5 and apache is the following:
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
However, you can just install apache and libapach2 mod and run php5. So why do you need the php5 package if the libapach mod package runs it just fine??
The php5 package is a metapackage whose job is solely to ensure that one of a number of different ways of running PHP for websites is installed. In actual use it's completely unnecessary; it's a convenience for people who just want PHP5. Type sudo apt-get install php5 on a system without PHP5 at all, and it'll prompt you with the options available.