In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to install the php7 extension in Ubuntu14. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Ubuntu14 install php7 method: 1, install mysql;2, download php source code "php-7.2.27.tar.gz" and extract to the root directory; 3, install and compile the dependencies needed; 4, create an installation directory; 5, configure to open php-fpm support.
This article operating environment: ubuntu14.04 system, PHP7.2 version, Dell G3 computer.
Resolve the problem:
Unable to install php7.0
There is an exception in uploading files above 1m in the above version of php
Php does not specify Loaded Configuration File
Php uses phpmailer ssl to send mail exception
System:
Server: Linux version 4.4.0-53-generic (buildd@lgw01-18) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)) # 74~14.04.1-Ubuntu SMP Fri Dec 2 03:43:31 UTC 2016
Install php7.0 and above:
Through the query, almost all the tutorials are as follows
First add the php official source
$sudo add-apt-repository ppa:ondrej/php
Then update the source
$sudo apt-get update
Then install
$sudo apt-get install php7.0 php7.0-cli php7.0-fpm php7.0-gd php7.0-json php7.0-mysql php7.0-readline
However, in practice, sources above 7.0 cannot be found.
The error is as follows
Root@iZuf624uxtr8143n2396iaZ:~# sudo apt-get install php7.0 php7.0-cli php7.0-fpm php7.0-gd php7.0-json php7.0-mysql php7.0-readlineReading package lists... DoneBuilding dependency tree Reading state information... DoneE: Unable to locate package php7.0E: Couldn't find any package by regex 'php7.0'E: Unable to locate package php7.0-cliE: Couldn't find any package by regex' php7.0-cli'E: Unable to locate package php7.0-fpmE: Couldn't find any package by regex 'php7.0-fpm'E: Unable to locate package php7.0-gdE: Couldn't find any package by regex' php7.0-gd'E: Unable to locate package php7.0-jsonE: Couldn't find Any package by regex 'php7.0-json'E: Unable to locate package php7.0-mysqlE: Couldn't find any package by regex' php7.0-mysql'E: Unable to locate package php7.0-readlineE: Couldn't find any package by regex 'php7.0-readline'
I have no choice but to download the installation package by myself, install it manually, step on all kinds of pits in the middle, and record it again, which is convenient for the needed partners to take it away directly to save time.
Using the installation package, install php7.0 and above:
Compilation environment: php-7.2.27
Static resource server: nginx/1.4.6 (Ubuntu)
Database: mysql
1. Mysql installation
1. Install mysql, install directory / usr/bin/mysql installation steps
II. PHP installation
1. Download the php source code php-7.2.27.tar.gz and decompress it to the / root directory
$tar-zxvf / root/php-7.2.27.tar.gz-C / root/
2. Install the dependencies required for compilation
① install libxml2-dev
$sudo apt-get update $sudo apt-get install libxml2-dev
② install gcc
$sudo apt-get install build-essential
③ installs dependent libraries
$sudo apt-get install openssl$ sudo apt-get install libssl-dev$ sudo apt-get install make$ sudo apt-get install curl$ sudo apt-get install libcurl4-gnutls-dev$ sudo apt-get install libfreetype6-dev$ sudo apt-get install libjpeg-dev$ sudo apt-get install libpng-dev$ sudo apt-get install libmcrypt-dev$ sudo apt-get install libreadline6 libreadline6-dev$ sudo apt-get install libbz2-dev
④ installs apache2-dev, otherwise-with-apxs2=/usr/bin/apxs cannot be specified to generate libphp7.so
Sudo apt-get install apache2-dev
3. Create an installation directory
$mkdir / usr/local/php
4. Switch to the decompressed and compiled directory
$cd / root/php-7.2.27/
Configure to enable php-fpm support, and enable multithreading support-enable-maintainer-zts, otherwise you cannot use the Event MPM feature of Apache2.
① execution:
/ configure-- prefix=/usr/local/php-- exec-prefix=/usr/local/php-- with-config-file-path=/usr/local/php/etc-- with-pdo-mysql=/usr/bin/mysql-- enable-bcmath-- enable-mbstring-- with-gettext-- enable-fpm-- enable-shmop-- enable-soap-- enable-opcache-- with-curl-- disable-debug-- disable-rpath-- enable-inline-optimization-- with-bz2-- with- Zlib-enable-sockets-enable-sysvsem-enable-sysvshm-enable-pcntl-enable-mbregex-with-mhash-enable-zip-with-pcre-regex-enable-mysqlnd-with-mysqli=mysqlnd-with-pdo-mysql=mysqlnd-with-gd with-jpeg-dir with-freetype-dir enable-calendar
② execution:
$make & & make testYou can then email it to qa-reports@lists.php.net later.Do you want to send this report now? [Yns]: $make & & sudo make install
Wait for a long time.
③ executes the following: check the version number
/ usr/local/php/bin/php-v
5. Configure php-fpm
Go to etc in the installation directory and copy php-fpm.conf.default to php-fpm.conf
Go to etc/php-fpm.d in the installation directory and copy www.conf.default to www.conf. The port number of fpm can be modified in this file.
$cd / usr/local/php/etc$ cp php-fpm.conf.default php-fpm.conf$ cd / usr/local/php/etc/php-fpm.d$ cp www.conf.default www.conf$ vim / usr/local/php/etc/php-fpm.d/www.conf
Modify:
User = www-data
Group = www-data
Eg: if the www-data user does not exist, then add the www-data user first
Groupadd www-datauseradd-g www-data www-data
Start php-fpm startup mode 1
:
$sudo / usr/local/php/sbin/php-fpm
6. Add php-fpm to init.d
$/ usr/local/php/etc$ Vim / usr/local/php/etc
Edit the php-fpm.conf file, remove the semicolon before; pid = run/php-fpm.pid and close the fpm service, and execute:
$killall php-fpm
Go to the directory (the directory is the extracted directory of the php source package) and find the init.d.php-fpm file
$cd / root/php-7.2.27/sapi/fpm/
Copy the file to the / etc/init.d directory and rename it php-fpm
$cp init.d.php-fpm / etc/init.d/php-fpm
Add permissions:
Chmod + x / etc/init.d/php-fpm chkconfig-- add php-fpmchkconfig php-fpm on
Start php-fpm startup mode 2:
$sudo / etc/init.d/php-fpm start
Start php-fpm startup mode 3:
$service php-fpm start
Fpm uses 9000 port number by default
Lsof-iVug 9000 View details
III. Server configuration
1. Apache2 configuration scheme
Installation configuration ignore
2. Nginx configuration scheme
Install nginx sudo apt-get install nginx nginx to point to fpm process Manager
Eg:
Server {listen 80; server_name ip address or domain name; root / home/cms/phpProject/; location / {index index.html index.htm index.php If (!-e $request_filename) {rewrite ^ (. *) $/ index.php?s=/$1 last; break }} location ~\ .php (. *) ${fastcgi_pass 127.0.0.1 9000; fastcgi_index index.php; fastcgi_split_path_info ^ ((? U). +\ .php) (/?. +) $ Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params;} access_log / var/log/nginx/cms.access.log Error_log / var/log/nginx/cms.error.log info;}
Put the project under / home/cms/phpProject/
Set permissions for runtime
$chmod + x / home/cms/phpProject/runtime/
Start nginx
$/ etc/nginx nginx
Access address ip/ domain name
4. Other points of attention
1. The permissions of template files under runtime cause the system to be inaccessible.
Log is in / home/cms/prod/runtime/ directory
Note the port number of the database connection
Note the read and write status of the cache file
Chmod-R 777 / home/cms/phpProject/runtime/
2. The lunix server php7.0+ environment cannot point to the php.ini file problem and cannot adjust the uploaded file size.
Viewing the basic information of PHP through phpinfo (), we found that Loaded Configuration File was not specified.
View strace / usr/local/php/sbin/php-fpm-I 2 > 1.log by assigning php-fpm to the log
Copy cp / usr/local/php/lib/php.ini / usr/local/php/etc/php.ini to the specified directory
The maximum limit for upload is still 1m. For the time being, the solution to the problem of raising the maximum limit for upload needs to be supplemented.
3. Fix the upload size limit in 2020-04-27
Through troubleshooting, it is found that the nginx file upload configuration is too small:
By looking at the error file in var/logs/nginx, there will be errors as follows
Recv () failed (104: Connection reset by peer) while waiting for
Request
Fixed: adjusting parameters in nginx.conf
Client_header_buffer_size 64k; large_client_header_buffers 4 64k; client_body_buffer_size 20m; fastcgi_buffer_size 128k; fastcgi_buffers 4 128k; fastcgi_busy_buffers_size 256k; fastcgi_connect_timeout 600; fastcgi_send_timeout 600; fastcgi_read_timeout 600; proxy_buffer_size 64k; proxy_buffers 4 128k Proxy_busy_buffers_size 256k; proxy_connect_timeout 600s; proxy_send_timeout 1200; proxy_read_timeout 1200
After restarting nginx, the picture is uploaded and found that the error is still reported. Open the php log and find that the error is reported.
[error] [2] mkdir (): Permission denide [/ home/biotool/cms/prod/thinkphp/library/think/File.php:160]
Remember, all such problems are caused by lack of permissions.
Execute:
Chmod-R 777 / home/cms/prod/public/ `
More than 1m images have been uploaded successfully
4. Failed to send mail to the server. Openssl did not specify a problem.
4.1. my source code is in / root/php-7.2.27, the installation location is in / usr/local/php, and the php.ini is under / usr/local/php/lib. If there is no php.ini, you need to rename the configuration file php.ini-development or php.ini-production in the source code to php.ini and put it under lib.
4.2. Enter the openssl extension directory:
Cd / root/php-7.2.27/ext/openssl
3. Run phpize
/ usr/local/php7/bin/phpize
After execution, an error is found that the config.m4 cannot be found, and config0.m4 is config.m4. Rename directly
Mv config0.m4 config.m4
If it is reported after implementation
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
Execute: apt install autoconf
3.4. Perform installation
. / configure-with-openssl-with-php-config=/usr/local/php7/bin/php-config make&&make install
3.5. it may not be found in the process. Execute the following command and then re-execute the installation corresponding to libssl.
Yum install openssl yum install openssl-devel
3.6. After performing the installation, I will be prompted to generate a .so file in a directory. The location I generated is at
/ usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/
3.7.Open etc/ php.ini
Vim / usr/local/php/etc/php.ini
Add the following two sentences
Extension_dir = "/ usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/"
Extension=openssl.so
3.8. Restart php.
Killall php-fpm/usr/local/php/sbin/php-fpm
4. Switch domain names
Log in to the central node and change the proxy forwarding address corresponding to the xxx.net domain name to: http://ip/
4.2 Log in to the application server and add ip to server_name
Note: the use of intranet addresses here can increase the access speed between services (bandwidth 20m)
After the configuration is successful, visit xxx.net, and the website is switched successfully, and the access speed is faster than that of IP direct access.
This is the end of this article on "how to install php7 extensions for Ubuntu14". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.