標籤:關閉selinux hash gre ash zlib log echo 成功 bst
php
1.下載解壓
cd /usr/local/srcwget http://mirrors.sohu.com/php/php-5.6.9.tar.gztar zxvf php-5.6.9.tar.gzcd php-5.6.9
2.編譯安裝
./configure --with-apr=/usr/local/apr --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 --with-gd --with-jpeg-dir
--with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-mcrypt --with-openssl --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
編譯來至(全)http://blog.csdn.net/godmatrix/article/details/5969558./configure 配置,安裝--with-apr=/usr/local/apr \ 指定apr代碼的目錄 --prefix=/usr/local/php \ 指定php安裝目錄.--with-apxs2=/usr/local/apache2/bin/apxs 讓Apache伺服器能夠支援PHP。整合 apache,apxs功能是使用mod_so中的LoadModule指令,載入指定模組到 apache,要求 apache 要開啟SO模組--with-config-file-path=/usr/local/php/etc 指定php.ini設定檔的位置 --with-mysql=/usr/local/mysql MySQL安裝的目錄,對mysql的支援 --with-libxml-dir 開啟對libxml2庫的支援 --with-gd 開啟對gd庫的支援 --with-jpeg-dir --with-png-dir 開啟對jpeg圖片和png圖片的支援 --with-freetype-dir 開啟對freetype字型庫的支援 --with-iconv-dir 開啟對iconv函數庫,種字元集間的轉換 --with-zlib-dir 開啟對zlib庫的支援 --with-bz2 開啟對bz2檔案的支援 --with-openssl 開啟openssl的支援,加密傳輸時用到的 --with-mcrypt 演算法,mhash和mcrypt都是演算法的擴充 --enable-soap 開啟soap的支援 --enable-gd-native-ttf 支援True Type 字串 函數庫 --enable-mbstring 多位元組,字串的支援 --enable-sockets 開啟sockets支援 --enable-exif 圖片的中繼資料支援 --disable-ipv6不支援ipv6
錯誤1
configure: error: xml2-config not found. Please check your libxml2 installation.配置:錯誤:xml2-config不見了。請檢查你的libxml2安裝。解決:yum install libxml2 libxml2-devel -y
錯誤2
configure: error: Cannot find OpenSSL’s <evp.h>配置:錯誤:找不到OpenSSL的< evp.h >解決:yum install openssl openssl-devel -y
錯誤3
Configure: error: Please reinstall the BZip2 distribution配置:錯誤:請重新安裝BZip2分布解決:yum install bzip2 bzip2-devel -y
錯誤4
configure: error: jpeglib.h not found.配置:錯誤:jpeglib。沒有找到。解決:yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y
錯誤5
Configure: error: mcrypt.h not found. Please reinstall libmcrypt.配置:錯誤:mcrypt。沒有找到。請重新安裝libmcrypt。解決:安裝epel-release源 yum install epel-release -yyum install libmcrypt-devel -y
最後執行
makemake install
3.拷貝PHP主設定檔
cp php.ini-production /usr/local/etc/php.ini
4.修改apache的設定檔,使apache支援解析php
vim /usr/local/apache2/conf/httpd.conf
1.找到#ServerName www.example.com:80改為
ServerName www.example.com:80
2.找到
<Directory /> AllowOverride none Require all denied </Directory>
改為
<Directory /> Options FollowSymLinks AllowOverride none Order deny,allow Allow from all </Directory>
3.找到
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
改為
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
4.找到
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
改為
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
註:
1.ServerName www.example.com:80 開啟伺服器佔用80連接埠
2.Allow from all 允許訪問web內容目錄
3.DirectoryIndex index.html index.php 目錄索引支援php
4. AddType application/x-httpd-php .php 應用類型支援php
5.檢查設定檔是否錯誤
/usr/local/apache2/bin/apachectl -t
6.啟動apache服務
/usr/local/apache2/bin/apachectl start
7.查看進程
ps aux |grep httpd
8.關閉防火牆。
永久關閉SElinux,重啟生效。
vim /etc/selinux/config
找到SELINUX=enforcing改為SELINUX=disabled臨時關閉 setenforce 0getenforce 查看當前SElinux防火牆狀態 setenforce 0 是臨時關閉 setenforce 1 是臨時開啟# enforcing - SELinux security policy is enforced.開啟# permissive - SELinux prints warnings instead of enforcing.開啟不攔截# disabled - No SELinux policy is loaded.關閉,預設
9.清空iptables規則
iptables -F service iptables save
10.瀏覽器訪問IP
是否顯示 it works!顯示說明成功。
11.測試解析php
cd /usr/local/apache2/htdocs
php主設定檔vim /usr/local/apache2/conf/httpd.conf指定的主目錄的路徑DocumentRoot"/usr/local/apache2/htdocs"
touch 1.txt echo ‘qqqqq‘ >> 1.txthttp://192.168.1.116/1.txtvim 2.php<?phpphpinfo();?>http://192.168.1.116/2.php
儲存鏡像4.備忘php安裝ok
php安裝成功
php安裝包:連結:http://pan.baidu.com/s/1nvbrFJF 密碼:sy20
Linux下apache安裝php