1、安裝各類軟件包php
yum -y install wget git vim lrzsz unzip zip gcc make gd-devel bzip2 bzip2-devel libcurl libcurl-devel zlib zlib-devel gcc-c++ libtoolmysql
yum -y install openssl openssl-devel curl curl-devel icu libicu libicu-devel libmcrypt-devel libxslt-devel epel-releasenginx
yum -y install cmake bison libicu-devel libjpeg libjpeg-devel libpng libpng-devel libxml2 libxml2-develc++
yum -y install gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel ncurses ncurses-develgit
yum -y install autoconf gd-devel freetype freetype-develgithub
2、源碼安裝Nginxredis
cd /usr/local/src
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module
make && make installsql
/usr/sbin/groupadd www 建立Nginx用戶組vim
/usr/sbin/useradd -g www www -s /sbin/nologin 建立Nginx用戶並指定用戶組curl
/usr/local/nginx/sbin/nginx 啓動nginx
3、源碼安裝php
cd /usr/local/src
上傳已經下載好的PHP源碼包到/usr/local/src目錄下,個人PHP版本是5.5.36
tar zxvf php-5.5.36.tar.gz
cd php-5.5.36
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/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-opcache --enable-intl --with-xsl
make && make install
cd /usr/local/php/etc
mv php-fpm.conf.default php-fpm.conf 將默認配置文件重命名爲php-fpm.conf,內容根據本身的實際狀況修改,如下是個人內容,能夠先truncate -s 0 php-fpm.conf把內容清空再寫入本身想要的內容
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1:9000
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 9
request_terminate_timeout = 9000
request_slowlog_timeout = 0
slowlog = /var/log/slow.log
別忘了php.ini文件
/usr/local/php/sbin/php-fpm #########啓動php
ps -ef |grep php 能夠看到php-fpm已經在正常運行了
###########nginx和PHP都安裝好了,接下來就是一堆擴展件的安裝了###########
1、源碼安裝memcache
cd /usr/local/src/
wget http://pecl.php.net/get/memcache-3.0.8.tgz
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
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示memcache共享擴展被安裝到了這裏
2、源碼安裝libmemcached,爲memcached安裝庫
cd /usr/local/src/
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure --prefix=/usr/local/libmemcached
make && make install
3、源碼安裝memcached
cd /usr/local/src/
wget http://pecl.php.net/get/memcached-2.2.0.tgz
tar -zxvf memcached-2.2.0.tgz
cd memcached-2.2.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示memcached共享擴展被安裝到了這裏
4、源碼安裝phpredis
cd /usr/local/src/
wget http://pecl.php.net/get/redis-2.2.4.tgz
tar -zxvf redis-2.2.4.tgz
cd redis-2.2.4
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示redis共享擴展被安裝到了這裏
5、源碼安裝xdebug
cd /usr/local/src/
wget http://xdebug.org/files/xdebug-2.4.0rc4.tgz
tar -zxvf xdebug-2.4.0rc4.tgz
cd xdebug-2.4.0RC4
/usr/local/php/bin/phpize
./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示xdebug共享擴展被安裝到了這裏
6、動態加載fileinfo
cd /usr/local/src/php-5.5.36/ext/fileinfo/ 進入此目錄,注意是php-5.5.36,此目錄是安裝包的所在目錄
/usr/local/php/bin/phpize
./configure --enable-fileinfo --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示fileinfo共享擴展被安裝到了這裏
7、動態加載mcrypt(和第六步相似)
cd /usr/local/src/php-5.5.36/ext/mcrypt
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
8、源碼安裝phalcon
cd /usr/local/src
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build/php5/64bits/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示phalcon共享擴展被安裝到了這裏
9、全部擴展件安裝完成後必定要記得啓動每一個擴展件
vi /usr/local/php/etc/php.ini 打開php.ini文件,在最上面或者最下面加上如下內容
extension=memcache.so
extension=mcrypt.so
extension=memcached.so
extension=redis.so
extension=xdebug.so
extension=fileinfo.so
extension=phalcon.so
php -m 以上內容添加到php.ini文件後,執行php -m能夠看到全部擴展件已被PHP加載