您好,登錄后才能下訂單哦!
原有的項目都為java項目 所以現有的環境為nginx+tomcat
現在要添加一個php環境
在編譯安裝php前,要先查看下nginx的運行用戶,php也用用同樣的用戶
編譯安裝php
根據自己想需求選擇相應的軟件環境
for packages in patch make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap;do yum -y install $packages; done
在這里我選擇php5.3的版本
wget -c http://soft.vpser.net/web/php/php-5.3.17.tar.gz
選擇php5.3版本編譯mysql時不需要指定mysql路徑,可用以下參數進行編譯
--with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-mysql=mysqlnd
開始編譯
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=nobody --with-fpm-group=nobody --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --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 --without-pear --with-gettext --disable-fileinfo
編譯完后
make&&make install
編譯時報錯信息及解決方法
在Linux下安裝PHP過程中,編譯時出現configure: error: libjpeg.(a|so) not found 錯誤的解決辦法
檢查之后發現已經安裝了libjpeg,但是在/usr/lib目錄下沒有libjpeg.so這個文件,在/usr/lib64下是有的
所以建立個軟鏈接
ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
問題解決, libpng 報的錯誤解決方法一樣
ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
configure: error: freetype.h not found.
gamedb:/data/soft/php-5.2.17 # zypper install freetype2-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
gamedb:/data/soft/php-5.2.17 # zypper install libmcrypt libmcrypt-devel
configure: error: Please reinstall libmhash - I cannot find mhash.h
gamedb:/data/soft/php-5.2.17 # zypper install mhash-devel
拷貝配置文件到安裝目錄中
cp php-5.3.17/php.ini-production /usr/local/php/etc/php.ini
配置文件放錯位置的話也會導致項目異常
cd /usr/local/php/etc/ # 切換到安裝目錄下的配置文件目錄 cp php-fpm.conf.default php-fpm.conf
vi php-fpm.conf
啟用如下幾行,即去掉前面的分號(;)
pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = notice listen = 127.0.0.1:9000 listen.allowed_clients = 127.0.0.1 pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500 env[HOSTNAME] = $HOSTNAME env[PATH] = /usr/local/bin:/usr/bin:/bin env[TMP] = /tmp env[TMPDIR] = /tmp env[TEMP] = /tmp
wq保存退出
# /usr/local/php/sbin/php-fpm (啟動PHP)
# netstat -antpl (如果看到9000端口,PHP-FPM配置成功)
注意:如果修改php.ini文件,則需要重啟php-fpm進程使生效。
最后配置項目的nginx的配置文件使php和nginx鏈接
gamedb:/opt/nginx/conf/vhost # cat gzqq_2014.conf server { listen 81; server_name www.abc.net; index index.php index.html index.htm; root /data/web/abc/default; #root /data/web/abc; location ~ .*\.(php|php5)?$ { try_files $uri =404; #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fcgi.conf; } location /status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } #access_log /home/wwwlogs/access.log access; #error_log /home/wwwlogs/qzqq_erro.log; }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。