Compile and install php 5.4.11 and php5.4.11
Step 1 first download the tzr.gz php source package
Then tar zxvf php-5.4.11.tar.gz
Then cd php-5.4.11
Then copy the following compilation code
./Configure \
-- Prefix =/usr/local/php \
-- Enable-zip \
-- With-xsl \
-- Enable-zend-multibyte \
-- Enable-sockets \
-- Enable-soap \
-- With-pdo-mysql = mysqlnd \
-- With-mysql = mysqlnd \
-- Enable-pcntl \
-- With-mcrypt \
-- Enable-fpm \
-- Enable-shmop \
-- With-readline \
-- Enable-mbstring \
-- With-mhash \
-- Enable-gd-native-ttf \
-- With-freetype-dir \
--with-t1lib=/usr/local/share/t1lib
\
-- With-png-dir \
-- With-jpeg-dir \
-- With-gd \
-- With-openssl-dir \
-- Enable-ftp \
-- Enable-exif \
-- Enable-dba \
With-bz2 \
-- Enable-bcmath \
-- With-curl
!!!
Compiling PHP5 missing t1lib package solution
This error is reported:
configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.
Follow these steps:
1. Download t1lib-5.1.2.tar.gz
2. Solve the dependency:
apt-get build-dep t1lib
3. installation:
./configure & make without_doc & make install
4. Compile php5 in
./configure
Add
--with-t1lib=/usr/local/share/t1lib
. The code can be compiled again.
Address: http://lepingbeta.com/archives/255
If configure: error: Please reinstall readline-I cannot find readline. h is prompted!
Install sudo apt-get install libreadline-dev
Then compile it and you will see no error!
'. /Configure ''-prefix =/usr/local/php''-with-config-file-path =/etc''-with-mysql =/usr/local/mysql' '-with-mysqli =/usr/local/mysql/bin/mysql_config'-with-iconv-dir =/usr/local' '-with-freetype-dir ''- with-jpeg-dir''-with-png-dir''-with-zlib ''-with-libxml-dir =/usr''-enable-xml''-disable -rpath ''-enable-safe-mode''-enable-bcmath ''-enable-shmop''-enable-sysvsem ''-enable-inline-optimization''- -curl ''-with-curlwrappers''-enable-mbregex ''-enable-fpm''-enable-mbstring''-with-mcrypt ''-with-gd'' -enable-gd-native-ttf''-with-openssl ''-with-mhash''-enable-pcntl ''-enable-sockets''-with-xmlrpc'' -enable-zip ''-enable-soap'
The following error occurs:
Error: configure: error: png. h not found.
Solution:
Apt-get-y install libpng12-dev
Error 1:
Configure: error: xml2-config not found. Please check your libxml2 installation.
I have installed libxml2, but the following message is displayed:
Solution:
# Sudo apt-get install libxml2-dev
Error 2:
Configure: error: Please reinstall the BZip2 distribution
And I have already installed bzip2, the solution found online is to install bzip2-dev, but 11.10 does not have this library.
Solution: Find bzip2-1.0.5.tar.gz on the internet, decompress, make directly, sudo make install. (the source I use is from the http://ishare.iask.sina.com.cn/f/9769001.html)
Error 3:
Configure: error: Please reinstall the libcurl distribution-easy. h shoshould be in/include/curl/
Solution:
# Sudo apt-get install libcurl4-gnutls-dev
Error 4:
Configure: error: Invalid Lib. h not found.
Solution:
# Sudo apt-get install libjpeg-dev
Error 5:
Configure: error: png. h not found.
Solution:
# Sudo apt-get install libpng-dev
Error 6:
Configure: error: libXpm. (a | so) not found.
Solution:
# Sudo apt-get install libxpm-dev
Error 7:
Configure: error: freetype. h not found.
Solution:
# Sudo apt-get install libfreetype6-dev
Error 8:
Configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.
Solution:
# Sudo apt-get install libt1-dev
Error 9:
Configure: error: mcrypt. h not found. Please reinstall libmcrypt.
Solution:
# Sudo apt-get install libmcrypt-dev
Error 10:
Configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!
Solution:
# Sudo apt-get install libmysql ++-dev
Error 11:
Configure: error: xslt-config not found. Please reinstall the libxslt> = 1.1.0 distribution
Solution:
# Sudo apt-get install libxslt1-dev
Visible PHP source code installation before you need to install these dependencies, detailed visibility http://forum.ubuntu.org.cn/viewtopic.php? F = 88 & t = 231159
After the above errors are solved, try again./config .... After no error occurs,
# Make
# Sudo make install
Input the compiled and installed PHP file to the environment variable.
After compilation, enter the PHP path to the environment variable, otherwise, when the system executes the PHP file, it does not know that PHP has been installed. Therefore, you need to specify a directory so that the system can find the PHP compiled and installed.
After installing php and MySQL on the Linux CentOS system, you must add the php and mysql commands to the system commands for ease of use, when you run the "php-v" command to view the current php version information, an error indicating that the command does not exist will be prompted, next we will introduce in detail how to add php and mysql to environment variables in linux (false php and mysql are installed in/usr/local/webserver/php/and/usr/respectively/ local/webserver/mysql ).
Method 1: run the command export PATH = $ PATH:/usr/local/webserver/php/bin and export PATH = $ PATH:/usr/local/webserver/mysql/bin.
This method is only valid for the current session. That is to say, the PATH setting will expire after the system is logged out or logged out, but will only take effect temporarily.
Method 2: Execute vi ~ /. Modify the PATH line in the bash_profile file and add/usr/local/webserver/php/bin and/usr/local/webserver/mysql/bin to PATH = $ PATH: $ HOME/bin after a row
This method takes effect only for the current Login User
Method 3: Modify the/etc/profile file to make it permanently effective and take effect for all system users. Add the following two lines of code at the end of the file:
PATH = $ PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin
Export PATH
Or export PATH = $ PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin
Finally, run the source/etc/profile command or run the./profile command to make the modification take effect. After the command is executed, run the echo $ PATH command to check whether the modification is successfully added.
When starting the php Service
Sudo/usr/local/php/sbin/php-fpm
Will appear
Error:
[10-Apr-2013 18:12:02] NOTICE: PHP message: PHP Deprecated: Comments starting with '#' are deprecated in/usr/local/php/lib/php. ini on line 1874 in Unknown on line 0
[10-Apr-2013 18:12:02] ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)
[10-apr-2013 18:12:02] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'
[10-Apr-2013 18:12:02] ERROR: FPM initialization failed
At this time php could not find the configuration file php-fpm.conf
Solution:
Cd/usr/local/php/etc/
Sudo cp php-fpm.conf.default php-fpm.conf
Restart
Sudo/usr/local/php/sbin/php-fpm
Error:
[10-Apr-2013 18:14:09] NOTICE: PHP message: PHP Deprecated: Comments starting with '#' are deprecated in/usr/local/php/lib/php. ini on line 1874 in Unknown on line 0
[10-Apr-2013 18:14:09] ERROR: [pool www] cannot get gid for group 'nobody'
[10-Apr-2013 18:14:09] ERROR: FPM initialization failed
The reason is that [pool www] cannot get gid for group 'nobody' does not have this user I previously specified when compiling the user is www so entering vi/usr/local/php/etc/php-fpm.conf
Modify
User = www
Group = www
Then, test whether PHP is successfully installed.
Write a file in the website and directory to test whether PHP is successfully installed.
My nginx root directory is/usr/local/nginx/html/
Sudo vi index. php
<? Php phpinfo ();?>
Save
Then test it.