11.10/11.11/11.12 安裝PHP5php
11.13 安裝PHP7css
php中mysql,mysqli,mysqlnd,pdo究竟是什麼 html
http://blog.csdn.net/u013785951/article/details/60876816mysql
查看編譯參數 linux
http://ask.apelearn.com/question/1295redis
11.10/11.11/11.12 安裝PHP5:sql
PHP官網www.php.netexpress
當前主流版本爲5.6/7.1apache
有些過老的版本可能不兼容7版本。7的性能比5有很大的提高json
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-5.6.32.tar.gz
tar zxf php-5.6.32.tar.gz
cd php-5.6.32
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
--prefix=/usr/local/php 指定安裝目錄
--with-apxs2 apxs2是Apache的一種工具,能夠自動的把擴展的模塊放到Apache的目錄裏,就是在咱們用httpd -M的時候能夠加載出來。阿鑫在作的時候,修改了他的路徑(find一下apxs2,查到目錄,修改一下就能夠了)
--with-config-file-path=/usr/local/php/etc 指定php的配置文件
--with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config 指定這三種mysql不一樣的庫。至關於php與mysql相互通訊的驅動,因此是定義mysql的函數或者驅動的
後面的都是指定php的模塊的
make && make install
cp php.ini-production /usr/local/php/etc/php.ini 咱們指定了他的配置文件,要拷貝到那裏去( --with-config-file-path).。若是是開發環境就用 php.ini-development,php.ini-production用於生產環境
知識點:
/usr/local/php/bin/ PHP的核心文件
/usr/local/apache2.4/modules/libphp5.so 這是咱們安裝php5的模塊。咱們須要的
/usr/local/php/bin/ -m 查看php加載的模塊有哪些(靜態的)。是能夠擴展的,增長.so的文件
/usr/local/apache2.4/bin/httpd -M 能夠查看Apache的模塊。最後就是咱們安裝的php5的模塊
php做爲Apache的擴展模塊存在的。也就是說Apache須要藉助php module,也就是藉助這個.so的文件
vim /usr/local/apache2.4/conf/httpd.conf 能夠查看Apache的模塊。php也在其中
實例:
[root@localhost]# cd /usr/local/src
[root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.32.tar.gz
[root@localhost src]#tar zxf php-5.6.32.tar.gz
[root@localhost src]# cd php-5.6.32/
[root@localhost php-5.6.32]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
如下的幾個報錯,安裝PH5.6.32
1.configure: error: xml2-config not found. Please check your libxml2 installation.
#yum install -y libxml2-devel
2.configure: error: Cannot find OpenSSL's <evp.h>
#yum install -y openssl-devel
3.configure: error: Please reinstall the BZip2 distribution
#yum install -y bzip2 bzip2-devel
4.configure: error: jpeglib.h not found.
#yum -y install libjpeg-devel
5.configure: error: png.h not found.
#yum install -y libpng libpng-devel
6.configure: error: freetype-config not found.
#yum install -y freetype freetype-devel
7.configure: error: mcrypt.h not found. Please reinstall libmcrypt.
#yum install -y epel-release
#yum install -y libmcrypt-devel
編譯完成
Thank you for using PHP. config.status: creating php5.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands
安裝PH7提示報錯
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
#yum install -y perl*
#yum install -y httpd-devel
#find / -name apxs 獲得的路徑是:/usr/sbin/apxs
因而修改--with-apsx2=/usr/sbin/apxs指定到正確路徑
還有n個報錯,都是缺乏一些庫。安裝就行了
[root@localhost php-5.6.32]# echo $? 直到成功。configure成功
0
[root@localhost php-5.6.32]# make 開始make
xt/standard/crypt_blowfish.lo ext/standard/crypt_sha512.lo ext/standard/crypt_sha256.lo ext/standard/php_crypt_r.lo ext/standard/array.lo ext/standard/base64.lo ext/standard/basic_functions.lo ext/standard/browscap.lo ext/standard/crc32.lo ext/standard/crypt.lo ext/standard/cyr_convert.lo ext/standard/datetime.lo ext/standard/dir.lo ext/standard/dl.lo ext/standard/dns.lo ext/standard/exec.lo ext/standard/file.lo ext/standard/filestat.lo ext/standard/flock_compat.lo ext/standard/formatted_print.lo ext/standard/fsock.lo ext/standard/head.lo ext/standard/html.lo ext/standard/image.lo ext/standard/info.lo ext/standard/iptc.lo ext/standard/lcg.lo ext/standard/link.lo ext/standard/mail.lo ext/standard/math.lo ext/standard/md5.lo ext/standard/metaphone.lo ext/standard/microtime.lo ext/standard/pack.lo ext/standard/pageinfo.lo ext/standard/quot_print.lo ext/standard/rand.lo ext/standard/soundex.lo ext/standard/string.lo ext/standard/scanf.lo ext/standard/syslog.lo ext/standard/type.lo ext/standard/uniqid.lo ext/standard/url.lo ext/standard/var.lo ext/standard/versioning.lo ext/standard/assert.lo ext/standard/strnatcmp.lo ext/standard/levenshtein.lo ext/standard/incomplete_class.lo ext/standard/url_scanner_ex.lo ext/standard/ftp_fopen_wrapper.lo ext/standard/http_fopen_wrapper.lo ext/standard/php_fopen_wrapper.lo ext/standard/credits.lo ext/standard/css.lo ext/standard/var_unserializer.lo ext/standard/ftok.lo ext/standard/sha1.lo ext/standard/user_filters.lo ext/standard/uuencode.lo ext/standard/filters.lo ext/standard/proc_open.lo ext/standard/streamsfuncs.lo ext/standard/http.lo ext/standard/password.lo ext/tokenizer/tokenizer.lo ext/tokenizer/tokenizer_data.lo ext/xml/xml.lo ext/xml/compat.lo ext/xmlreader/php_xmlreader.lo ext/xmlwriter/php_xmlwriter.lo TSRM/TSRM.lo TSRM/tsrm_strtok_r.lo main/main.lo main/snprintf.lo main/spprintf.lo main/php_sprintf.lo main/fopen_wrappers.lo main/alloca.lo main/php_scandir.lo main/php_ini.lo main/SAPI.lo main/rfc1867.lo main/php_content_types.lo main/strlcpy.lo main/strlcat.lo main/mergesort.lo main/reentrancy.lo main/php_variables.lo main/php_ticks.lo main/network.lo main/php_open_temporary_file.lo main/output.lo main/getopt.lo main/streams/streams.lo main/streams/cast.lo main/streams/memory.lo main/streams/filter.lo main/streams/plain_wrapper.lo main/streams/userspace.lo main/streams/transports.lo main/streams/xp_socket.lo main/streams/mmap.lo main/streams/glob_wrapper.lo Zend/zend_language_parser.lo Zend/zend_language_scanner.lo Zend/zend_ini_parser.lo Zend/zend_ini_scanner.lo Zend/zend_alloc.lo Zend/zend_compile.lo Zend/zend_constants.lo Zend/zend_dynamic_array.lo Zend/zend_dtrace.lo Zend/zend_execute_API.lo Zend/zend_highlight.lo Zend/zend_llist.lo Zend/zend_vm_opcodes.lo Zend/zend_opcode.lo Zend/zend_operators.lo Zend/zend_ptr_stack.lo Zend/zend_stack.lo Zend/zend_variables.lo Zend/zend.lo Zend/zend_API.lo Zend/zend_extensions.lo Zend/zend_hash.lo Zend/zend_list.lo Zend/zend_indent.lo Zend/zend_builtin_functions.lo Zend/zend_sprintf.lo Zend/zend_ini.lo Zend/zend_qsort.lo Zend/zend_multibyte.lo Zend/zend_ts_hash.lo Zend/zend_stream.lo Zend/zend_iterators.lo Zend/zend_interfaces.lo Zend/zend_exceptions.lo Zend/zend_strtod.lo Zend/zend_gc.lo Zend/zend_closures.lo Zend/zend_float.lo Zend/zend_string.lo Zend/zend_signal.lo Zend/zend_generators.lo Zend/zend_virtual_cwd.lo Zend/zend_ast.lo Zend/zend_objects.lo Zend/zend_object_handlers.lo Zend/zend_objects_API.lo Zend/zend_default_classes.lo Zend/zend_execute.lo main/internal_functions_cli.lo sapi/cgi/cgi_main.lo sapi/cgi/fastcgi.lo -lcrypt -lresolv -lcrypt -lrt -lmysqlclient_r -lmcrypt -lpng -lz -ljpeg -lbz2 -lz -lrt -lm -ldl -lnsl -lxml2 -lz -lm -ldl -lssl -lcrypto -lxml2 -lz -lm -ldl -lfreetype -lmysqlclient -lm -lrt -ldl -lmysqlclient -lm -lrt -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt -o sapi/cgi/php-cgi Generating phar.php Generating phar.phar PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled. clicommand.inc directorytreeiterator.inc invertedregexiterator.inc directorygraphiterator.inc pharcommand.inc phar.inc Build complete. Don't forget to run 'make test'.
[root@localhost php-5.6.32]# echo $? 查看是否成功
0
[root@localhost php-5.6.32]# make install
Installing PEAR environment: /usr/local/php/lib/php/ [PEAR] Archive_Tar - installed: 1.4.3 [PEAR] Console_Getopt - installed: 1.4.1 [PEAR] Structures_Graph- installed: 1.1.1 [PEAR] XML_Util - installed: 1.4.2 [PEAR] PEAR - installed: 1.10.5 Wrote PEAR system config file at: /usr/local/php/etc/pear.conf You may want to add: /usr/local/php/lib/php to your php.ini include_path /usr/local/src/php-5.6.32/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin ln -s -f phar.phar /usr/local/php/bin/phar Installing PDO headers: /usr/local/php/include/php/ext/pdo/
[root@localhost php-5.6.32]# echo $? 查看是否成功
0
[root@localhost php-5.6.32]# cp php.ini-production /usr/local/php/etc/php.ini
!!阿鑫在./configure的時候,由於--with exps的路徑寫錯了。阿鑫的電腦路徑是apache2,跟着阿銘老師寫了2.4結果致使不成功。這點須要注意
----------------------------------------------------------------------------------------------------------------------------------------------------
11.13 安裝PHP7:
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
tar xjvf php-7.1.6.tar.bz2 //tar -xvf axin.tar 解包,後面跟打包名
tar zxf php-7.1.6.tar.bz2 (報錯,z : 表示 tar 包是被 gzip 壓縮過的,因此解壓時須要用 gunzip 解壓
cd php-7.1.6
./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
Thank you for using PHP. config.status: creating php7.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands
make
Generating phar.php Generating phar.phar PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled. directorytreeiterator.inc directorygraphiterator.inc pharcommand.inc clicommand.inc invertedregexiterator.inc phar.inc Build complete. Don't forget to run 'make test'.
&& make install
Wrote PEAR system config file at: /usr/local/php7/etc/pear.conf You may want to add: /usr/local/php7/lib/php to your php.ini include_path /usr/local/src/php-7.1.6/build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin ln -s -f phar.phar /usr/local/php7/bin/phar Installing PDO headers: /usr/local/php7/include/php/ext/pdo/
ls /usr/local/apache2.4/modules/libphp7.so
/usr/local/apache2.4/modules/libphp7.so
cp php.ini-production /usr/local/php7/etc/php.ini 解釋跟php5同樣
ls /usr/local/apache2.4/modules 下就有libphp7.so。查看Apache的模塊
libphp5.so mod_authn_dbm.so mod_cache_disk.so mod_file_cache.so mod_macro.so mod_proxy_scgi.so mod_session.so mod_userdir.so libphp7.so mod_authn_file.so mod_cache.so mod_filter.so mod_mime.so mod_proxy.so mod_setenvif.so mod_version.so mod_access_compat.so mod_authn_socache.so mod_cache_socache.so mod_headers.so mod_negotiation.so mod_proxy_uwsgi.so mod_slotmem_shm.so mod_vhost_alias.so mod_actions.so mod_authz_core.so mod_cgid.so mod_include.so mod_proxy_ajp.so mod_proxy_wstunnel.so mod_socache_dbm.so mod_watchdog.so mod_alias.so mod_authz_dbd.so mod_dav_fs.so mod_info.so mod_proxy_balancer.so mod_ratelimit.so mod_socache_memcache.so mod_allowmethods.so mod_authz_dbm.so mod_dav.so mod_lbmethod_bybusyness.so mod_proxy_connect.so mod_remoteip.so mod_socache_redis.so mod_auth_basic.so mod_authz_groupfile.so mod_dbd.so mod_lbmethod_byrequests.so mod_proxy_express.so mod_reqtimeout.so mod_socache_shmcb.so mod_auth_digest.so mod_authz_host.so mod_dir.so mod_lbmethod_bytraffic.so mod_proxy_fcgi.so mod_request.so mod_speling.so mod_auth_form.so mod_authz_owner.so mod_dumpio.so mod_lbmethod_heartbeat.so mod_proxy_fdpass.so mod_rewrite.so mod_status.so mod_authn_anon.so mod_authz_user.so mod_env.so mod_log_config.so mod_proxy_ftp.so mod_sed.so mod_substitute.so mod_authn_core.so mod_autoindex.so mod_expires.so mod_log_debug.so mod_proxy_hcheck.so mod_session_cookie.so mod_unique_id.so
/usr/local/php7/bin/php -m 查看php7加載的模塊
dom exif fileinfo filter gd hash iconv json libxml mbstring mcrypt mysqli openssl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session SimpleXML soap sockets SPL sqlite3 standard tokenizer xml xmlreader xmlwriter zlib [Zend Modules]
/usr/local/apache2.4/bin/apachectl -M 查看Apache加載了幾個php。最下面就是php7和php5
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_event_module (static) authn_file_module (shared) authn_core_module (shared) authz_host_module (shared) authz_groupfile_module (shared) authz_user_module (shared) authz_core_module (shared) access_compat_module (shared) auth_basic_module (shared) reqtimeout_module (shared) filter_module (shared) mime_module (shared) log_config_module (shared) env_module (shared) headers_module (shared) setenvif_module (shared) version_module (shared) unixd_module (shared) status_module (shared) autoindex_module (shared) dir_module (shared) alias_module (shared) php5_module (shared) php7_module (shared)
咱們如何在PHP7和PHP5之間選擇切換,修改配置文件:
vim /usr/local/apache2.4/conf/httpd.conf 在裏面找到PHP5或PHP7(可/ 搜索php5.so),前面加#註釋,註釋掉這一個,就是使用另外一個
#LoadModule php5_module modules/libphp5.so
LoadModule php7_module modules/libphp7.so
實例:
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
[root@localhost src]# ls
[root@localhost src]# tar -jxvf php-7.1.6.tar.bz2
[root@localhost src]# ls
apr-1.6.3 apr-util-1.6.1.tar.gz mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz php-5.6.32.tar.bz2
apr-1.6.3.tar.gz httpd-2.4.34 mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz php-7.1.6
apr-util-1.6.1 httpd-2.4.34.tar.gz php-5.6.32 php-7.1.6.tar.bz2
[root@localhost src]# cd php-7.1.6/
[root@localhost php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
[root@localhost php-7.1.6]# echo $?
0
[root@localhost php-7.1.6]# make
[root@localhost php-7.1.6]# echo $?
0
[root@localhost php-7.1.6]# make install
[root@localhost php-7.1.6]# echo $?
0
[root@localhostphp-7.1.6]# cp php.ini-production /usr/local/php7/etc/php.ini