Linux 下搭建PHP環境(make方法)太麻煩了

載軟件包 
四、下載php 
   us.php.net/get/php-5.3.10.tar.gz/from/cn2.php.net/mirror  php

 http://cn2.php.net/distributions/php-5.6.19.tar.gz html

五、下載cmake(MySQL編譯工具) 
   http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz  java

    https://cmake.org/files/v3.5/cmake-3.5.0.tar.gz mysql

六、下載libmcrypt(PHPlibmcrypt模塊) 
   ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz 
七、下載Zend Guard  (須要註冊)
   http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz  linux

    http://downloads.zend.com/guard/7.0.0/zend-loader-php5.6-linux-x86_64.tar.gz nginx

安裝篇 
如下是用putty工具遠程登陸到服務器,在命令行下面操做的 
1、安裝libmcrypt 
sql

cd /usr/local/src 
tar zxvf  libmcrypt-2.5.7.tar.gz   #解壓 
cd  libmcrypt-2.5.7 #進入目錄 
./configure    #配置 
make           #編譯 
make install   #安裝


2、安裝cmake 
shell

cd /usr/local/src 
tar zxvf cmake-2.8.7.tar.gz 
cd cmake-2.8.7 
./configure 
make           #編譯 
make install   #安裝


3、安裝pcre 
數據庫

 cd /usr/local/src 
 mkdir /usr/local/pcre  #建立安裝目錄 
 tar  zxvf pcre-8.30.tar.gz 
 cd pcre-8.30 
 ./configure  --prefix=/usr/local/pcre  #配置 
 make 
 make install

6、安裝php  api

cd /usr/local/src
tar -zvxf php-5.3.10.tar.gz
cd  php-5.3.10
mkdir -p /usr/local/php5  #創建php安裝目錄
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv  --with-zlib  --enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex  --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl  #配置
make   #編譯
make install    #安裝
cp  php.ini-production   /usr/local/php5/etc/php.ini  #複製php配置文件到安裝目錄
rm -rf /etc/php.ini   #刪除系統自帶配置文件
ln -s /usr/local/php5/etc/php.ini  /etc/php.ini    #添加軟連接
cp  /usr/local/php5/etc/php-fpm.conf.default   /usr/local/php5/etc/php-fpm.conf    #拷貝模板文件爲php-fpm配置文件
vi  /usr/local/php5/etc/php-fpm.conf  #編輯
user = www    #設置php-fpm運行帳號爲www
group = www   #設置php-fpm運行組爲www
pid = run/php-fpm.pid    #取消前面的分號
設置 php-fpm開機啓動
cp /usr/local/src/php-5.3.10/sapi/fpm/init.d.php-fpm   /etc/rc.d/init.d/php-fpm  #拷貝php-fpm到啓動目錄
chmod +x /etc/rc.d/init.d/php-fpm  #添加執行權限
chkconfig php-fpm on    #設置開機啓動
vi /usr/local/php5/etc/php.ini    #編輯配置文件
找到:;open_basedir =
修改成:open_basedir = .:/tmp/   #防止php木馬跨站,重要!!
找到: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,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP能夠禁用的函數,若是某些程序須要用到這個函數,能夠刪除,取消禁用。
找到:;date.timezone =
修改成:date.timezone = PRC   #設置時區
找到:expose_php = On
修改成:expose_php = OFF  #禁止顯示php版本的信息
找到:display_errors = On
修改成:display_errors = OFF  #關閉錯誤提示

7、配置nginx支持php 

vi /usr/local/nginx/conf/nginx.conf
修改/usr/local/nginx/conf/nginx.conf 配置文件,需作以下修改
user   www  www;          #首行user去掉註釋,修改Nginx運行組爲www www;必須與/usr/local/php5/etc/php-fpm.conf中的user,group配置相同,不然php運行出錯
index  index.php  index.html index.htm;    #添加index.php
  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include        fastcgi_params;
  }
#取消FastCGI server部分location的註釋,並要注意fastcgi_param行的參數,改成$document_root$fastcgi_script_name,或者使用絕對路徑
/etc/init.d/nginx restart  #重啓nginx

8、配置php支持Zend Guard 

安裝Zend Guard
cd /usr/local/src
mkdir /usr/local/zend       #創建Zend安裝目錄
tar xvfz ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz  #解壓安裝文件
cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so  /usr/local/zend/  #拷貝文件到安裝目錄
vi /usr/local/php5/etc/php.ini   #編輯文件
在最後位置添加如下內容
[Zend Guard]
zend_extension=/usr/local/zend/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
測試篇
cd  /usr/local/nginx/html/   #進入nginx默認網站根目錄
rm -rf   /usr/local/nginx/html/*   #刪除默認測試頁
vi  index.php  #新建index.php文件
<?php
phpinfo();
?>
:wq!   #保存
chown www.www /usr/local/nginx/html/  -R   #設置目錄全部者
chmod 700 /usr/local/nginx/html/  -R #設置目錄權限
shutdown -r now    #重啓
在客戶端瀏覽器輸入服務器IP地址,能夠看到相關的配置信息!
service nginx restart    #重啓nginx
service mysqld restart   #重啓mysql
/usr/local/php5/sbin/php-fpm   #啓動php-fpm
/etc/rc.d/init.d/php-fpm  restart   #重啓php-fpm
/etc/rc.d/init.d/php-fpm  stop  #中止php-fpm
/etc/rc.d/init.d/php-fpm  start  #啓動php-fpm
#############################################################################
備註:
nginx默認站點目錄是:/usr/local/nginx/html/ 
權限設置:chown www.www  /usr/local/nginx/html/  -R
MySQL數據庫目錄是:/data/mysql
權限設置:chown mysql.mysql -R  /data/mysql



php安裝錯誤configure: error: Please reinstall the libcurl distribu

 (2013-05-03 13:32:04)
分類: Linux

今天配置一臺server的php支持curl的時候, 出現以下報錯

checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/

其實就是curl的dev包沒有安裝, 解決方案:
終端下

# yum -y install curl-devel

而後就能夠繼續了



yum install openssl openssl-devel

ln -s /usr/lib64/libssl.so /usr/lib/

安裝PHP的時候提示這個錯誤 configure: error: png.h not found.,這個是選擇安裝GD模塊纔會出現的錯誤,詳細錯誤信息以下

If configure fails try --with-vpx-dir=<DIR>
If configure fails try --with-jpeg-dir=<DIR>
configure: error: png.h not found.

我找了下資料說是libpng沒有安裝,因而我執行命令 $>yum install libpng 可是並無解決,想了下是否是還有什麼devel包沒安裝吧,試了下面這個命令 $> yum install libpng-devel 終於解決了,呵呵。記錄下來,方便你們和本身下次查看。

相關文章
相關標籤/搜索