How to upgrade mysql version and php version
代码输入中...2018-08-02 21:55:26
Download and Unzip
Go to the official PHP download page, select a mirror in the country where your server is located, and right-click to copy the link.
$ wget http://am1.php.net/get/php-7.0.0.tar.gz/from/this/mirror
Decompress the downloaded compressed package
$ tar xf php-7.0.0.tar.gz$cd php-7.0.0
Configuration before installation
Resolve dependency packages
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
Using the Linux make installation method, we need to configure the software compilation before make. It should be noted here that if the corresponding options are not configured before compilation, some modules will not be generated, and you may encounter problems later.
./configure --prefix=/usr/local/php7 \--with-config-file-path=/usr/local/php7/etc \--with-config-file-scan-dir=/usr/local/php7/etc/php.d \--with-apxs2=/usr/local/apache/bin/apxs \--with-mcrypt=/usr/include \--enable-mysqlnd \--with-mysqli \--with-pdo-mysql \--with-gd \--with-iconv \--with-zlib \--enable-xml \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-gd-native-ttf \--with-openssl \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-zip \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg-dir \--with-freetype-dir \--enable-opcache
In the above configuration, the blue option can be modified to become your own actual path based on your server deployment.
Compile and install
Originally in Linux, after configure, you only need make to compile, but due to different environments, different errors will occur, such as on my server, A libiconv error appeared, and I also saw a libmcrypt error above. Therefore, when compiling, we may need to install some corresponding modules or software environments based on the situations that occur during compilation. If you cannot continue compilation after a compilation error, you can use make clean to compile again.
When I compiled again, a libiconv error occurred. At the same time, our server is dual-core, so I used the following command to compile:
$ gmake -j2 ZEND_EXTRA_LIBS='-liconv'
-j2 means using dual-core cup Go to compile, compile faster. In short, if there is any error during compilation, go online to find out how to solve it.
After completing the compilation, just install it.
$ make install
Configure apache
If the above compilation and installation are normal, since we configured the apxs option, make will configure apache during compilation apxs to perform the calling operation, the result is to generate libphp7.so in the modules directory under the apache installation directory, and add a line
LoadModule php7_module modules/libphp7.so
to the apache configuration file httpd.conf. You will understand at a glance, that is, let apache to load a new libphp7.so module. But we still need to modify httpd.conf and reconfigure apache. Find LoadModule php, you will find that there are two lines of LoadModule, loading php5 and php7 at the same time, as follows:
LoadModule php5_module modules/libphp5.soLoadModule php7_module modules/libphp7.so
We comment out the first line, and also add a PHPIniDir configuration item, which is modified as follows:
#LoadModule php5_module modules/libphp5.soLoadModule php7_module modules/libphp7.soPHPIniDir /usr/local/php7/etc
Restart apache, now you can write a phpinfo to try it.
php configuration file
In the default installation state of php, you may find that there is no etc directory under /usr/local/php7, and there is no php.ini file. This is normal, but you can create php.ini yourself, or you can find two php.ini-xxx files in the PHP source directory, copy one and rename it to php.ini.
cd ~/php-7.0.0mkdir /usr/local/php7/etccp php.ini-production /usr/local/php7/etc/php.ini
If mysql is also installed on your server, there is no need to do other configuration. When we configure, we let php7 also support mysql. If your original lamp environment can already connect to mysql normally, So now php7 can actually connect to mysql normally, and mysql does not need to make any configuration modifications.