Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos manually installs PHP

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Download the source code of PHP, I have a look at the installation of too many parameters, and there is no time to understand the meaning of each parameter in turn. I copied one directly from the Internet and tried to install it first. And record the steps, the basic steps are decompression, configuration, compilation, and run.

1. Download the PHP source code and put it in a directory, such as ~ / temp

two。 Next, I was ready to run configure and tried it countless times, basically crashing, because each time it was always prompted that some support library was missing. To sum up, there are some

Curl,freetype,glib,libcurl,libjpeg,libmcrypt,libpng,libxml2,libXpm,libxslt,openssl,postgresql,bzip2, first install these libraries, and then go to the body.

3. Run this long configuration command in the source directory

'. / configure''-- prefix=/usr/local/php''--with-pdo-pgsql''--with-zlib-dir''--with-freetype-dir''--enable-mbstring''--with-libxml-dir=/usr''--enable-soap''--enable-calendar''--with-curl''--with-mcrypt''--with-gd''--with-pgsql''--disable -rpath''--enable-inline-optimization''--with-bz2''--with-zlib''--enable-sockets''--enable-sysvsem''--enable-sysvshm''--enable-pcntl''--enable-mbregex''--enable-exif''--enable-bcmath''--with-mhash''--enable-zip''--with-pcre-regex''--with-pdo-mysql '--with-mysqli''-- with-jpeg-dir=/usr''--with-png-dir=/usr''--enable-gd-native-ttf''--with-openssl''--with-fpm-user=www-data''--with-fpm-group=www-data''--with-libdir=/lib/x86_64-linux-gnu/''--enable-ftp''--with-gettext''--with-xmlrpc' '--with-xsl''-- enable-opcache''--enable-fpm''--with-iconv''--with-xpm-dir=/usr'

Crash No, I don't know what so many parameters are for, but in any case, it runs successfully and there is no error.

4. Run make & & make install under the PHP decompression directory, and then prompt libtool: link: `ext/opcache/ZendAccelerator.lo' is not a valid libtool object error, Ok, find online information, and run make distclean. Then re-make, indicating that the make file cannot be found. No information can be found. Fortunately, I have a snapshot of the virtual machine, restore the snapshot, reinstall the required library files, and re-configure, and finally succeed.

After 5.make is successful, run php-version under the installation path to display the version number normally. Add this path to the system path variable

Vi / etc/profile

Add the PHP path at the end

PATH=$PATH:/usr/local/php/bin

Export PATH

After saving, try to run php-version anywhere successfully.

6. Next, add PHP to the apache

Vim / etc/httpd/conf/httpd.conf

/ / add after LoadModule: LoadModule php7_module modules/libphp7.so / / if not added, access to the .php file will become a download. Normally, this should be automatically added.

/ / add: index.php after DirectoryIndex

/ / add after AddType application/x-gzip .gz .tgz: AddType application/x-httpd-php .php / / .php preceded by a space

Restart the Apache service and indicate that it failed. The libphp7.so cannot be found. Check the data again and delete the LoadModule line first. Take a look at the need to add the apxs path parameter when compiling php to facilitate the generation of libphp7.so, while apxs requires the installation of the dependency package httpd-devel. To install httpd-devel, you need httpd and httpd-tools. Download and install them all.

Recompile php,./configure-- with-apxs2=/usr/bin/apxs. After success, make & & make install again

Good thing, did not find any errors, check in httpd.conf, found that LoadModule this sentence has been automatically added. Stop and restart the apache service, test the PHP page, and everything is fine.

7. Copy php.ini-development or php.ini-production to / usr/local/php/lib in the lib folder under php's installation directory and rename it to php.ini

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: 271

*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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report