Ubuntu Install PHP7 version Lamp Web site environment (APACHE/MYSQL/PHP7)

Source: Internet
Author: User
Tags mkdir mysql database
PHP7 has been out for some time, according to the practice of the user test than the previous version of the efficiency will be much higher, and the application to the site open speed will be significantly improved. But not all CMS program compatibility and support, the current mainstream WordPress, such as program compatibility is good, other programs to see the actual use, including program and component plug-in support. If we are not comfortable or incompatible, then temporarily use the version such as PHP5.6.




Today, old left to see an article on the installation of the Ubuntu environment Lamp, of course, including the compilation of the installation of PHP7 version, is a simple toss and experience the process of this environment, if the actual application to the project or according to our actual needs and skills to use.




First, Ubuntu installation PHP7 version lamp preparation




The code is as follows

Apt-get update && sudo apt-get upgrade




Upgrade and update the source in the Ubuntu 16.04 system we have installed.




Second, lamp environment installation and configuration Apache




1. Install Apache 2.4




The code is as follows

Apt-get Install Apache2-y




Install Apache directly from the system library.




2, modify the apache2.conf configuration




The code is as follows

/etc/apache2/apache2.conf







The code is as follows

KeepAlive off




Modify parameter keepalive to OFF




3, modify the mpm_prefork.conf configuration




The code is as follows

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







Set parameters:




The code is as follows

<ifmodule mpm_prefork_module>
Startservers 2
Minspareservers 6
Maxspareservers 12
Maxrequestworkers 39
Maxconnectionsperchild 3000
</IfModule>




4. Disable and start the module




The code is as follows

sudo a2dismod mpm_event
sudo a2enmod mpm_prefork




5, restart Apache




The code is as follows

sudo systemctl restart Apache2




Third, configure the virtual host environment




1, copy the default configuration file




The code is as follows

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




2, modify the configuration file




The code is as follows

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




Here we need to compile the current site configuration file.




The code is as follows

<Directory/var/www/html/laozuo.org/public_html>
Require all granted
</Directory>
<virtualhost *:80>
ServerName laozuo.org
Serveralias www.laozuo.org
ServerAdmin Webmaster@localhost
Documentroot/var/www/html/laozuo.org/public_html

Errorlog/var/www/html/laozuo.org/logs/error.log
Customlog/var/www/html/laozuo.org/logs/access.log combined

</VirtualHost>




3, create the need directory/file




The code is as follows

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




4, start the site




The code is as follows

sudo a2ensite laozuo.org.conf




5. Disable default root configuration




The code is as follows

sudo a2dissite 000-default.conf




6, restart Apache




The code is as follows

sudo systemctl reload apache2




Four, install MySQL database




1, the installation of the database




The code is as follows

sudo apt-get install Mysql-server




In the installation process needs to set the MySQL database root account password, input two times enter.







2. Configure Database Security




The code is as follows

Mysql_secure_installation




As prompted, we need to clean up the default tables and set the security of the database. There have been a lot of documents set up here before, you can refer to.




Lamp Compiling and installation PHP7




Here is the key, other we may have similar settings can refer to previous articles, PHP7 compilation has not yet articles, together to learn.




1. Installation PHP7 and response extension




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




The code is as follows

Max_input_time = 30
error_reporting = E_compile_error | E_recoverable_error | E_error | E_core_error
Error_log =/var/log/php/error.log




4. Create a log directory




The code is as follows

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




5, restart Apache




The code is as follows

sudo systemctl restart Apache2




Testing PHP7 Environment Support




So far we have created the lamp environment, we can drop a probe phpinfo in the directory of the domain name that is bound above, and then detect if the PHP7 version is supported.







Seven, Ubuntu installation PHP7 version lamp summary




1, if our technology is fair, and like toss, you can use this method to install the environment, if we actually need and urgent use, it is still a more mature one-button package or panel.




2, not all programs and components are currently compatible with PHP7, so we need to determine the support to use.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.