centos6.5搭建php
搭建php
centos 6.5 64
php: 5.5.32
三.安裝PHP
先配置本地yum源
安裝依賴包:
yum -y install curl-devel mysql-devel libfreetype6-dev freetype-devel libpng libpng-devel openldap openldap-devel bzip2-devel db4-devel postgresql-devel net-snmp-devel libjpeg-devel libpng-devel libXpm-devel gmp-devel pspell-devel libxslt-devel libc-client-devel openldap-devel libxslt-devel libxml2-devel pcre-devel mysql-develunixODBC-devel
安裝PHP所需依賴包:
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure –prefix=/usr/local
make && make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make && make install
/sbin/ldconfig
cd libltdl/
./configure –enable-ltdl-install
make && make install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make && make install
cd ../
# 對共享庫做符號連結
ln -s /usr/local/lib/libmcrypt.la /usr/lib64/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
ln -sf /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib64/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib64/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib64/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make && make install
cd ../
安裝php:
tar zxvf php-5.5.13.tar.gz
cd php-5.5.13
mkdir /usr/local/php
mkdir /usr/local/php/etc
請核對一下自己的安裝目錄。
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc
–with-mysql=/opt/mysql –with-mysqli=/opt/mysql/bin/mysql_config
–with-iconv-dir –with-freetype-dir –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-fpm –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf
–with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap
–enable-opcache=no –without-pear –disable-fileinfo
列表如下(部分引數未得到解釋):
# 指定 php 安裝目錄
–prefix=/usr/local/php
# 指定php.ini位置
–with-config-file-path=/usr/local/php/etc
# mysql安裝目錄,對mysql的支援
–with-mysql=/usr/local/mysql
mysqli擴充套件技術不僅可以呼叫MySQL的儲存過程、處理MySQL事務,而且還可以使訪問資料庫工作變得更加穩定。
–with-mysqli=/usr/local/mysql/bin/mysql_config
整合 apache,apxs功能是使用mod_so中的LoadModule指令,載入指定模組到 apache,要求 apache 要開啟SO模組
–with-apxs2=/usr/local/apache/bin/apxs
# 選項指令 –with-iconv-dir 用於 PHP 編譯時指定 iconv 在系統裡的路徑,否則會掃描預設路徑。
–with-iconv-dir=/usr/local
#注:如果記憶體較大 可以去掉–disable-fileinfo
make ZEND_EXTRA_LIBS=`-liconv`
make install
cp php.ini-development /usr/local/php/etc/php.ini
cd ../
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
修改
user = nobody
group = nobody
為
user = www
group = www
# 將;pid = run/php-fpm.pid前的;去掉並修改為
pid = /usr/local/php/var/run/php-fpm.pid
啟動php-fpm
/usr/local/php/sbin/php-fpm
將Nginx與fpm加入自啟動
vi /etc/rc.local
# 輸入
ulimit -SHn 65535
/usr/local/php/sbin/php-fpm
/usr/local/nginx/sbin/nginx
編譯PHP擴充套件模組memcache、pdo_mysql、imagick
tar zxvf memcache-3.0.8.tgz
cd memcache-3.0.8
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/opt/mysql
/usr/include/mysql 是mysql的標頭檔案位置
ln -s /usr/include/mysql/* /usr/local/include/
make && make install
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make && make install
cd ../
tar zxvf imagick-3.2.0RC1.tgz
cd imagick-3.2.0RC1
/usr/local/php/bin/phpize
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
./configure –with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
修改php.ini配置檔案
vi /usr/local/php/etc/php.ini
#查詢; extension_dir = “/” 將前面的;去掉並修改為
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/”
#並加入
extension=memcache.so
extension=pdo_mysql.so
extension=imagick.so
執行下面的命令使配置檔案立即生效:
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
其他(可選):
優化linux核心引數
vi /etc/sysctl.conf
在末尾增加以下內容:
# Add
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_recycle = 1
#net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
#net.ipv4.tcp_fin_timeout = 30
#net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024 65535
使配置立即生效:
/sbin/sysctl -p
安裝opcache(因為PHP 5.5已經整合Zend Opcache,可以替代eaccelerator)
tar zxvf zendopcache-7.0.3.tgz
cd zendopcache-7.0.3
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
在php.ini中加入下面配置:
[opcache]
zend_extension=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/opcache.so”
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
# 使php.ini配置檔案立即生效
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
常用命令:
#修改完php.ini後執行:
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
#修改完nginx.conf後執行
/usr/local/nginx/sbin/nginx -s reload
#重啟mysql服務執行:
service mysqld (start|stop|restart)
ln -s /usr/local/php/bin/php /usr/bin/php
連結到/usr/bin下
同樣在slave上按照上面的步驟安裝。
請多指教!
相關文章
- Centos6.5搭建LAMPCentOSLAMP
- CentOS6.5搭建ZabbixCentOS
- centos6.5安裝php5.6.0CentOSPHP
- Centos6.5搭建svn伺服器CentOS伺服器
- Centos6.5搭建java開發環境CentOSJava開發環境
- 5—-CentOS6.5原始碼搭建LAMP–基於module方式實現php(單臺機器)CentOS原始碼LAMPPHP
- 4、CentOS6.5下安裝php5.3CentOSPHP
- centos6.5 unison檔案雙向同步搭建CentOS
- CentOS6.5下搭建NFS檔案伺服器CentOSNFS伺服器
- CentOS6.5 LVS + KeepAlived搭建步驟CentOS
- centos6.5之Zabbix2.2安裝搭建及漢化CentOS
- centos6.5開發環境部署(nignx1.7.10+php5.4.38+mysql+ftp)CentOS開發環境PHPMySqlFTP
- docker搭建php環境DockerPHP
- Mac搭建php+nginxMacPHPNginx
- PHP--環境搭建PHP
- php環境搭建---LAMPPHPLAMP
- PHP基礎教程-03 搭建PHP環境PHP
- PHP-lnmp 環境搭建PHPLNMP
- PHP+sqlserver搭建筆記PHPSQLServer筆記
- Centos下搭建LAMP+PHPCentOSLAMPPHP
- 【LINUX】LINUX PHP搭建LinuxPHP
- 【Nginx】php+nginx快速搭建NginxPHP
- Mac搭建PHP開發環境(PHP+Nginx+MySQL)MacPHP開發環境NginxMySql
- [php]手動搭建php開發環境(排錯)PHP開發環境
- Docker Contos 搭建 PHP 環境DockerPHP
- Mac 搭建 PHP 開發環境MacPHP開發環境
- mac下搭建nginx+php+mysqlMacNginxPHPMySql
- linux 下搭建php環境LinuxPHP
- php環境搭建(windowsphp+apache)PHPWindowsApache
- 在nginx上搭建php服務NginxPHP
- CentOS6.5安裝pipCentOS
- CentOS6.5 安裝opensslCentOS
- CentOS6.5安裝ScrapyCentOS
- Centos6.5 Docker安裝CentOSDocker
- centos6.5安裝gitCentOSGit
- CentOS6.5安裝MongoDBCentOSMongoDB
- CentOS6.5安裝RHBaseCentOS
- CentOS6.5安裝RHiveCentOSHive