Ubuntu installs PHP7 version LAMP website environment (Apache/MySQL/PHP7)

888u

Last update at :2024-06-20,Edit by888u

PHP7 has been out for a while. According to netizens’ practical tests, it is much more efficient than the previous version, and the opening speed will be significantly improved when applied to websites. However, not all CMS programs are compatible and supported. The current mainstream WordPress and other programs are relatively compatible. Other programs depend on actual use, including program and component plug-in support. If we are not yet convinced or it is not compatible, then use a version such as PHP5.6 for the time being.

Today Snail saw an article about installing LAMP in the Ubuntu environment. Of course, it includes compiling and installing the PHP7 version. It is a simple process of tossing and experiencing this environment. If it is actually applied to the project, it must be based on our actual situation. needs and skills to use.

Snail has previously shared LAMP’s environmental articles:

1. One-click installation of LNMP/LAMP/LNMPA website environment on CentOS/Debian/Ubuntu system

2. Complete configuration of CentOS6 installation LAMP (Apache/MySQL/PHP) environment building tutorial

First, Ubuntu installation PHP7 version LAMP preparation

apt-get update && sudo apt-get upgrade

Upgrade and update sources in the Ubuntu 16.04 system we installed.

Second, install and configure Apache in LAMP environment

1. Install Apache 2.4

apt-get install apache2 -y

Install Apache directly from the system repositories.

2. Modify apache2.conf configuration

/etc/apache2/apache2.conf

KeepAlive Off

Modify the parameter KeepAlive to Off

3. Modify mpm_prefork.conf configuration

/etc/apache2/mods-available/mpm_prefork.conf

Set parameters:

StartServers           2MinSpareServers           6MaxSpareServers                                                                                                                                                       12MaxRequestWorkers                                                               2MinSpareServers

4. Disable and enable modules

sudo a2dismod mpm_eventsudo a2enmod mpm_prefork

5. Restart Apache

sudo systemctl restart apache2

Third, configure the virtual host environment

1. Copy the default configuration file

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/laozuo.org.conf

2. Modify the configuration file

/etc/apache2/sites-available/laozuo.org.conf

Here we need to compile the current site configuration file.

Require all grantedServerName laozuo.orgServerAlias ​​www.laozuo.orgServerAdmin [email protected]DocumentRoot /var/www/html/laozuo.org/public_html

ErrorLog /var/www/html/laozuo.org/logs/error.logCustomLog /var/www/html/laozuo.org/logs/access.log combined

3. Create the required directories/files

sudo mkdir -p /var/www/html/laozuo.org/{public_html,logs}

4. Start the site

sudo a2ensite laozuo.org.conf

5. Disable default root directory configuration

sudo a2dissite 000-default.conf

6. Restart Apache

sudo systemctl reload apache2

Fourth, install the MYSQL database

1. Install database

sudo apt-get install mysql-server

During the installation process, you need to set the MYSQL database ROOT account password, enter it twice and press Enter.

2. Configure database security

mysql_secure_installation

According to the prompts, we need to clean up the default tables and set up database security. There are many documents that have been set up here before, you can refer to them.

Fifth, compile and install PHP7 with LAMP

Here is the key. For other similar settings, we may refer to previous articles. There are no articles on PHP7 compilation yet, so let’s learn together.

1. Install PHP7 and responsive extensions

sudo apt-get install php7.0 php-pear libapache2-mod-php7.0 php7.0-mysql

2. Installation component support

sudo apt-get install php7.0-curl php7.0-json php7.0-cgi

3. Configuration file/etc/php/7.0/apache2/php.ini

max_input_time = 30error_reporting = E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERRORerror_log = /var/log/php/error.log

4. Create a log directory

sudo mkdir /var/log/phpsudo chown www-data /var/log/php

5. Restart Apache

sudo systemctl restart apache2

Sixth, test PHP7 environment support

So far we have created the LAMP environment. We can drop a probe PHPINFO in the domain name site directory bound above, and then detect whether the php7 version is supported.

Seventh, summary of installing PHP7 version LAMP on Ubuntu

1. If our skills are good and we like to mess around, we can use this method to install the environment. If we actually need it and use it urgently, we should use a more mature one-click package or panel.

2. Not all programs and components are currently compatible with PHP7, so we need to confirm support before using them.

Recommended site search: dynamic ip dialer, icp website registration, virtual host, registered domain name, server space rental, Singapore server, domain name service provider, domain name registration, overseas virtual host, domain name query network,

Ubuntu installs PHP7 version LAMP website environment (Apache/MySQL/PHP7)

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码