Ⅰ 使用php的exec許可權問題
在php.ini在找到這行
disable_functions
=
exec,system,ini_alter,readlink,symlink,leak,proc_open,popepassthru,chroot,scandir,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,passthru,popen
這些都是禁用的函數,每個函數用逗號分開的,你把exec,刪除了保存就可以了
Ⅱ windows 怎麼支持symlink
一、系統約定篇 環境軟體下載後存放位置:X:\Server_Tools 環境軟體安裝位置:X:\Server_Core PHP安裝位置:X:\Server_Core\PHP MySQL安裝位置:X:\Server_Core\MySQL Zend Optimizer安裝位置:X:\Server_Core\Zend IIS網站站點根目錄:X:\wwwroot MySQL 資料庫位置:X:\Database php.ini存放位置:Y:\Windows\php.ini my.ini 存放位置:X:\Server_Core\MySQL\my.ini 註:X和Y為本標准中的變數,X僅表示應用程序實際存放、安裝的分區盤符,Y為系統所在分區盤符。 二、系統環境檢查以及准備所需軟體篇 1 、檢查系統是否已安裝 IIS 單擊:「開始」-「管理工具」。 2010-7-2 11:00 上傳 下載附件 (868.46 KB) 檢查是否存在「Internet 信息服務(IIS)管理器」
Ⅲ wampserver 修改php.ini配置問題
symlink表示這是一個連接,而不是真正的文件,window下可以理解為快捷方式.
php.ini的路徑應該是php/etc/php.ini之類的,而不會再apache/的目錄下
Ⅳ windows下怎麼安裝php7,php7裡面沒有這個php7apache2
第一步:安裝Apache服務。
在這里主要配置Network Domain、Server Name、Email地址以及Apache服務的佔用埠,默認為80埠,你可以根據需要配置在其他埠,Apache的安裝目錄你可以使用默認目錄或根據需要自行選擇安裝目錄。
在完成apache服務的安裝後,在游覽器中輸入http://localhost/,出現It』s work!字樣,說明Apache服務安裝成功了。
第二步:MySQL的安裝
選擇Custom自定義安裝
點擊「Change」更改你需要的目錄
待文件復制安裝完畢後,進行MySQL設置界面,單擊Finish。
選擇Detailed Configuration進行詳細配置
選擇MySQL運行模式:Server Machine
選擇MySQL資料庫默認存儲方式:Non-Trans Only (MYISAM)
設定MySQL最大連接數:一般設置為128 – 512之間的整數。
設定MySQL網路參數,注意:不要勾選啟用Strict Mode!那個Addfirewall的選項僅在需要外連MySQL的時候勾選上,也就是說給防火牆加個出入站的策略。
設定MySQL默認字元集:以用戶站點語言為准,默認我們填gbk。
Windows環境設定
修改設定root用戶密碼,root密碼請設置的比較復雜些,如果你出現的是三行,第一行的current password不要填寫,留空白
注意:非必要情況下,不要啟動遠程連接模式! 完成MySQL的安裝,並啟動MySQL服務。
完成後,打開cmd命令提示符窗口,輸入命令:mysql –u root –p
輸入剛才安裝時設置的密碼後,如果能夠正常進入MySQL控制台則說明MySQL安裝正常。
更改MySQL資料庫存放目錄(可選,默認是在C:ProgramDataMySQLMySQL Server 5.1data,隱藏目錄)
打開cmd命令提示符窗口,輸入命令:net stop mysql 停止MySQL服務運行;
打開你的mysql安裝目錄的my.ini,
找到:
Datadir = 「XXXXdata」
修改為:
Datadir = 「你需要的mysql安裝目錄,如:F:Database」
將C:ProgramDataMySQLMySQL Server 5.1data 文件夾復制到你修改的Datadir目錄,注意不是作為子目錄,如果你的Datadir寫的是F:Database,那麼你就把C:ProgramDataMySQLMySQL Server 5.1data復制到F盤,然後改名為Database;
打開cmd命令提示符窗口,
輸入命令:net start mysql
啟動MySQL服務。
重新測試MySQL是否工作正常。
第三步:安裝PHP。
其實在Windows 7下進行PHP安裝非常簡單,由於我下的是PHP代碼包,只要解壓php-5.3.2-Win32-VC6-x86並重名為文件夾為php,將其復制到C盤目錄下即可完成PHP安裝。
PHP環境搭建第三步:進行PHP配置環境。
解壓縮下載的php-5.2.8-Win32.zip文件到你指定的目錄
然後修改php.ini
進入PHP文件夾,將php.ini-dist 重命名為php.ini ;
打開php.ini文件,找到:
extension_dir= 「./」
將其改為:
extension_dir= 「你的php解壓目錄ext」
找到:Windows Extensions
在Windows Extensions下方的動態模塊配置中,需要打開以下模塊支持:(去掉模塊配置每行前面的分號即可)
php_curl.dll
php_pdo_mysql.dll
php_gd2.dll
php_mbstring.dll
php_mcrypt.dll
php_mhash.dll
php_ming.dll
php_mysql.dll
php_openssl.dll
php_sockets.dll
php_xmlrpc.dll
php_zip.dll
找到:
disable_functions=
改為:
disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
保存php.ini文件,並將其復制到Y:Windows,然後把php文件夾下的libmysql.dll復制到C:WindowsSystem32目錄下。
接著配置PHP的Session功能(可選)
在使用session功能時,我們必須配置session文件在伺服器上的保存目錄,否則無法使用session,我們需要在Windows 7上新建一個可讀寫的目錄文件夾,此目錄最好獨立於WEB主程序目錄之外,此處我在D盤根目錄上建立了phpsessiontmp目錄,然後在php.ini配置文件中找到
;session.save_path = 「/tmp」
修改為
session.save_path = 「D:/phpsessiontmp」
配置PHP的文件上傳功能 (可選)
同session一樣,在使用PHP文件上傳功能時,我們必須要指定一個臨時文件夾以完成文件上傳功能,否則文件上傳功能會失敗,我們仍然需要在Windows 7上建立一個可讀寫的目錄文件夾,此處我在D盤根目錄上建立了phpfileuploadtmp目錄,然後在php.ini配置文件中找到
;upload_tmp_dir =
修改為
upload_tmp_dir = 「D:/phpfileuploadtmp」
第五步:配置Apache以支持PHP
1、打開你的apache2的安裝目錄,找到conf文件,打開裡面的httpd.conf
在#LoadMole vhost_alias_mole moles/mod_vhost_alias.so下添加
復制代碼
代碼如下:
LoadMole php5_mole "你的php安裝目錄/php5apache2_2.dll"
PHPIniDir "c:/Windows" (因為把php.ini復制到了C:/Windows目錄中了)
AddType application/x-httpd-php .php .html .htm
我們在PHP目錄下可以看到多個php5apache的DLL文件,由於我們使用的是Apache2.2.15,所以我們當然需要使用php5apache2_2.dll,接著指定PHP的安裝目錄以及執行的程序擴展名。
2、我們應該知道默認Apache伺服器執行WEB主程序的目錄為Apache2.2/htdocs,所以當你的WEB主程序目錄變更時,我們需要修改相應的Apache配置,即將
復制代碼
代碼如下:
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
修改為
復制代碼
代碼如下:
DocumentRoot "D:/PHPWeb(目錄自己定,我這是隨便寫的)"
還有
復制代碼
代碼如下:
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
修改為
<Directory "D:/PHPWeb(目錄自己定,我這是隨便寫的)">
最後修改具體的index文件先後順序,由於配置了PHP功能,當然需要index.php優先執行
DirectoryIndex index.html
修改為
DirectoryIndex index.php index.html
最後重啟Apache伺服器
在一切工作完成後,在你剛才指定的工作目錄中(D:/PHPWeb)新建php文件,輸入以下內容
復制代碼
代碼如下:
<?
phpinfo();
?>
保存,在瀏覽器中輸入http://localhost/剛才新建的php文件名.php,如果出現php信息的話,就說明成功了。然後是資料庫的鏈接,把剛才建的php文件的內容替換為
復制代碼
代碼如下:
<?php
$connect=mysql_connect(「127.0.0.1″,」root」,」你的mysql資料庫密碼」);
if(!$connect) echo 「Mysql Connect Error!」;
else echo 「歡迎我的博客-www.aitilife.com」;
mysql_close();
?>
Ⅳ WindowsServer2003中IIS支持php的配置
確定你下載的PHP和MYSQL都是相應你系統能用的(我一般用的版本如下,其實配置都一樣,無所謂的
MySQL-essential-5.0.45-win32.msi
php-5.2.4-Win32.zip)
1.安裝MySQL(沒有特殊說明的就按照默認安裝)
選擇 Custom 自定義安裝
點擊"Change"更改 MySQL 安裝目錄(自定義)
其他按照默認的下一步就可以
安裝完成後會自動跳轉到設置界面,選擇 Detailed Configuration 進行詳細配置
選擇 MySQL 運行模式:Server Machine
選擇 MySQL 資料庫默認存儲方式:Non-Trans Only ( MYISAM)
設定 MySQL 最大連接數:一般設置為 128 - 512 之間的整數
設定 MySQL 網路參數,注意:不要啟用 Strict Mode!
設定 MySQL 默認字元集:以用戶站點語言為准(一般GBK)
Windows 環境設定,三個都勾上,service name是MySQL
接下來設置root用戶密碼,按需求是否啟用遠程用戶(Enable root access from remote...),如果只是本機訪問的話就別勾了,更安全
最後,完成 MySQL 的安裝和配置,會自動啟動 MySQL 服務。
測試 MySQL 工作是否正常:
打開 cmd 命令提示符窗口,輸入命令:MySQL –u root –p 輸入密碼後,如果能夠正常進入 MySQL 控制台則說明 MySQL 安裝正常。(注意,-p和密碼之間沒空格)
2.安裝 PHP:(我默認安裝在D:\PHP下,可按需求更改)
(1) 解壓縮下載的 php-5.2.4-Win32.zip 文件,並將其復制到: D:\PHP ;
(2) 進入 D:\PHP文件夾,將 php.ini-dist 重命名為 php.ini ;
(3) 打開 php.ini 文件,找到:extension_dir = "./" 將其改為;
extension_dir = " D:\PHP\ext"
(4) 找到:Windows Extensions
在 Windows Extensions 下方的動態模塊配置中,需要打開以下模塊支持:(去掉模塊配置每行前面的;號即可)
extension=php_mbstring.dll
extension=php_gd2.dll
extension=php_MySQL.dll
(5) 找到:
disable_functions =
改為:
disable_functions = phpinfo,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
(6) 保存 php.ini 文件,並將其復制到 C:\Windows\
PHP按此安裝可以滿足絕大部分建站需求。如果有特殊需要請自行查閱PHP模塊(extension)的相關資料
3. IIS 新建一個站點(這部分不仔細闡明了,沒什麼要點,只是要注意需要給予該站點"讀取"和"運行腳本"的許可權)
4.IIS 與 PHP 的整合配置 - 使站點支持 PHP(這個是重點)
(1) 右鍵打開剛剛建立的網站屬性,
(2) 在站點屬性窗口中,單擊"主目錄"頁簽,單擊"配置"按鈕,在新彈出的"應用程序配置"對話框中,單擊"添加"按鈕,加入 PHP 的 ISAPI 支持,選擇可執行文件:D:\PHP\php5isapi.dll 、擴展名為 .php 、限制動作為:GET,POST 。單擊"確定"添加,並在"應用程序配置"窗口中查看 .php 擴展是否載入成功。若成功,則單擊"確定"關閉配置窗口,回到站點屬性主窗口。【這步比較重要】
(3) 單擊"文檔"頁簽,在默認內容文檔中添加 index.htm、index.html、index.php 三個文件,並將所有默認文檔排序,順序按照下圖所示。完成後,單擊"確定",關閉站點屬性配置窗口,回到 IIS 管理器主界面。
(4) 右鍵單擊"Web 服務擴展",添加一個新的web服務擴展,添加 PHP 擴展支持。
(5) 在"新建WEB服務擴展"對話框中,"擴展名"填寫PHP,"文件"選擇 D:\PHP\php5isapi.dll ,並設置該PHP擴展默認為允許。
(6) 重啟 IIS 服務
5、測試 PHP 支持是否正常
IIS與PHP的整合已經完畢,下面需要測試 PHP 支持是否正常。
在你的網站根目錄下新建一個phpinfo.php文件,用記事本編輯,內容為
<?php
phpinfo();
?>
然後嘗試訪問該頁面。
如果能夠正常顯示PHP支持信息則表明配置整合是成功的。
至此 全部配置完畢
Ⅵ PHP語言有更新過嗎
PHP是一種新型的CGI程序編寫語言,易學易用,運行速度快,可以方便快捷地編寫出功能強大,運行速度快,並可同時運行於 Windows、Unix、linux平台的Web後台程序,內置了對文件上傳、密碼認證、Cookies操作、郵件收發、動態GIF生成等功能,PHP 直接為很多資料庫提供原本的連接,包括Oracle、Sybase、Postgres、Mysql、Informix、Dbase、Solid、 Access等,完全支持ODBC介面,用戶更換平台時,無需變換PHP代碼,可即拿即用. Version 5.2.5 08-November-2007 * Security Fixes o Fixed dl() to only accept filenames. reported by Laurent Gaffie. o Fixed dl() to limit argument size to MAXPATHLEN (CVE-2007-4887). o Fixed htmlentities/htmlspecialchars not to accept partial multibyte sequences. o Fixed possible triggering of buffer overflows inside glibc implementations of the fnmatch(), setlocale() and glob() functions. Reported by Laurent Gaffie. o Fixed "mail.force_extra_parameters" php.ini directive not to be modifiable in .htaccess e to the security implications reported by SecurityReason. o Fixed bug #42869 (automatic session id insertion adds sessions id to non-local forms). o Fixed bug #41561 (Values set with php_admin_* in httpd.conf can be overwritten with ini_set()). * Upgraded PCRE to version 7.3 (Nuno) * Added optional parameter $provide_object to debug_backtrace(). (Sebastian) * Added alpha support for imagefilter() IMG_FILTER_COLORIZE. (Pierre) * Added ability to control memory consumption between request using ZEND_MM_COMPACT environment variable. (Dmitry) * Improved speed of array_intersect_key(), array_intersect_assoc(), array_uintersect_assoc(), array_diff_key(), array_diff_assoc() and array_udiff_assoc(). (Dmitry) * Fixed move_uploaded_file() to always set file permissions of resulting file according to UMASK. (Andrew Sitnikov) * Fixed possible crash in ext/soap because of uninitialized value. (Zdash Urf) * Fixed regression in glob() when enforcing safe_mode/open_basedir checks on paths containing '*'. (Ilia) * Fixed PDO crash when driver returns empty LOB stream. (Stas) * Fixed iconv_*() functions to limit argument sizes as workaround to libc bug (CVE-2007-4783, CVE-2007-4840 by Laurent Gaffie). (Christian Hoffmann, Stas) * Fixed missing brackets leading to build warning and error in the log. Win32 code. (Andrey) * Fixed leaks with multiple connects on one mysqli object. (Andrey) * Fixed endianness detection on MacOS when building universal binary. (Uwe Schindler, Christian Speich, Tony) * Fixed imagerectangle regression with 1x1 rectangle (libgd #106). (Pierre) * Fixed bug #43196 (array_intersect_assoc() crashes with non-array input). (Jani) * Fixed bug #43139 (PDO ignores ATTR_DEFAULT_FETCH_MODE in some cases with fetchAll()). (Ilia) * Fixed bug #43137 (rmdir() and rename() do not clear statcache). (Jani) * Fixed bug #43130 (Bound parameters cannot have - in their name). (Ilia) * Fixed bug #43099 (XMLWriter::endElement() does not check # of params). (Ilia) * Fixed bug #43020 (Warning message is missing with shuffle() and more than one argument). (Scott) * Fixed bug #42976 (Crash when constructor for newInstance() or newInstanceArgs() fails) (Ilia) * Fixed bug #42943 (ext/mssql: Move *timeout initialization from RINIT to connect time). (Ilia) * Fixed bug #42917 (PDO::FETCH_KEY_PAIR doesn't work with setFetchMode). (Ilia) * Fixed bug #42890 (Constant "LIST" defined by mysqlclient and c-client). (Andrey) * Fixed bug #42818 ($foo = clone(array()); leaks memory). (Dmitry) * Fixed bug #42817 (clone() on a non-object does not result in a fatal error). (Ilia) * Fixed bug #42785 (json_encode() formats doubles according to locale rather then following standard syntax). (Ilia) * Fixed bug #42783 (pg_insert() does not accept an empty list for insertion). (Ilia) * Fixed bug #42773 (WSDL error causes HTTP 500 Response). (Dmitry) * Fixed bug #42772 (Storing $this in a static var fails while handling a cast to string). (Dmitry) * Fixed bug #42767 (highlight_string() truncates trailing comment). (Ilia) * Fixed bug #42739 (mkdir() doesn't like a trailing slash when safe_mode is enabled). (Ilia) * Fixed bug #42703 (Exception raised in an iterator::current() causes segfault in FilterIterator) (Marcus) * Fixed bug #42699 (PHP_SELF plicates path). (Dmitry) * Fixed bug #42654 (RecursiveIteratorIterator modifies only part of leaves) (Marcus) * Fixed bug #42643 (CLI segfaults if using ATTR_PERSISTENT). (Ilia) * Fixed bug #42637 (SoapFault : Only http and https are allowed). (Bill Moran) * Fixed bug #42629 (Dynamically loaded PHP extensions need symbols exported on MacOSX). (jdolecek at NetBSD dot org) * Fixed bug #42627 (bz2 extension fails to build with -fno-common). (dolecek at netbsd dot org) * Fixed bug #42596 (session.save_path MODE option does not work). (Ilia) * Fixed bug #42590 (Make the engine recognize \v and \f escape sequences). (Ilia) * Fixed bug #42587 (behavior change regarding symlinked .php files). (Dmitry) * Fixed bug #42579 (apache_reset_timeout() does not exist). (Jani) * Fixed bug #42549 (ext/mysql failed to compile with libmysql 3.23). (Scott) * Fixed bug #42523 (PHP_SELF plicates path). (Dmitry) * Fixed bug #42512 (ip2long('255.255.255.255') should return 4294967295 on 64-bit PHP). (Derick) * Fixed bug #42506 (php_pgsql_convert() timezone parse bug) (nonunnet at gmail dot com, Ilia) * Fixed bug #42462 (Segmentation when trying to set an attribute in a DOMElement). (Rob) * Fixed bug #42453 (CGI SAPI does not shut down cleanly with -i/-m/-v cmdline options). (Dmitry) * Fixed bug #42452 (PDO classes do not expose Reflection API information). (Hannes) * Fixed bug #42468 (Write lock on file_get_contents fails when using a compression stream). (Ilia) * Fixed bug #42488 (SoapServer reports an encoding error and the error itself breaks). (Dmitry) * Fixed bug #42378 (mysqli_stmt_bind_result memory exhaustion). (Andrey) * Fixed bug #42359 (xsd:list type not parsed). (Dmitry) * Fixed bug #42326 (SoapServer crash). (Dmitry) * Fixed bug #42214 (SoapServer sends clients internal PHP errors). (Dmitry) * Fixed bug #42189 (xmlrpc_set_type() crashes php on invalid datetime values). (Ilia) * Fixed bug #42139 (XMLReader option constants are broken using XML()). (Rob) * Fixed bug #42086 (SoapServer return Procere '' not present for WSIBasic compliant wsdl). (Dmitry) * Fixed bug #41822 (Relative includes broken when getcwd() fails). (Ab5602, Jani) * Fixed bug #39651 (proc_open() append mode doesn't work on windows). (Nuno 以上 是 找來的 就我而言 目前來說 完善的更新還 沒出 但一直在討論階段 以上 只代表個人觀點
Ⅶ 打開php.ini中的Safe_mode,會影響哪些參數至少說出6個。
system,passthru,exec,shell_exec,popen,phpinfo等等大部分的文件操作函數。
因為Safe_mode是php非常重要的內嵌的安全機制。默認是關閉的。
Ⅷ 如何在linux系統下打造適合自己的PHP開發環境
一、系統約定
軟體源代碼包存放位置:/usr/local/src
源碼包編譯安裝位置(prefix):/usr/local/software_name
腳本以及維護程序存放位置:/usr/local/sbin
MySQL 資料庫位置:/var/lib/MySQL(可按情況設置)
Apache 網站根目錄:/home/www/wwwroot(可按情況設置)
Apache 虛擬主機日誌根目錄:/home/www/logs(可按情況設置)
Apache 運行賬戶:www:www
二、系統環境部署及調整
1. 檢查系統是否正常
1
2
3
4
# more /var/log/messages(檢查有無系統級錯誤信息)
# dmesg(檢查硬體設備是否有錯誤信息)
# ifconfig(檢查網卡設置是否正確)
# ping www.163.com(檢查網路是否正常)
2. 關閉不需要的服務
1
2
3
4
5
6
7
8
9
10
# ntsysv
以下僅列出需要啟動的服務,未列出的服務一律推薦關閉:
atd
crond
irqbalance
microcode_ctl
network
sendmail
sshd
syslog
3. 重新啟動系統
1
# init 6
4. 配置 vim
1
# vi /root/.bashrc
在 alias mv='mv -i' 下面添加一行:alias vi='vim' 保存退出。
1
# echo 'syntax on' > /root/.vimrc
5. 使用 yum 程序安裝所需開發包(以下為標準的 RPM 包名稱)
1
2
# yum install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex
bison autoconf automake bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel kerne
6. 定時校正伺服器時鍾,定時與中國國家授時中心授時伺服器同步
1
# crontab -e
加入一行:
1
*/30 * * * * ntpdate 210.72.145.44
7. 源碼編譯安裝所需包 (Source)
需要下載的文件
1
2
3
4
5
6
7
gd-2.0.34.tar.gz
libxml2-2.6.30.tar.bz2
libmcrypt-2.5.8.tar.bz2
cronolog-1.7.0-beta.tar.gz
openssl-0.9.8e.tar.gz (可選)
openssl-0.9.8e.tar.gz (可選)
7.1 GD2
1
2
3
4
5
6
# cd /usr/local/src
# tar xzvf gd-2.0.34.tar.gz
# cd gd-2.0.34
# ./configure --prefix=/usr/local/gd2
# make
# make install
7.2 LibXML2
1
2
3
4
5
6
# cd /usr/local/src
# tar xjvf libxml2-2.6.30.tar.bz2
# cd libxml2-2.6.30
# ./configure --prefix=/usr/local/libxml2
# make
# make install
7.3 LibMcrypt
1
2
3
4
5
6
# cd /usr/local/src
# tar xjvf libmcrypt-2.5.8.tar.bz2
# cd libmcrypt-2.5.8
# ./configure –prefix=/usr/local/libmcrypt
# make
# make install
7.4 Apache日誌截斷程序
1
2
3
4
5
6
# cd /usr/local/src
# tar xzvf cronolog-1.7.0-beta.tar.gz
# cd cronolog-1.7.0-beta
# ./configure –prefix=/usr/local/cronolog
# make
# make install
8. 升級OpenSSL和OpenSSH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# cd /usr/local/src
# tar xzvf openssl-0.9.8e.tar.gz
# cd openssl-0.9.8e
# ./config --prefix=/usr/local/openssl
# make
# make test
# make install
# cd ..
# tar xzvf openssh-4.7p1.tar.gz
# cd openssh-4.7p1
# ./configure \
"--prefix=/usr" \
"--with-pam" \
"--with-zlib" \
"--sysconfdir=/etc/ssh" \
"--with-ssl-dir=/usr/local/openssl" \
"--with-md5-passwords"
# make
# make install
(1)禁用 SSH V1 協議 找到:
1
#Protocol 2,1
改為:
1
Protocol 2
(2)禁止root直接登錄,此處先建立一個普通系統用戶:
1
2
# useradd username
# passwd username
找到:
1
#PermitRootLogin yes
改為:
1
PermitRootLogin no
(3)禁用伺服器端GSSAPI,找到以下兩行,並將它們注釋:
1
2
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
(4)禁用 DNS 名稱解析,找到:
1
#UseDNS yes
改為:
1
UseDNS no
(5)禁用客戶端 GSSAPI
1
# vi /etc/ssh/ssh_config
找到:
1
GSSAPIAuthentication yes
將這行注釋掉。
最後,確認修改正確後重新啟動 SSH 服務
1
2
# service sshd restart
# ssh -v
確認 OpenSSH 以及 OpenSSL 版本正確。
三、編譯安裝L.A.M.P環境
1. 下載軟體
1
# cd /usr/local/src
下載文件mysql,apache,php,請到下面網址下載相應軟體
1
2
3
http://www.apache.org/ (推薦版本:2.2.21)
http://www.php.net/ (推薦版本:5.2.17)
http://www.mysql.com/
2. 編譯安裝MySQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# tar xzvf MySQL-5.0.45-linux-i686-glibc23.tar.gz
# mv MySQL-5.0.45-linux-i686-glibc23 /usr/local/
# ln -s /usr/local/ MySQL-5.0.45-linux-i686-glibc23 /usr/local/MySQL
# useradd MySQL
# chown -R MySQL:root /usr/local/MySQL/
# cd /usr/local/MySQL
# ./scripts/MySQL_install_db --user=MySQL
# cp ./support-files/MySQL.server /etc/rc.d/init.d/MySQLd
# chown root:root /etc/rc.d/init.d/MySQLd
# chmod 755 /etc/rc.d/init.d/MySQLd
# chkconfig --add MySQLd
# chkconfig --level 3 5 MySQLd on
# cp ./support-files/my-huge.cnf /etc/my.cnf
# mv /usr/local/MySQL/data /var/lib/MySQL
# chown -R MySQL:MySQL /var/lib/MySQL/
# vi /etc/my.cnf
3. 編譯安裝Apache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# cd /usr/local/src
# tar xjvf httpd-2.2.21.tar.bz2
# cd httpd-2.2.21
# ./configure \
"--prefix=/usr/local/apache2" \
"--with-included-apr" \
"--enable-so" \
"--enable-deflate=shared" \
"--enable-expires=shared" \
"--enable-rewrite=shared" \
"--enable-static-support" \
"--disable-userdir"
# make
# make install
# echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.local
4. 編譯安裝PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# cd /usr/local/src
# tar xjvf php-5.2.17.tar.bz2
# cd php-5.2.17
# ./configure \
"--prefix=/usr/local/php" \
"--with-apxs2=/usr/local/apache2/bin/apxs" \
"--with-config-file-path=/usr/local/php/etc" \
"--with-MySQL=/usr/local/MySQL" \
"--with-libxml-dir=/usr/local/libxml2" \
"--with-gd=/usr/local/gd2" \
"--with-jpeg-dir" \
"--with-png-dir" \
"--with-bz2" \
"--with-freetype-dir" \
"--with-iconv-dir" \
"--with-zlib-dir " \
"--with-openssl=/usr/local/openssl" \
"--with-mcrypt=/usr/local/libmcrypt" \
"--enable-soap" \
"--enable-gd-native-ttf" \
"--enable-ftp" \
"--enable-mbstring" \
"--enable-exif" \
"--disable-ipv6" \
"--disable-cgi" \
"--disable-cli"
# make
# make install
# mkdir /usr/local/php/etc
# cp php.ini-dist /usr/local/php/etc/php.ini
5. 整合Apache與PHPP
1
# vi /usr/local/apache2/conf/httpd.conf
找到:
1
AddType application/x-gzip .gz .tgz
在該行下面添加
1
AddType application/x-httpd-php .php
找到:
1
DirectoryIndex index.html
將該行改為
1
DirectoryIndex index.html index.htm index.php
找到:
1
2
3
4
#Include conf/extra/httpd-mpm.conf
#Include conf/extra/httpd-info.conf
#Include conf/extra/httpd-vhosts.conf
#Include conf/extra/httpd-default.conf
去掉前面的「#」號,取消注釋。注意:以上 4 個擴展配置文件中的設置請按照相關原則進行合理配置!修改完成後保存退出。
1
# /usr/local/apache2/bin/apachectl restart
6. 查看確認L.A.M.P環境信息、提升 PHP 安全性
在網站根目錄放置 phpinfo.php 腳本,檢查phpinfo中的各項信息是否正確。
確認 PHP 能夠正常工作後,在 php.ini 中進行設置提升 PHP 安全性。
1
# vi /etc/php.ini
找到:
1
disable_functions =
設置為:
1
2
phpinfo,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,
ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
Ⅸ 如何在linux下安裝多個不同版本的PHP
Linux下部署php多版本共存
背景說明
自php7問世,身為最新版本控的我馬上升級體驗,但是由於伺服器上還有舊程序在運行,只好部署一個php多版本共存環境。
現有環境是lnmp
- CentOS 6.7
- nginx 1.10.1
- mariadb-10.0.26
- php 7.0.8
為了更好兼容舊的php程序,推薦使用5.4.45. 主要是兼容mysql擴展。
開始安裝
首先要下載php-5.4.45.tar.gz源碼包。
通過源碼安裝
# tar xzvf php-5.4.45.tar.gz
# cd php-5.4.45
# ./configure --prefix=/usr/local/php54 --with-config-file-path=/usr/local/php54/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-intl --with-xsl
# make ZEND_EXTRA_LIBS='-liconv'
# make install
# cp php.ini-proction /usr/local/php/etc/php.ini
------------------------------------------------------------------------------------------------
php.ini 配置
post_max_size = 50M
upload_max_filesize = 50M
date.timezone = PRC
short_open_tag = On
cgi.fix_pathinfo=0
max_execution_time = 300
disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
------------------------------------------------------------------------------------------------
php-fpm.conf 配置
------------------------------
# vim /usr/local/php/etc/php-fpm.conf1
[global]
pid = /usr/local/php54/var/run/php-fpm.pid
error_log = /usr/local/php54/var/log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php54-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1:9001
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 40
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 40
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log
----------------------------------------------------------------------------------
啟動 php-fpm
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php54-fpm
# chmod +x /etc/init.d/php54-fpm
# /etc/init.d/php54-fpm start
-------------------------------------------------------------------------------------------
修改nginx配置,對需要的服務配置使用php-5.4.45
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php54-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
----------------------------------------------------------------------------------------
配置php-5.4.45 的php54-fpm 開機自動啟動
# chkconfig --add php54-fpm
# chkconfig php54-fpm on
Ⅹ 如何查看symlink 文件 目標路徑
一、系統約定篇 環境軟體下載後存放位置:X:\Server_Tools 環境軟體安裝位置:X:\Server_Core PHP安裝位置:X:\Server_Core\PHP MySQL安裝位置:X:\Server_Core\MySQL Zend