In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to compile and install php5.6.31, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Php5.6.31 compilation and installation methods: 1, add epel source; 2, installation dependency; 3, download and extract php5.6.31;4, modify php-fpm.conf;5, start php-fpm.
Operating environment of this article: CentOS 7 system, php version: 5.6.31 nginx version: 1.7.3 mysql version: 5.6.62, DELL G3 computer
How to compile and install php5.6.31?
CentOS 7 compile and install PHP5.6.31:
There are already nginx and mysql on the server, so I decided to adopt the combination of PHP+Nginx+mysql. I looked up a lot of materials on the Internet. Because I didn't know about linux and PHP, I didn't know how PHP and nginx and mysql were related, and it took a lot of time to encounter various reasons (either php was installed incorrectly, or the package was not installed,). Later, after deployment, I found that all three were installed separately (er, can they be installed together), and only need to be configured after php installation. Under the configuration of nginx (associated with php), you can run directly. As for mysql, as long as it is turned on, the connection database in the php project is configured and can be connected directly. So this article mainly focuses on the installation of php.
With regard to the installation of nginx and mysql, some of the development libraries that need to be installed in linux before starting the installation are not repeated here, which are available in the reference link.
PHP installation configuration
Nginx itself cannot handle PHP, it is just a WEB server. When a request is received, if it is a php request, it is sent to the php interpreter for processing and the result is returned to the client.
Nginx generally sends the request to the fastcgi management process, and the fastcgi management process selects the processing result of the CGI child process and returns nginx.
What is PHP-FPM? PHP-FPM is a FASTCGI manager that belongs to PHP and is only used for PHP. The new version has integrated php-fpm. Php-fpm provides better php process management, can effectively control memory and processes, and can smoothly reload php configuration. In configure, you can enable php-fpm with-enable-fpm parameter. Other parameters can be found here. For what is fastcgi and what is the relationship with php-fpm, please see the link https://segmentfault.com/q/1010000000256516.
Pre-installation preparation
Add epel source rpm-Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm installation depends on yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-develyum-y install gcc gcc-c++ glibcyum-y install libmcrypt-devel mhash-devel libxslt-devel\ libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel\ zlib zlib -devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel\ ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel\ krb5 krb5-devel libidn libidn-devel openssl openssl-devel
Download php-5.6.31
1) extract the installation package to / usr/local/src
Cd / usr/local/srctar-zvxf php-5.6.31.tar.gz
2) enter the installation directory and install
Cd php-5.6.31./configure-- prefix=/usr/local/php-- enable-fpm-- with-mcrypt\-- enable-mbstring-- enable-pdo-- 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 -- with-mysql-- with-mysqli\-- with-gd-- with-jpeg-dir-- with-freetype-dir-- enable-calendarmake & & make installCentOS download php: wget http://php.net/get/php-5.6.30.tar.gz/from/this/mirror
This completes the installation of php-fpm, and the installation process will take some time.
About php configuration
1. Provide configuration files for php
Cp php.ini-production / usr/local/php/etc/php.ini
Note: php.ini-production is still in the / usr/local/src/php-5.6.31 directory.
2. Provide configuration files for php-fpm
Cd / usr/local/phpcp etc/php-fpm.conf.default etc/php-fpm.confvim etc/php-fpm.conf
Modify php-fpm.conf
User = wwwgroup = www
If the www user does not exist, add the www user first (the default runs the user nobody)
Groupadd wwwuseradd-g www www
If this step is not configured, the browser will report an error when opening the php file.
"The page you are looking for is temporarily unavailable Please try again later"
Modify
Pm.max_children = 150pm.start_servers = 8pm.min_spare_servers = 5pm.max_spare_servers = 10pid = / usr/local/php/var/run/php-fpm.pid
3. Start php-fpm
Execution
/ usr/local/php/sbin/php-fpm
Use the following command to verify (if there are several php-fpm processes in the output of this command, the startup is successful):
Ps aux | grep php-fpm
The result is as follows:
3. Nginx and php-fpm integration
Edit nginx profile
Vim / usr/local/nginx/conf/nginx.conf
The initial content is as follows:
# nginx runs the user name user nginx;# nginx to start the process, which is usually set to equal the number of cpu. Here, for the automatic worker_processes auto;# errorlog file location error_log / var/log/nginx/error.log;# pid file address, the pid of nginx is recorded, which is convenient for the process to manage pid / run/nginx.pid;# Load dynamic modules. See / usr/share/nginx/README.dynamic.# configuration include / usr/share/nginx/modules/*.conf;# working mode and maximum number of connections used to load other dynamic modules events {# maximum number of concurrent links per worker_processes # total concurrency: worker_processes*worker_connections worker_connections 1024 } # some configuration parameters related to providing http services are similar to mailhttp {# format log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"' # access_log records visited users, pages, browsers, ip and other access information access_log / var/log/nginx/access.log main; # this section will explain separately # set whether nginx uses the sendfile function to output file sendfile on; # packet maximum packet (using Nagle algorithm) tcp_nopush on # send packets immediately (disable Nagle algorithm) tcp_nodelay on; # Link timeout keepalive_timeout 65; # I don't know. Types_hash_max_size 2048; # introduces the file extension and file type mapping table include / etc/nginx/mime.types; # default file type default_type application/octet-stream; # Load modular configuration files from the / etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. Several virtual hosts are supported on the include / etc/nginx/conf.d/*.conf; # http service. # each virtual host has a corresponding server configuration item # the configuration item contains the configuration related to the virtual host. Server {# port listen 80 default_server; listen [:]: domain name accessed by 80 default_server; # server_name _; # default website root directory (www directory) root / usr/share/nginx/html; # Load configuration files for the default server block. Include / etc/nginx/default.d/*.conf; # default request location / {} # error page (404) error_page 404 / 404.html; location = / 40x.html {} # error page (50x) error_page 500502 503 504 / 50x.htl; location = / 50x.html {}}
All we need to change the configuration is the server section. Enter vim editing mode, or use FlashFXP to share the configuration file to the desktop to change.
Only three changes are needed.
Server {listen 80 default_server; listen [:]: 80 default_server; # changed here, you can also write your domain name, I use the IP address server_name 192.168.0.222; root / usr/share/nginx/html; # Load configuration files for the default server block. Include / etc/nginx/default.d/*.conf; location / {# here changes the name of the index file that defines the home page index index.php index.html index.htm;} error_page 404 / 404.html; location = / 40x.html {} error_page 500502 503504 / 50x.html Location = / 50x.html {} # all the newly added # PHP script requests are forwarded to FastCGI for processing. Use the default configuration of the FastCGI protocol. # Protocol for communication between Fastcgi server and program (PHP,Python). Location ~\ .php$ {# set the listening port fastcgi_pass 127.0.0.1 fastcgi_pass 9000; # set the path requested by the script file fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # introduce fastcgi's configuration file include fastcgi_params;}}
Restart the nginx server
Nginx-s reload
At this point, the joint configuration of nginx and php is complete, but we don't know how the actual configuration works, so we can write a small test script to verify it.
As mentioned earlier, / usr/share/nginx/html is the root of the Nginx site, where we can create a php test script.
# phpinfo.php is the file name I want to create
Vi / usr/share/nginx/html/phpinfo.php
After opening the editor, type in it
After saving and exiting, type http://192.168.0.222/phpinfo.php, in the browser. My ip here is 192.168.0.222. You can change it to your own. An interface similar to the following appears as shown in the figure:
Nginx and php have been configured.
4. the reason for the error in the installation process
When I followed the process to install, there was an error: mcrypt.h not found. Please reinstall libmcrypt
Because php-mcrypt libmcrypt libmcrypt-devel these packages are not installed, the errors are usually missing libraries or packages, you can install them.
The above is all the contents of the article "how to compile and install php5.6.31". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.