Install Php 7.1 Debian 8
If someone else (like me) still needs to install php 7.1 or newer on Debian 7.X (wheezy), please be informed that I followed this instruction (just scroll down to Configuration for Debian 7.x “Wheezy” section) and it worked for me like a charm! This tutorial shows how to build the new PHP 7.1 as a PHP-FPM and a FastCGI version on a Debian Jessie server. This PHP 7.1 build includes many compiled in extensions and Zend OPcache and Memcached as loadable modules. 1 Preliminary Note. I will install PHP 7.1 which has been released as final version a few days ago.
Introduction
The “LAMP” stack of software, consisting of the Linux operating system, Apache web server, MySQL database, and PHP scripting language, is a great foundation for web or application development. Installed together, this software stack enables your server to host dynamic websites and web applications.
In this tutorial, we’ll install a LAMP stack on a Debian 8 server.
Prerequisites
Before we get started, you will need to set up a Debian 8 server with a non-root
sudo
-enabled user account. You can do this by following our initial server setup guide for Debian 8.You should also create a basic firewall, which you can do by following the Ubuntu and Debian UFW setup tutorial.
Step 1 — Updating the System
Before you install any software, it’s important to make sure your system is up to date. To update your package lists, type:
This tells your operating system to compare the software packages currently installed on your server with any new versions that might have been updated recently in the Debian online repositories, where base software packages are stored.
Note: If you are running a development or mission-critical high-use server, be cautious about installing updates without carefully going through each package to determine if it is actually needed for your system. In our example here, all packages have been installed for the purposes of this tutorial only.
Once you’ve determined that these updated software components are relevant for your needs, go ahead and update your server. You can do this by typing the following command:
This may take a while, depending on the current version of the operating system you have installed, software packages, and network conditions. On a fresh server, it will take a couple of seconds.
Now your server is fully patched, updated, and ready for LAMP installation. Since your server is already running the Linux operating system Debian, you can move on to installing the Apache web server to manage your networking connections.
Step 2 — Installing Apache and Updating the Firewall
The next step in our LAMP installation is to install the Apache web server. This is a well-documented and widely used web server that will allow your server to display web content. To install Apache, type the following:
This installs the basic Apache web server package as well as the documentation that goes along with it. This may take a few seconds as Apache and its required packages are installed. Once done, apt-get
will exit, and the installation will be complete.
Next, assuming that you have followed the UFW setup tutorial by installing and enabling a firewall, make sure that your firewall allows HTTP and HTTPS traffic.
When installed on Debian 8, UFW comes loaded with app profiles which you can use to tweak your firewall settings. View the full list of application profiles by running:
The WWW
profiles are used to manage ports used by web servers:
If you inspect the WWW Full
profile, it shows that it enables traffic to ports 80
and 443
:
Allow incoming HTTP and HTTPS traffic for this profile:
Now that we’ve allowed web traffic through our firewall, let’s test to make sure the web server will respond to requests with a sample web page. First up, you will need the IP address of your server. You can view your IP address in your current SSH session by running the following command:
On your screen, you will see a few lines of output, including your server’s IP address. You’ll want the four-part number shown after inet addr:
:
Note the IP address listed and type it into your favorite web browser like this:
http://111.111.111.111
Once done, you will see the default Apache 2 web page, similar to this:
Now that you have successfully installed Apache on your server, you can upload your website content to the /var/www/html
directory. If you want to set up multiple websites, please see this article on setting up Apache virtual hosts.
For additional instructions and Apache-related security information, please take a look at Debian’s Apache information.
With your web server up and running, you are ready to create a place for your website to store data, which you can do with MySQL.
Install Latest Php Debian
Step 3 — Installing and Securing MySQL
The next component of the LAMP server is MySQL. This relational database software is an essential backend component for other software packages such as WordPress, Joomla, Drupal, and many others.
To install MySQL and PHP support for it, type the following:
This will install MySQL and other required packages. Note that the installation routine will ask you to enter a new password for the root MySQL user:
This is a separate account used specifically for administrative functions in MySQL. The username is root and the password is whatever you set here. Be sure to set a good password with various combinations of letters and numbers.
After this, the MySQL installation is finished.
To keep your new database server safe, there is an additional script you need to run. Type the following to get started:
At this point, the script will ask you a few questions. When prompted, enter the password for the root MySQL account. The system will then ask you:
Since we already set the root MySQL password at our installation, you can say no at this point. The script will then ask:
Answer yes to remove the anonymous users option for safety.
Next, the script will ask you to either allow or disallow remote logins for the root account. For safety, disallow remote logins for root unless your environment requires this.
Finally, the script will ask you to remove the test database and then reload the privilege tables. Answer yes to both of these. This will remove the test database and process the security changes.
If everything is correct, once done, the script will return with:
Let’s double-check that our new MySQL server is running. Type this command:
Enter the root password you set up for MySQL when you installed the software package. Remember, this is not the root account used for your server administration. Once in, type the following to get the server status, version information, and more:
This is a good way to ensure that you’ve installed MySQL and are ready for further configuration. When you are finished examining the output, exit the application by typing this:
After confirming that MySQL is active, the next step is to install PHP so that you can run scripts and process code on your server.
Step 4 — Installing PHP
For our last component, we will set up and install PHP, which stands for PHP: Hypertext Preprocessor. This popular server-side scripting language is used far and wide for dynamic web content, making it essential to many web and application developers.
To install PHP, type the following:
After you agree to the installation, PHP will be installed on your server. You will see many packages being installed beyond just PHP. Don’t worry; your system is integrating the PHP software with your existing Apache2 installation and other programs.
Restart Apache on your server to make sure all of the changes with the PHP installation take effect. To do this, type the following:
Now, let’s take a moment to test the PHP software that you just installed. Move into your public web directory:
Once there, use your favorite console text editor to create a file named info.php
. Here’s one method of doing this:
This command will use the command line editor nano
to open a new blank file with this name. Inside this file, type the following to populate a web page with output information for your PHP’s configuration:
Hit CTRL-X
to exit the file, then Y
to save the changes that you made, then ENTER
to confirm the file name. To access the configuration info, open your web browser and type the following URL, replacing the highlighted section with your server’s IP address:
http://111.111.111.111/info.php
If you’ve done everything correctly, you will see the default PHP information page, like the one shown below:
Debian Php 7.2
When you are done looking at this test PHP page, remove it for security. To do that, run this command:
The system will then ask if you wish to remove the test file that you’ve created. Answer yes to remove the file. Once this is done, you will have completed the basic PHP installation.
Conclusion
You have now installed the basic LAMP stack on your server, giving you a platform to create a wide range of websites and web applications. From here, there are many ways that you could customize and extend the capabilities of your server. To learn more about securing your Linux server, check out An Introduction to Securing Your Linux VPS. If you would like to set up your server to host multiple websites, follow the Apache virtual hosts tutorial.
This tutorial will enable PHP 5.6, 7.0, 7.1, 7.2, 7.3 and 7.4 to specific/desired domains.Tutorial is for Debian and Ubuntu (but probably can give you a good direction for CentOS).
PHP will run through PHP-FPM, which is much more faster solution than other existent PHP-switcher that uses only old phpfcgid solution (because with PHP-FPM you can use opcache).
Communication to PHP-FPM will goes through Unix-sockets, which is also the fastest communication between daemons.
Second tutorial goes a step forward - it will allow you to make direct communication from nginx to PHP-FPM, avoiding Apache for desired domains (Apache is installed by default in default Vesta installation).
So, yes, you can easily make nginx <-> PHP-FPM stack even if you have Apache installed.
And yet better news - you can use it only on desired domains - so all other domains will stay untouched.
First pre-required step for Debian 10:First pre-required step for Debian 9:First pre-required step for Debian 8:First pre-required step for Ubuntu:
Install Php 7.1 Debian Jessie
Under Adding this PPA to your system click Technical details about this PPA, select your Ubuntu version, and two lines that you get from field box below add to /etc/apt/sources.list.d/php.list
Second pre-required step for both Debian and Ubuntu:
Code: Select all
For PHP 5.6
For PHP 7.0
Code: Select all
Install Php 7.1 Debian 8gb
For PHP 7.1For PHP 7.2
Code: Select all
Install Php 7 Debian 8
For PHP 7.3
For PHP 7.4
Code: Select all
Now simply go to Vesta, edit WEB for desired domain and choose: