當前位置:首頁 » 編程語言 » phpinstallwith

phpinstallwith

發布時間: 2022-10-17 15:42:41

❶ 如何在虛擬機上搭建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

熱點內容
速喵游戲下載為什麼要鎖屏密碼 發布:2024-12-24 11:07:38 瀏覽:336
國家基礎資料庫 發布:2024-12-24 10:58:20 瀏覽:923
python是否是字元串 發布:2024-12-24 10:56:51 瀏覽:524
疫區的消毒應怎麼配置 發布:2024-12-24 10:55:31 瀏覽:241
可樂雲解壓密碼 發布:2024-12-24 10:50:18 瀏覽:759
數據存儲與容災 發布:2024-12-24 10:49:47 瀏覽:597
蘋果安卓哪個好玩 發布:2024-12-24 10:44:00 瀏覽:317
怎麼在電腦上建網站上傳ftp 發布:2024-12-24 10:34:36 瀏覽:777
linux下安裝驅動 發布:2024-12-24 10:33:03 瀏覽:652
什麼人用獨立伺服器 發布:2024-12-24 10:22:09 瀏覽:683