phpinstallwith
❶ 如何在虚拟机上搭建php
虚拟机是window系统还是 linux系统。
window系统就很简单了,直接下载一个集成环境,就可以运行了
linux 系统就要稍微麻烦点
1. php下载以及安装
下载: wget http://am1.php.net/distributions/php-7.3.2.tar.gz
解压: tar -zxvf php-7.3.2.tar.gz
进入目录开始编译安装:
./configure --prefix=/opt/soft/php --enable-fpm
下面是直接把常用的扩展安装好,免得后面在一个一个安装(推荐)
./configure --prefix=/opt/soft/php --with-curl --with-mysqli --with-openssl --with-pdo-mysql --enable-fpm
make
sudo make install
设置快捷访问方式: sudo cp /opt/soft/php/bin/php /usr/local/bin/
把php配置文件放在正确的位置
确认正确位置:php -i | grep php.ini
在下载的安装包中将php配置文件移动过来: sudo cp /opt/packages/php-7.3.2/php.ini-proction /opt/soft/php/lib/php.ini
ps:以后可以通过 php --ini 查看文件所在位置
2. nginx下载以及安装
和上面php一样的步骤,下载--解压--编译--安装
wget http://nginx.org/download/nginx-1.14.2.tar.gz
./configure --prefix=/opt/soft/nginx --sbin-path=/opt/soft/nginx/sbin/nginx --conf-path=/opt/soft/nginx/config/nginx.conf --error-log-path=/opt/soft/nginx/logs/error.log --pid-path=/opt/soft/nginx/logs/nginx.pid --http-log-path=/opt/soft/nginx/logs/access.log --with-http_stub_status_mole --with-http_ssl_mole
sudo make && make install
设置快捷访问方式: sudo cp /opt/soft/nginx/sbin/nginx /usr/local/bin/
简单配置nginx(详细配置后面再重新开文章写),然后浏览器直接访问ip就能访问了(这个时候只能访问html,访问php是直接下载文件)
开启nginx: sudo nginx(sudo nginx -s reload 重启nginx), 查看是否开起nginx: sudo netstat -anp | grep 80(端口号)
3. 配置nginx支持php
nginx不能直接和php通信,需要借助FastCGI(高速地在HTTP服务器和动态脚本语言间通信的接口),需要用到php-fpm(FastCGI Process Manager:FastCGI进程管理器, 他的具体概念可以参照这里搞清楚php-FPM到底是什么),这也是为什么在编译安装php的时候需要带--enable-fpm这个扩展的原因.
I. 启动php-fpm
进入到 /opt/soft/php/etc 这个目录将php-fpm.conf.default改名为php-fpm.conf,编辑他查看最后一行
然后进入最后一行指向php-pm.d目录,将www.conf.default改名成www.conf,并编辑成对应账号,我这里是xunan
然后将/opt/soft/php/sbin/php-fpm设置快捷访问方式,并启动php-fpm,也就是执行下面两个命令
sudo cp /opt/soft/php/sbin/php-fpm /usr/local/bin/ sudo php-fpm
ps: 重启php-fpm: 先ps aux | grep php-fpm,然后kill掉对应的进程
II. 配置nginx支持php
具体配置:
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
按照上面配置完成后,在配置文件的root目录下建立一个index.php,编辑
然后重启nginx(sudo nginx -s reload),在浏览器ip访问
❷ failed to install with error是怎么回事
用360安全卫士或者黄山修复IE.
黄山IE修复专家 V8.55 - 反浏览器劫持病毒/超越IE修复极限
http://www.xdowns.com/soft/1/16/2006/Soft_33319.html
❸ php安装的问题,无法载入 mysql 扩展,请检查 PHP 配置
首先你需要将PHP安装目录下的php_mysql.dll和php_mysqli.dll(我的在D:\apptools\php5\ext目录下)复制到c:\windows\system32目录下,然后修改php.ini文件(需要放到c:\windows目录下),关键是extension=php_mysql.dll 和extension_dir = "D:/apptools/php5/ext"。
我的配置是这样的:
[PHP]
;;;;;;;;;;;
; WARNING ;
;;;;;;;;;;;
; This is the default settings file for new PHP installations.
; By default, PHP installs itself with a configuration suitable for
; development purposes, and *NOT* for proction purposes.
; For several security-oriented considerations that should be taken
; before going online with your site, please consult php.ini-recommended
; and http://php.net/manual/en/security.php.
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; This file controls many aspects of PHP's behavior. In order for PHP to
; read it, it must be named 'php.ini'. PHP looks for it in the current
; working directory, in the path designated by the environment variable
; PHPRC, and in the path that was defined in compile time (in that order).
; Under Windows, the compile-time path is the Windows directory. The
; path in which the php.ini file is looked for can be overridden using
; the -c argument in command line mode.
;
; The syntax of the file is extremely simple. Whitespace and Lines
; beginning with a semicolon are silently ignored (as you probably guessed).
; Section headers (e.g. [Foo]) are also silently ignored, even though
; they might mean something in the future.
;
; Directives are specified using the following syntax:
; directive = value
; Directive names are *case sensitive* - foo=bar is different from FOO=bar.
;
; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one
; of the INI constants (On, Off, True, False, Yes, No and None) or an expression
; (e.g. E_ALL & ~E_NOTICE), or a quoted string ("foo").
;
; Expressions in the INI file are limited to bitwise operators and parentheses:
; | bitwise OR
; & bitwise AND
; ~ bitwise NOT
; ! boolean NOT
;
; Boolean flags can be turned on using the values 1, On, True or Yes.
; They can be turned off using the values 0, Off, False or No.
;
; An empty string can be denoted by simply not writing anything after the equal
; sign, or by using the None keyword:
;
; foo = ; sets foo to an empty string
; foo = none ; sets foo to an empty string
; foo = "none" ; sets foo to the string 'none'
;
; If you use constants in your value, and these constants belong to a
; dynamically loaded extension (either a PHP extension or a Zend extension),
; you may only use these constants *after* the line that loads the extension.
;
;
;;;;;;;;;;;;;;;;;;;
; About this file ;
;;;;;;;;;;;;;;;;;;;
; All the values in the php.ini-dist file correspond to the builtin
; defaults (that is, if no php.ini is used, or if you delete these lines,
; the builtin defaults will be identical).
;;;;;;;;;;;;;;;;;;;;
; Language Options ;
;;;;;;;;;;;;;;;;;;;;
; Enable the PHP scripting language engine under Apache.
engine = On
; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
zend.ze1_compatibility_mode = Off
; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On
; Allow ASP-style <% %> tags.
asp_tags = Off
; The number of significant digits displayed in floating point numbers.
precision = 12
; Enforce year 2000 compliance (will cause problems with non-compliant browsers)
y2k_compliance = On
; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit. You can enable output buffering ring runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On', as
; a value for this directive (e.g., output_buffering=4096).
output_buffering = On
; You can redirect all of the output of your scripts to a function. For
; example, if you set output_handler to "mb_output_handler", character
; encoding will be transparently converted to the specified encoding.
; Setting any output handler automatically turns on output buffering.
; Note: People who wrote portable scripts should not depend on this ini
; directive. Instead, explicitly set the output handler using ob_start().
; Using this ini directive may cause problems unless you know what script
; is doing.
; Note: You cannot use both "mb_output_handler" with "ob_iconv_handler"
; and you cannot use both "ob_gzhandler" and "zlib.output_compression".
; Note: output_handler must be empty if this is set 'On' !!!!
; Instead you must use zlib.output_handler.
;output_handler =
; Transparent output compression using the zlib library
; Valid values for this option are 'off', 'on', or a specific buffer size
; to be used for compression (default is 4KB)
; Note: Resulting chunk size may vary e to nature of compression. PHP
; outputs chunks that are few hundreds bytes each as a result of
; compression. If you prefer a larger chunk size for better
; performance, enable output_buffering in addition.
; Note: You need to use zlib.output_handler instead of the standard
; output_handler, or otherwise the output will be corrupted.
zlib.output_compression = Off
; You cannot specify additional output handlers if zlib.output_compression
; is activated here. This setting does the same as output_handler but in
; a different order.
;zlib.output_handler =
; Implicit flush tells PHP to tell the output layer to flush itself
; automatically after every output block. This is equivalent to calling the
; PHP function flush() after each and every call to print() or echo() and each
; and every HTML block. Turning this option on has serious performance
; implications and is generally recommended for debugging purposes only.
implicit_flush = Off
; The unserialize callback function will be called (with the undefined class'
; name as parameter), if the unserializer finds an undefined class
; which should be instantiated.
; A warning appears if the specified function is not defined, or if the
; function doesn't include/implement the missing class.
; So only set this entry, if you really want to implement such a
; callback-function.
unserialize_callback_func=
; When floats & doubles are serialized store serialize_precision significant
; digits after the floating point. The default value ensures that when floats
; are decoded with unserialize, the data will remain the same.
serialize_precision = 100
; Whether to enable the ability to force arguments to be passed by reference
; at function call time. This method is deprecated and is likely to be
; unsupported in future versions of PHP/Zend. The encouraged method of
; specifying which arguments should be passed by reference is in the function
; declaration. You're encouraged to try and turn this option Off and make
; sure your scripts work properly with it in order to ensure they will work
; with future versions of the language (you will receive a warning each time
; you use this feature, and the argument will be passed by value instead of by
; reference).
allow_call_time_pass_reference = On
;
; Safe Mode
;
safe_mode = Off
; By default, Safe Mode does a UID compare check when
; opening files. If you want to relax this to a GID compare,
; then turn on safe_mode_gid.
safe_mode_gid = Off
; When safe_mode is on, UID/GID checks are bypassed when
; including files from this directory and its subdirectories.
; (directory must also be in include_path or full path must
; be used when including)
safe_mode_include_dir =
; When safe_mode is on, only executables located in the safe_mode_exec_dir
; will be allowed to be executed via the exec family of functions.
safe_mode_exec_dir =
; Setting certain environment variables may be a potential security breach.
; This directive contains a comma-delimited list of prefixes. In Safe Mode,
; the user may only alter environment variables whose names begin with the
; prefixes supplied here. By default, users will only be able to set
; environment variables that begin with PHP_ (e.g. PHP_FOO=BAR).
;
; Note: If this directive is empty, PHP will let the user modify ANY
; environment variable!
safe_mode_allowed_env_vars = PHP_
; This directive contains a comma-delimited list of environment variables that
; the end user won't be able to change using putenv(). These variables will be
; protected even if safe_mode_allowed_env_vars is set to allow to change them.
safe_mode_protected_env_vars = LD_LIBRARY_PATH
; open_basedir, if set, limits all file operations to the defined directory
; and below. This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
;open_basedir =
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
disable_functions =
; This directive allows you to disable certain classes for security reasons.
; It receives a comma-delimited list of class names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
disable_classes =
; Colors for Syntax Highlighting mode. Anything that's acceptable in
; <span style="color: ???????"> would work.
;highlight.string = #DD0000
;highlight.comment = #FF9900
;highlight.keyword = #007700
;highlight.bg = #FFFFFF
;highlight.default = #0000BB
;highlight.html = #000000
; If enabled, the request will be allowed to complete even if the user aborts
; the request. Consider enabling it if executing long request, which may end up
; being interrupted by the user or a browser timing out.
; ignore_user_abort = On
;
; Misc
;
; Decides whether PHP may expose the fact that it is installed on the server
; (e.g. by adding its signature to the Web server header). It is no security
; threat in any way, but it makes it possible to determine whether you use PHP
; on your server or not.
expose_php = On
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
max_execution_time = 3000 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; error_reporting is a bit-field. Or each number up to get desired error
; reporting level
; E_ALL - All errors and warnings (doesn't include E_STRICT)
; E_ERROR - fatal run-time errors
; E_WARNING - run-time warnings (non-fatal errors)
; E_PARSE - compile-time parse errors
; E_NOTICE - run-time notices (these are warnings which often result
; from a bug in your code, but it's possible that it was
; intentional (e.g., using an uninitialized variable and
; relying on the fact it's automatically initialized to an
; empty string)
; E_STRICT - run-time notices, enable to have PHP suggest changes
; to your code which will ensure the best interoperability
; and forward compatibility of your code
; E_CORE_ERROR - fatal errors that occur ring PHP's initial startup
; E_CORE_WARNING - warnings (non-fatal errors) that occur ring PHP's
; initial startup
; E_COMPILE_ERROR - fatal compile-time errors
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
; E_USER_ERROR - user-generated error message
; E_USER_WARNING - user-generated warning message
; E_USER_NOTICE - user-generated notice message
;
; Examples:
;
; - Show all errors, except for notices and coding standards warnings
;
;error_reporting = E_ALL & ~E_NOTICE
;
; - Show all errors, except for notices
;
;error_reporting = E_ALL & ~E_NOTICE | E_STRICT
;
; - Show only errors
;
;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
;
; - Show all errors except for notices and coding standards warnings
;
error_reporting = E_ALL & ~E_NOTICE
; Print out errors (as a part of the output). For proction web sites,
; you're strongly encouraged to turn this feature off, and use error logging
; instead (see below). Keeping display_errors enabled on a proction web site
; may reveal security information to end users, such as file paths on your Web
; server, your database schema or other information.
display_errors = On
; Even when display_errors is on, errors that occur ring PHP's startup
; sequence are not displayed. It's strongly recommended to keep
; display_startup_errors off, except for when debugging.
display_startup_errors = Off
; Log errors into a log file (server-specific log, stderr, or error_log (below))
; As stated above, you're strongly advised to use error logging in place of
; error displaying on proction web sites.
log_errors = Off
; Set maximum length of log_errors. In error_log information about the source is
; added. The default is 1024 and 0 allows to not apply any maximum length at all.
log_errors_max_len = 1024
; Do not log repeated messages. Repeated errors must occur in same file on same
; line until ignore_repeated_source is set true.
ignore_repeated_errors = Off
; Ignore source of message when ignoring repeated messages. When this setting
; is On you will not log errors with repeated messages from different files or
; sourcelines.
ignore_repeated_source = Off
; If this parameter is set to Off, then memory leaks will not be shown (on
; stdout or in the log). This has only effect in a debug compile, and if
; error reporting includes E_WARNING in the allowed list
report_memleaks = On
; Store the last error/warning message in $php_errormsg (boolean).
track_errors = Off
; Disable the inclusion of HTML tags in error messages.
; Note: Never use this feature for proction boxes.
;html_errors = Off
; If html_errors is set On PHP proces clickable error messages that direct
; to a page describing the error or function causing the error in detail.
; You can download a of the PHP manual from http://www.php.net/docs.php
; and change docref_root to the base URL of your local including the
; leading '/'. You must also specify the file extension being used including
; the dot.
; Note: Never use this feature for proction boxes.
;docref_root = "/phpmanual/"
;docref_ext = .html
; String to output before an error message.
;error_prepend_string = "<font color=ff0000>"
; String to output after an error message.
;error_append_string = "</font>"
; Log errors to specified file.
;error_log = filename
; Log errors to syslog (Event Log on NT, not valid in Windows 95).
;error_log = syslog
;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
;
; Note - track_vars is ALWAYS enabled as of PHP 4.0.3
; The separator used in PHP generated URLs to separate arguments.
; Default is "&".
;arg_separator.output = "&"
; List of separator(s) used by PHP to parse input URLs into variables.
; Default is "&".
; NOTE: Every character in this directive is considered as separator!
;arg_separator.input = ";&"
; This directive describes the order in which PHP registers GET, POST, Cookie,
; Environment and Built-in variables (G, P, C, E & S respectively, often
; referred to as EGPCS or GPC). Registration is done from left to right, newer
; values override older values.
variables_order = "EGPCS"
; Whether or not to register the EGPCS variables as global variables. You may
; want to turn this off if you don't want to clutter your scripts' global scope
; with user data. This makes most sense when coupled with track_vars - in which
; case you can access all of the GPC variables through the $HTTP_*_VARS[],
; variables.
;
; You should do your best to write your scripts so that they do not require
; register_globals to be on; Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
register_globals = On
; Whether or not to register the old-style input arrays, HTTP_GET_VARS
; and friends. If you're not using them, it's recommended to turn them off,
; for performance reasons.
register_long_arrays = On
; This directive tells PHP whether to declare the argv&argc variables (that
; would contain the GET information). If you don't use these variables, you
; should turn it off for increased performance.
register_argc_argv = On
; When enabled, the SERVER and ENV variables are created when they're first
; used (Just In Time) instead of when the script starts. If these variables
; are not used within a script, having this directive on will result in a
; performance gain. The PHP directives register_globals, register_long_arrays,
; and register_argc_argv must be disabled for this directive to have any affect.
auto_globals_jit = On
; Maximum size of POST data that PHP will accept.
post_max_size = 8M
; Magic quotes
;
; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = On
; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off
; Use Sybase-style magic quotes (escape ' with '' instead of \').
magic_quotes_sybase = Off
; Automatically add files before or after any PHP document.
auto_prepend_file =
auto_append_file =
; As of 4.0b4, PHP always outputs a character encoding by default in
; the Content-type: header. To disable sending of the charset, simply
; set it to be empty.
;
; PHP's built-in default is text/html
default_mimetype = "text/html"
;default_charset = "iso-8859-1"
; Always populate the $HTTP_RAW_POST_DATA variable.
;always_populate_raw_post_data = On
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
include_path = ".;D:\apptools\php5\PEAR"
; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues. The alternate is to use the
; cgi.force_redirect configuration below
doc_root =
; The directory under which PHP opens the script using /~username used only
; if nonempty.
user_dir =
; Directory in which the loadable extensions (moles) reside.
extension_dir = "D:/apptools/php5/ext"
; Whether or not to enable the dl() function. The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
enable_dl = On
❹ 如何在PHP中开启GD库支持
开启GD库支持有以下几种方法 检测GD库是否安装命令 php5 -m | grep -i gd 或者 php -i | grep -i --color gd如未安装GD库,则为服务器安装,方法如下 如果是源码安装,则加入参数 --with-gd 如果是debian系的linux系统,用apt-get安装,如下 apt-get install php5-gd 如果是CentOS系的系统,用yum安装,如下 yum install php-gd 如果是suse系的linux系统,用yast安装,如下 yast -i php5_gd 如果嫌这个世界不够蛋疼呢,可以在原先编译PHP不支持GD的情况下附加 先下zlib源码,libpng源码,gd源码 解压后到源码目录 zlib目录 ./configure --prefix=/usr/local/zlib make ; make install make clean libpng目录 cp scripts/makefile.linux ./makefile ./configure --prefix=/usr/local/libpng make ; make install make clean gd目录 ./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng make ; make install make clean 最后在php.ini中,搜到[gd]后,在下面加一行 extension=/usr/local/libgdgd.so 然后重启php服务,如果不行,试试reboot 所以如果是源码安装,最好还是在编译PHP的时候加参数--with-gd Windows下开启PHP的GD库支持 找到php.ini,打开内容,找到: ;extension=php_gd2.dll 把最前面的分号“;”去掉,再保存即可,如果本来就没有分号,那就是已经开启了。
❺ 如何在linux安装php开发环境
我一般会选用源码安装 php,安装 php 的过程指定要安装的扩展,但是避免不了缺少某个扩展未安装导致程序运行报错的问题。以 fileinfo 为例,介绍一下怎么添加 php 扩展。
1. 准备
通常遇到报错:xxx function undefined,而这个函数是系统函数的话,那一定是你缺少某个扩展。添加扩展也非常简单。首选要确认当前的 php 是哪个版本,不同版本的 php 扩展会有些许出入。然后找到 Php 源码目录,也就是从网上下载下来并且解压的 php 文件包。添加扩展的时候需要在源码包里面去执行命令。
2. 安装 fileinfo 扩展
1. 确认 php 版本
php -v
# PHP 7.4.4 (cli)
2. 找到 php 可执行文件的位置
whereis php
# php: /usr/local/php /usr/local/php/bin/php
可以看出 php 执行文件在 /usr/local/php/bin 目录里面
那么尝试执行 phpize,保证这个文件存在,phpize 命令在添加扩展的时候需要用到
/usr/local/php/bin/phpize -v
# Configuring for:
# PHP Api Version: 20190902
# Zend Mole Api No: 20190902
# Zend Extension Api No: 320190902
3.进入php源码目录
我的习惯是网络下载的软件会放在 /usr/local/src 下面,
cd /usr/local/src/php-7.4.4
cd /etc
cd fileinfo
扩展都在源码目录的 etc 下面,里面有 curl,gd,ftp 等等扩展目录,我要安装 fileinfo,所以到 fileinfo 目录里面
4.开始安装
确定目录下面有 config.m4 文件,如果没有,应该会有 config0.m4 文件,把 config0.m4 复制一份为 config.m4,如果没有这个文件,会报错:can not found config.m4
/usr/local/php/bin/phpize
./configure
make && make install
如果这几行命令运行下来都没有报错,那么说明扩展文件已经生成,并且已经自动移入相应位置。接下来就是修改 php.ini,追加 extension=fileinfo.so 到 php.ini 中。
5.修改php.ini,加载扩展文件
查看 php.ini 的位置
php -i | grep php.ini
#Configuration File (php.ini) Path => /usr/local/php/etc
#Loaded Configuration File => /usr/local/php/etc/php.ini
可以看到 php.ini 的位置: /usr/local/php/etc/php.ini
vim /usr/local/php/etc/php.ini
#添加extension=fileinfo.so,保存
php -m | grep fileinfo
#fileinfo
看到输出 fileinfo,至此,fileinfo 扩展安装完毕!另外可以使用 pecl 命令安装,更方便快捷!
❻ Linux系统中设置多版本PHP共存配合Nginx服务器使用
应用环境
LNMP的环境,当前PHP版本5.3.8,遇到一个应用需求只支持PHP
5.2.x,又希望保持现有应用还是用PHP
5.3.8。也就是说需要两个版本的PHP同时存在,供nginx根据需要调用不同版本。
思路
Nginx是通过PHP-FastCGI与PHP交互的。而PHP-FastCGI运行后会通过文件、或本地端口两种方式进行监听,在Nginx中配置相应的FastCGI监听端口或文件即实现Nginx请求对PHP的解释。
既然PHP-FastCGI是监听端口和文件的,那就可以让不同版本的PHP-FastCGI同时运行,监听不同的端口或文件,Nginx中根据需求配置调用不同的PHP-FastCGI端口或文件,即可实现不同版本PHP共存了。
配置记录
下面记录简单的配置流程,基于已经安装了lnmp的debian环境。当前版本的PHP是5.3.8,位于/usr/local/php。
1.下载PHP-5.2.14及相关的FPM、autoconf组件:
mkdir
~/php5.2
cd
~/php5.2
wget
-c
http://museum.php.net/php5/php-5.2.14.tar.gz
wget
-c
http://php-fpm.org/downloads/php-5.2.14-fpm-0.5.14.diff.gz
2.解压PHP-5.2.14,并打上PHP-FPM的补丁:
tar
zxvf
php-5.2.14.tar.gz
gzip
-cd
php-5.2.14-fpm-0.5.14.diff.gz
|
patch
-d
php-5.2.14
-p1
3.如果你已经通过lnmp安装,应该已经安装好了autoconf,如果没有,请自行下载并编译autoconf-2.13,然后设置autoconf环境变量:
export
PHP_AUTOCONF=/usr/local/autoconf-2.13/bin/autoconf¬
export
PHP_AUTOHEADER=/usr/local/autoconf-2.13/bin/autoheader
3.编译安装PHP-5.2.14在新的路径(/usr/local/php-5.2.14)下,注意–prefix、–with-config-file-path的路径,并且打开fastcgi和fpm选项:
cd
php-5.2.14/
./buildconf
--force
./configure
--prefix=/usr/local/php-5.2.14
--with-config-file-path=/usr/local/php-5.2.14/etc
--with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config
--enable-fastcgi
--enable-fpm
make
ZEND_EXTRA_LIBS='-liconv'
make
install
4.设置/usr/local/php-5.2.14/etc/php-fpm.conf,监听端口:
<value
name="listen_address">127.0.0.1:9001</value>
或者监听文件:
<value
name="listen_address">/path/to/unix/socket</value>
其他参数根据服务器环境和需求自行定制。
5.启动php-fpm,以后可以通过php-fpm进行管理:
/usr/local/php-5.2.14/sbin/php-fpm
start
字php5.3.3后,php已经将php-fpm继承到php中,而且内置的php-fpm默认不支持(start|stop|reload)的平滑启动参数,需要使用官方源代码中提供的启动脚本来控制:
cp
-f
(php
-5.3.x-source-dir)/sapi/fpm/init.d.php-fpm
/etc/init.d/php-fpm
chmod
755
/etc/init.d/php-fpm
/etc/init.d/php-fpm
start
php-fpm支持的操作:
start,启动PHP的FastCGI进程。
stop,强制终止PHP的FastCGI进程。
quit,平滑终止PHP的FastCGI进程。
restart,
重启PHP的FastCGI进程。
reload,
重新加载PHP的php.ini。
logrotate,
重新启用log文件。
5.3.3的php-fpm脚本支持的操作:start|stop|force-quit|restart|reload|status
6.配置好PHP-5.2.14的php.ini,重新加载生效:
vi
/usr/local/php-5.2.14/etc/php.ini
/usr/local/php-5.2.14/sbin/php-fpm
reload
7.修改nginx配置,对需要的服务配置使用PHP-5.2.14:
location
~
.*.(php|php5)?$
{
fastcgi_pass
127.0.0.1:9001;
fastcgi_index
index.php;
include
fcgi.conf;
}
8.记录一下自己编译php5.5.10使用的配置
./configure
--prefix=/usr/local/php-5.5.10
--with-config-file-path=/usr/local/php-5.5.10/etc
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--with-bz2
--with-curl=/usr/bin
--enable-ftp
--enable-sockets
--disable-ipv6
--with-gd
--with-jpeg-dir=/usr/local
--with-png-dir=/usr/local
--with-freetype-dir=/usr/local
--enable-gd-native-ttf
--with-iconv-dir=/usr/local
--enable-mbstring
--enable-calendar
--with-gettext
--with-libxml-dir=/usr/local
--with-zlib
--with-pdo-mysql=mysqlnd
--enable-dom
--enable-xml
--enable-fpm
--with-libdir=lib64
--with-mcrypt=/usr/bin
--enable-zip
--enable-soap
--enable-mbstring
--with-gd
--with-openssl
--enable-pcntl
--with-xmlrpc
--enable-opcache
❼ Linux系统下PHP-FPM的安装和配置教程
基本安装方法
安装工具包
$
sudo
apt-get
install
python-software-properties
添加ppa源
$
sudo
add-apt-repository
ppa:yola/php5
安装php5-fpm
sudo
apt-get
update
sudo
apt-get
install
php5-fpm
其它必要的软件安装接
sudo
apt-get
install
nginx
配置php-fpm
php-fpm的解析器是C/S结构,它的配置文件位于:
(1)/etc/php5/fpm/php-fpm.conf
(2)/etc/php5/fpm/pool.d/
一般没什么严格的配置的要求,或者说这块我还没有具体的研究每个配置参数的意义
我采用了tcp模式与fastcgi进程进行连接,因此我修改了tcp监听的地址和端口,修改了一下监视目录的名称,这里不做具体详细解释了,大家可以参考官方文档根据自己的需求进行配置
重启php5-fpm
安装提示错误解决
如果服务器的系统源中没有php5-fpm,安装的时候会提示:
Reading
state
information...
Done
E:
Couldn't
find
package
php5-fpm
解决办法
1.
添加非官方的源到
/etc/apt/sources.list
echo
"deb
http://ppa.launchpad.net/brianmercer/php/ubuntu
lucid
main"
>>
/etc/apt/sources.list
echo
"deb-src
http://ppa.launchpad.net/brianmercer/php/ubuntu
lucid
main"
>>
/etc/apt/sources.list
2.
安装php5-fpm
sudo
apt-get
update
&&
sudo
apt-get
install
php5-fpm
3.
安装php扩展组件
sudo
apt-get
install
php-apc
php5-curl
php5-gd
php5-imagick
php5-mysql\
php5-memcache
php5-memcached
php5-mcrypt
4.
启动php-fpm
sudo
/etc/init.d/php5-fpm
start
php.in位于/etc/php5/fpm/php.ini
php-fpm.ini位于/etc/php5/fpm/php5-fpm.conf
php-fpm启动时报错
PHP
Warning:
PHP
Startup:
Unable
to
load
dynamic
library
'/usr/lib/php5/20060613+lfs/gd.so'
-
/usr/lib/php5/20060613+lfs/gd.so:
undefined
symbol:
gdImageCreateFromJpeg
in
Unknown
on
line
0
locate
libgd
查看gd的动态库位置,如果/usr/local/lib/目录里有则
rm
/usr/local/lib/libgd*
重启php-fpm即可
去掉php-fpm启动时警告提示信息
PHP
Deprecated:
Comments
starting
with
'#'
are
deprecated
in
/etc/php5/fpm/conf.d/imagick.ini
on
line
1
in
Unknown
on
line
0
把#变成;即可去掉该提示
❽ php怎么用啊我是初学者(环境搭建好了)
后,默认用户名为root,默认密码为mysql)
下载时下载编译好的那种
解压MySQL,把所有文件复制到/usr/local/mysql
[root@Bleach usr]# groupadd mysql
[root@Bleach usr]# useradd -g mysql mysql
[root@Bleach mysql]# cd mysql
[root@Bleach mysql]# scripts/mysql_install_db --user=mysql
[root@Bleach mysql]# chown -R root .
[root@Bleach mysql]# chown -R mysql data
[root@Bleach mysql]# chgrp -R mysql .
[root@Bleach mysql]# ./bin/mysqld_safe --user=mysql &
[root@Bleach mysql]# ./bin/mysqladmin -u root password mysql
[root@Bleach mysql]# cp ./support-files/mysql.server /etc/init.d/mysql
[root@Bleach mysql]# cd /etc/rc3.d/
[root@Bleach rc3.d]# ln -s /etc/init.d/mysql S85mysql
[root@Bleach rc3.d]# ln -s /etc/init.d/mysql K85mysql
安装GD库基本包gd-devel
#rpm -ivh gd-devel-1.8.4-11.i386.rpm
安装XPM支持
#rpm -ivh xpm-3.4k-2.i386.rpm
安装libxml2 (记得PHP5.1.1只支持libxml2-2.6.11以上版本)
#tar zxvf libxml2-2.6.11.tar.gz
#cd libxml2-2.6.11
#./configure
#make
#make install
开始装GD库支持
-------------------------------------------------------
先安装GD基础rpm包
#rpm –ivh gd-devel.rpm
ZLIB
#./configure
#make
#make install
JPEGSRC
#./configure --enable-shared
#make
#make install-lib
#make install
LIBPNG
#cp scripts/makefile.std Makefile
#make
#make install
最后是GD2.*
#./configure --with-png=/usr/local --with-jpeg=/usr/local --with-freetype=/usr
#make
#make install
----------------------------------------------
上面一切都很顺利的话,GD就算成功的安装上了. 如果有问题,应该是缺少支持包,总之是少什么就下载什
么来安装上.
跟着下来,开始安装APAHCHE2和PHP5
#./configure --prefix=/usr/local/apache2 --enable-mole=so
#make
#make install
PHP5
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-gd=/usr/local --enable-trace-vars --with-zlib-dir=/usr/local -with-mysql=/usr/local/mysql --enable-mbstring=all
#make
#make install
复制PHP.INI文件到正确位置
在PHP目录下运行
#cp php.ini-dist /usr/local/php/lib/php.ini
编辑apache配置文件httpd.conf
#vi /usr/local/apache2/conf/httpd.conf
要改的有如下几处:
一般都在
#AddType application/x-tar .tgz
下加一行
AddType application/x-httpd-php .php
查找
index.html
在后面加 index.htm index.php 让它把index.php做为默认页
再找
#ServerName
把#去掉,后面的IP改成你的IP.
找到
"/usr/local/apache2/htdocs"
把两个"/usr/local/apache2/htdocs"改为你存放网页文件的路径
保存httpd.conf文件.
启动它
# /usr/local/apache2/bin/apachectl start
如果没有出错,写一个测试页放到你网页目录下, 我的就是上面所说的 /www
phpinfo();
?>
保存.试试在测试器里打IP进去就可以看到PHPINFO页了
把Apache2加入系统服务
#cd /etc/init.d
#cp /usr/local/apache/bin/apachectl ./httpd
用文本编辑/etc/init.d/httpd
在头部加入
#chkconfig: 345 79 15
#description: Activates/Deactivates Apache Web Server
# processname: httpd
#chkconfig --add httpd
安装ZendOptimizer-2.5.3加速PHP
#./install.sh
------------------------
一直想写篇关于Linux下 PHP环境的详细安装配置文章, 没什么时间
趁现要配几台服务器, 借此机会把自己安装配置的步骤写出来, 供初学者参考!
有什么错误的地方请大家指证批评,谢谢! - by Mayer
首先我在 /root 目录下建了一个 soft 文件夹来保存我要安装的源码包
mkdir /root/soft
cd /root/soft
先找到 apache php mysql proftpd 源码包下载的URL地址
请浏览
等官方网站
使用wget 直接下载
wget
...
wget
...
wget
...
第一步:安装apache
注:当前目录为/root/soft ,
目录下有
httpd-2.0.55.tar.gz, php-5.0.5.tar.gz
等二进制源码包
#号代表为root 根权限,#后是输入的一条命令
执行下列命令
解压源码包
# tar -zxf httpd-2.0.55.tar.gz
进入安装目录
# cd httpd-2.0.55
配置apache安装信息
# ./configure --prefix=/usr/local/apache --enable-moles=so --enable-rewrite
执行make安装
# make; make install
安装完后
# vi /usr/local/apache/conf/httpd.conf
找到 prefork.c 下的
MaxClients 150
改为
ServerLimit 2000
MaxClients 1000
apache默认工作在prefork.c模式下,并发进程为150,超过后就无法访问,150是远远不够的,所以这里按自己网站的需求改, 如1000
由于apache默认最大并发进程是 256 所以要先设置 ServerLimit 2000 将服务器可设的最大并发数设为2000, 然后再设置最大并发数 MaxClients 1000
找到 #ServerName
在其下设置 ServerName 如下
ServerName
基中
为你网站名,也可用IP代替
找到 DocumentRoot "/usr/local/apache/htdocs"
设置你的 WEB 服务器的根目录 如
DocumentRoot "/myweb"
找到 DirectoryIndex index.html index.html.var 改为
DirectoryIndex index.html index.php index.htm
找到 ForceLanguagePriority Prefer Fallback 在其下加上
AddDefaultCharset gb2312
改完后保存(vi 的用法请查 Linux vi 命令)
用下面命令启动WEB服务器
# /usr/local/apache/bin/apachectl start
查看自己的站点是否正常
也可用IP
用 # /usr/local/apache/bin/apachectl stop 可停止服务
安装MYSQL
# tar -zxf mysql-standard-5.0.15-linux-i686.tar.gz
# cp -r mysql-standard-5.0.15-linux-i686 /usr/local/mysql
# vi /usr/local/mysql/support-files/my-medium.cnf
在后面加上
max_connections = 1000
log-slow-queries
long_query_time = 5
注 max_connections 为允许的最大连接数
log-slow-queries 打开低速查询日志
long_query_time 低速查询的秒数(运行一句sql达到此时间记录在日志里)
然后COPY 它为 /etc/my.cnf 文件
# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
添加mysql用户及用户组
# groupadd mysql
# useradd -g mysql mysql
修改mysql目录权限
# chown -R root /usr/local/mysql
# chgrp -R mysql /usr/local/mysql
# chown -R mysql /usr/local/mysql/data
生成mysql系统数据库
# /usr/local/mysql/scripts/mysql_install_db --user=mysql&
启动mysql服务
# /usr/local/mysql/bin/mysqld_safe --user=mysql&
如出现 Starting mysqld daemon with databases from /usr/local/mysql/data
代表正常启动mysql服务了, 按Ctrl + C 跳出
修改 mysql 的 root 密码
# /usr/local/mysql/bin/mysqladmin -u root -p password 123456
回车出现 Enter password: 最开始密码默认为空 继续回车即可
123456 即为你的新密码
安装GD库(让PHP支持GIF,PNG,JPEG)
首先下载 jpeg6,libpng,freetype 并安装模块
wget
...
wget
...
wget
...
wget
...
安装 jpeg6
建立目录
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/man
# mkdir /usr/local/jpeg6/man/man1
# cd /root/soft
# tar -zxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make; make install
安装libpng
# cd /root/soft
# tar -zxf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# cp scripts/makefile.std makefile
# make; make install
安装 freetype
# cd /root/soft
# tar -zxf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# ./configure --prefix=/usr/local/freetype
# make;make install
安装最新的GD库
# cd /root/soft
# tar -zxf gd-2.0.33.tar.gz
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
# make; make install
安装最新的Curl库
# cd /root/soft
# wget
...
# tar -zxf curl-7.15.0.tar.gz
# ./configure --prefix=/usr/local/curl
# make; make install
安装PHP
由于php5需libxml2的支持, 所以先下载并安装libxml2
# cd /root/soft
# wget
...
# tar -zxf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# ./configure --prefix=/usr/local/libxml2
# make; make install
安装 libxslt
# cd /root/soft
# wget
...
# tar -zxf libxslt-1.1.15.tar.gz
# cd libxslt-1.1.15
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
# make; make install
# tar -zxf php-5.0.5.tar.gz
# cd php-5.05
# ./configure --prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/
--with-curl=/usr/local/curl --enable-ftp
--with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib
--enable-soap --with-xsl=/usr/local/libxslt --enable-xslt
--with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/
--with-zlib-dir=/usr/lib --with-png
--with-freetype-dir=/usr/local/freetype
# make
# make install
其中./configure 后的
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql/
--with-libxml-dir=/usr/local/libxml2
是必要的选项
--with-gd=/usr/local/gd2/
--with-jpeg-dir=/usr/local/jpeg6/
--with-png
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
这是让PHP支持GD库的配置选项
--with-curl=/usr/local/curl 支持CURL库
--enable-ftp 打开FTP库函数支持
--enable-soap --with-xsl=/usr/local/libxslt --enable-xslt
让PHP支持SOAP, 上面这些一般用得少, 可以去掉
配置 httpd.conf 让apache支持PHP
# vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
重启apache
# /usr/local/apache/bin/apachectl restart
在你Web目录里建一内容为 PHP文件, 输入URL地址查看PHP配置是否正确
安装 phpmyadmin
下载
# cd /root/soft
# wget
...
# tar -zxf phpMyAdmin-2.6.4-pl3.tar.gz
# vi phpMyAdmin-2.6.4-pl3/config.inc.php
找到 $cfg['Servers'][$i]['auth_type'] = 'config'; 将config 改为 http
保存后
mv phpMyAdmin-2.6.4-pl3 /你的phpmyadmin目录
关于mysql4.1-4移植4.0旧数据库中文乱码问题的解决方法
进入phpmyadmin管理
建立你数据库名并选上 gb2312_bin 的编码
然后导入你先前备份好的SQL文件, 导入时选择 文件的字符集:gb2312
完成后就OK了
注: PHP连接mysql4.1和5.0 数据库后需指定字符集 需执行如 mysql_query("SET NAMES 'gb2312' ");
否则会产生中文乱码问题!
❾ 请问下linux下搭建php环境的一些问题。
这是我自己整理的你可以查考下
基本上没有什么包得
一、mysql安装:
1.安装bison和cmake
提示:MySQL 5.5 版本的安装需要这两个软件,bison我们可以用方便的yum直接安装好,cmake则用编译安装的办法。
yum install bison
注:需安装GCC,ncurses-devel。
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4/
./configure
gmake
gmake install
chkconfig iptables off 禁用iptables(永久生效)
service iptables stop (临时生效)
3,安装
提示:如果机器上已有自带的MySQL版本,最好先卸载自带的MySQL,以防以后使用的时候混淆。
卸载命令:yum remove mysql
如果不确定机器上是否自带有MySQL,也一样可以执行下卸载命令无妨。
/usr/sbin/groupadd mysql (如果有提示已存在,并不是错误)
/usr/sbin/useradd -g mysql mysql (如果有提示已存在,并不是错误)
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
tar zxvf mysql-5.5.13.tar.gz
cd mysql-5.5.13
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/mysql
make
make install
4,设置
cd /usr/local/mysql
cp ./support-files/my-huge.cnf /etc/my.cnf
编辑/etc/my.cnf
在 [mysqld] 段增加
datadir = /data/mysql
wait-timeout = 30
max_connections = 512
max_connect_errors = 10000000
在 [mysqld] 段修改
max_allowed_packet = 16M
./scripts/mysql_install_db --user=mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on
编辑/etc/rc.d/init.d/mysqld
把basedir=编辑成basedir=/usr/local/mysql
把datadir=编辑成datadir=/data/mysql
service mysqld start
bin/mysqladmin -u root password 'password_for_root'
其中引号内的password_for_root是要设置的root密码
service mysqld restart
/usr/local/mysql/bin/mysql -uroot -p
show databases;
===========================================================================
二、apache安装
./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-so
make;make install
groupadd apache
useradd -g apache -M -s /sbin/nologin apache
vi /usr/local/apache2/conf/httpd.conf
找到如下2句 并在行头加#号注释掉
User daemon
Group daemon
追加如下2句
User apache
Group apache
/usr/local/apache2/bin/apachectl start
lsof -i:80
测试:首先,关闭 service iptables stop
curl http://localhost (linux)
http://服务器IP(windows)
#cp /usr/local/src/httpd-2.2.19/build/rpm/httpd.init /etc/rc.d/init.d/httpd
#vim /etc/rc.d/init.d/httpd
#apachectl=/usr/local/apache2/bin/apachectl
#httpd=${HTTPD-/usr/local/apache2/bin/httpd}
#CONFFILE=/usr/local/apache2/conf/httpd.conf
#chmod +x /etc/init.d/httpd
#chmod 700 /etc/init.d/httpd
#设置httpd开机自启动
#chkconfig --add httpd
#chkconfig --level 345 httpd on
#这样,启动、停止、重启Apache就可以用以下方式了:
#/etc/init.d/httpd start
#/etc/init.d/httpd stop
#/etc/init.d/httpd restart
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.local
====================================================================
三、php安装:
yum install libjpeg*
yum install libpng*
tar zxvf php-5.3.3-CP.tar.gz
cd php-5.3.3
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --disable-debug --enable-safe-mode --enable-short-tags --with-gd --with-zlib --with-jpeg-dir --with-png-dir --enable-memory-limit --disable-posix --with-config-file-path=/usr/local/lib --with-mysqli=/usr/local/mysql/bin/mysql_config
make;make install
cp php.ini-proction /usr/local/lib/php.ini
[root@RHEL php-5.2.14]# vi /usr/local/apache2/conf/httpd.conf
在内容里搜一下是否有libphp5.so
我的情况 已经有了 如果没有追加下面那句前面不带#的
# LoadMole foo_mole moles/mod_foo.so
LoadMole php5_mole moles/libphp5.so
#
再搜索AddType关键字 在那附近追加如下一句
AddType application/x-httpd-php .php .phtml
再搜索下面一段 把第二句DirectoryIndex的后面追加index.php
<IfMole dir_mole>
DirectoryIndex index.html index.php
</IfMole>
cd /usr/local/apache2/htdocs/
vi index.php
输入内容
<?php
phpinfo();
?>
vim /etc/selinux/config
注释掉#SELINUX=enforcing 并追加SELINUX=disabled
修改完需重启服务器
[root@RHEL php-5.2.14]# /usr/local/apache2/bin/apachectl restart
不重启:
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache2/moles/libphp5.so
# /usr/local/apache2/bin/apachectl stop
#/usr/local/apache2/bin/apachectl start
# setenforce 1
[root@RHEL mysql]# curl -I http://localhost/index.php
或者你在你的浏览器里输入http://yourip/index.php
vim phpmysql.php
输入内容
<?php
mysql_connect("localhost","root","123456") or die("MySQL First Test:Failed");
echo "MySQL First Test:Success";
?>
因为我们编译php的时候没有加--with-mysqli选项 所以不支持mysqli扩展
[root@RHEL htdocs]# curl http://localhost/phpmysql.php
MySQL First Test:Success
好了 我这里成功了
你可以再浏览器里输入http://ip/phpmysql.php
=============================================================================
四、配置phpMyAdmin
wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.7/phpMyAdmin-3.3.7-all-languages.tar.bz2
cd /root
tar -jxvf phpMyAdmin-3.3.7-all-languages.tar.bz2
test -d /var/www || mkdir -p /var/www #判断是否存在此目录,不存在则创建
mv phpMyAdmin-3.3.7-all-languages /var/www/phpMyAdmin
cp /var/www/phpMyAdmin/config.sample.inc.php /var/www/phpMyAdmin/config.inc.php
vi /var/www/phpMyAdmin/config.inc.php
追加$cfg['Lang'] = 'zh-utf-8';
----------可选设置 为phpMyAdmin设置50位的短语密码---------
yum install expect
[root@RHEL src]# mkpasswd -l 50
nxcayzaoqygmp5e$
复制产生的短语密码
[root@RHEL src]# vi /var/www/phpMyAdmin/config.inc.php
找到如下参数
$cfg['blowfish_secret'] = 'nxcayzaoqygmp5e$'
chown -R root.apache /var/www/phpMyAdmin
cd /usr/local/apache2/conf/
vi extra/phpmyadmin.conf
加入内容
Alias /phpMyAdmin /var/www/phpMyAdmin
<Location /phpMyAdmin>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 10.110.108.55
#这里改成你实际允许访问的ip
</Location>
vi httpd.conf
追加:Include conf/extra/phpmyadmin.conf
/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl start
lsof -i:80
❿ php安装问题
HOHO~!都报库了~!
下载最新的php5.0
实在不行看http://www.kb8.cn/show/?id=328