1、更新系统
[jeesaas@localhost ~]$ sudo yum update -y
2、系统环境
[jeesaas@localhost ~]$ cat /etc/redhat-release // 查看系统版本
[jeesaas@localhost ~]$ sudo yum -y install vim wget lsof gcc gcc-c++ //安装必备工具包以及依赖
[jeesaas@localhost ~]$ cd /usr/local/src/
[jeesaas@localhost src]$ sudo wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz
[jeesaas@localhost src]$ sudo tar zvxf libunwind-1.1.tar.gz
[jeesaas@localhost src]$ cd libunwind-1.1
[jeesaas@localhost libunwind-1.1]$ sudo ./configure --enable-shared
[jeesaas@localhost libunwind-1.1]$ sudo make
[jeesaas@localhost libunwind-1.1]$ sudo make install
[jeesaas@localhost libunwind-1.1]$ cd ../
[jeesaas@localhost src]$ sudo wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.5/gperftools-2.5.tar.gz
[jeesaas@localhost src]$ sudo tar zvxf gperftools-2.5.tar.gz
[jeesaas@localhost src]$ cd gperftools-2.5
[jeesaas@localhost gperftools-2.5]$ sudo ./configure --enable-shared --enable-frame-pointers
[jeesaas@localhost gperftools-2.5]$ sudo make
[jeesaas@localhost gperftools-2.5]$ sudo make install
[jeesaas@localhost gperftools-2.5]$ cd ~
4、更新,使动态链接库能够被系统共享
[jeesaas@localhost ~]$ su root
[root@localhost jeesaas]# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
[root@localhost jeesaas]# ldconfig
[root@localhost jeesaas]# su jeesaas
5、安装 MySQL(需要 cmake ncurses-devel bison 库)
[jeesaas@localhost ~]$ cd /usr/local/src/
[jeesaas@localhost src]$ sudo wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
[jeesaas@localhost src]$ sudo yum install ncurses-devel openssl* -y
[jeesaas@localhost src]$ sudo tar zxvf ncurses-5.9.tar.gz
[jeesaas@localhost src]$ cd ncurses-5.9
[jeesaas@localhost ncurses-5.9]$ sudo ./configure
[jeesaas@localhost ncurses-5.9]$ sudo make
[jeesaas@localhost ncurses-5.9]$ sudo make install
[jeesaas@localhost ncurses-5.9]$ cd ../
[jeesaas@localhost src]$ sudo wget https://cmake.org/files/v3.7/cmake-3.7.0.tar.gz
[jeesaas@localhost src]$ sudo tar zvxf cmake-3.7.0.tar.gz
[jeesaas@localhost src]$ cd cmake-3.7.0
[jeesaas@localhost cmake-3.7.0]$ sudo ./bootstrap
[jeesaas@localhost cmake-3.7.0]$ sudo make
[jeesaas@localhost cmake-3.7.0]$ sudo make install
[jeesaas@localhost cmake-3.7.0]$ cd ../
[jeesaas@localhost src]$ sudo wget http://ftp.gnu.org/gnu/bison/bison-3.0.tar.gz
[jeesaas@localhost src]$ sudo tar zvxf bison-3.0.tar.gz
[jeesaas@localhost src]$ cd bison-3.0
[jeesaas@localhost bison-3.0]$ sudo ./configure
[jeesaas@localhost bison-3.0]$ sudo make
[jeesaas@localhost bison-3.0]$ sudo make install
[jeesaas@localhost bison-3.0]$ cd ~
[jeesaas@localhost ~]$ sudo groupadd mysql //创建用户组
[jeesaas@localhost ~]$ sudo useradd -g mysql mysql //创建用户名
[jeesaas@localhost ~]$ sudo mkdir -p /data/mysql //创建mysql需要的目录
[jeesaas@localhost ~]$ sudo chown -R mysql:mysql /data/mysql
[jeesaas@localhost ~]$ cd /usr/local/src/
[jeesaas@localhost src]$ sudo wget http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.34.tar.gz
[jeesaas@localhost src]$ sudo tar zvxf mysql-5.6.34.tar.gz
[jeesaas@localhost src]$ cd mysql-5.6.34
[jeesaas@localhost mysql-5.6.34]$ su root
[root@localhost mysql-5.6.34]# cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/data/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on -DWITH_SSL=yes
[root@localhost mysql-5.6.34]# su jeesaas
[jeesaas@localhost mysql-5.6.34]$ sudo make
[jeesaas@localhost mysql-5.6.34]$ sudo make install
[jeesaas@localhost mysql-5.6.34]$ sudo ln -s /opt/mysql/lib/lib* /usr/lib/ //创建软连接
[jeesaas@localhost mysql-5.6.34]$ cd /opt/mysql //进入配置mysql数据库目录
[jeesaas@localhost mysql]$ sudo ./scripts/mysql_install_db --basedir=/opt/mysql/ --datadir=/data/mysql/ --user=mysql //配置mysql数据库
[jeesaas@localhost mysql]$ sudo cp ./support-files/my-default.cnf /etc/my.cnf //复制配置文件 3.9.1 (mysql 5.6.19)
[jeesaas@localhost mysql]$ sudo cp ./support-files/my-large.cnf /etc/my.cnf //3.9.2 (mysql 5.3.29)
[jeesaas@localhost mysql]$ su root
[root@localhost mysql]# vi /etc/my.cnf
在[mysqld]下添加一行:character-set-server = utf8
在[client]下添加一行:default-character-set = utf8
[root@localhost mysql]# su jeesaas
[jeesaas@localhost mysql]$ sudo cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
[jeesaas@localhost mysql]$ sudo chkconfig --add mysqld
[jeesaas@localhost mysql]$ sudo chkconfig --level 345 mysqld on
[jeesaas@localhost mysql]$ su root
[root@localhost mysql]# vi /etc/rc.d/init.d/mysqld
根据设定需要,修改mysqld文件中的下面两项,保存后退出
basedir=/opt/mysql
datadir=/data/mysql
[root@localhost mysql]# service mysqld start
[root@localhost mysql]# ./bin/mysql_secure_installation //数据库初始化及修改root密码(root初始密码为空),根据提示操作
[root@localhost mysql]# ln -s /opt/mysql/bin/mysql /bin
[jeesaas@localhost ~]$ mysql -uroot //重启登录
mysql> quit;
[jeesaas@localhost ~]$ sudo vi /opt/mysql/bin/mysqld_safe
使用tcmalloc优化mysql ( 需要安装google-perftools),在# executing mysqld_safe的下一行,加上:
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so
[jeesaas@localhost ~]$ su root
[root@localhost jeesaas]# service mysqld restart //重启服务
[root@localhost jeesaas]# lsof -n | grep tcmalloc //查看tcmalloc是否生效
如果显示以下类似的信息,即表示tcmalloc生效
mysqld 1777 mysql mem REG 253,0 2200512 2235134 /usr/local/lib/libtcmalloc.so.4.3.0
[jeesaas@localhost ~]$ mysql -uroot //重启登录
mysql> use mysql;
mysql> update user set password=password('jeesaas@liubo') where user='root'; //设置登录密码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'jeesaas@liubo' WITH GRANT OPTION; //添加远程登录支持
mysql> FLUSH PRIVILEGES;
mysql> quit;
6、安装 Nginx
[root@localhost jeesaas]# yum install zlib* openssl* -y //更新包
[root@localhost jeesaas]# cd /usr/local/src/
[jeesaas@localhost src]$ sudo wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
[jeesaas@localhost src]$ sudo tar zvxf pcre-8.38.tar.gz
[jeesaas@localhost src]$ cd pcre-8.38
[jeesaas@localhost pcre-8.38]$ sudo ./configure
[jeesaas@localhost pcre-8.38]$ sudo make
[jeesaas@localhost pcre-8.38]$ sudo make install
[jeesaas@localhost src]$ cd ~
[jeesaas@localhost ~]$ su root
创建www用户和组,创建www虚拟主机使用的目录,以及Nginx使用的日志目录,并且赋予他们适当的权限
[root@localhost jeesaas]# groupadd www
[root@localhost jeesaas]# useradd -g www www
[root@localhost jeesaas]# mkdir -p /data/www
[root@localhost jeesaas]# chmod +w /data/www
[root@localhost jeesaas]# chown -R www:www /data/www
为tcmalloc添加目录,并且赋予适当权限
[root@localhost jeesaas]# mkdir -p /tmp/tcmalloc/
[root@localhost jeesaas]# chown -R www:www /tmp/tcmalloc/
[root@localhost jeesaas]# su jeesaas
[jeesaas@localhost ~]$ cd /usr/local/src
[jeesaas@localhost src]$ sudo wget http://nginx.org/download/nginx-1.11.6.tar.gz
[jeesaas@localhost src]$ sudo tar zvxf nginx-1.11.6.tar.gz
[jeesaas@localhost src]$ cd nginx-1.11.6/src/core
[jeesaas@localhost core]$ sudo vim ./src/core/nginx.h //伪装服务器信息(可以不修改)
修改NGINX_VERSION为你希望显示的版号
修改NGINX_VER为你希望显示的名称
修改NGINX_VAR 为你希望显示的名称
保存,退出
[jeesaas@localhost core]$ cd ../../
[jeesaas@localhost nginx-1.11.6]$ sudo ./configure --user=www --group=www --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-google_perftools_module
[jeesaas@localhost nginx-1.11.6]$ sudo make
[jeesaas@localhost nginx-1.11.6]$ sudo make install
[jeesaas@localhost nginx-1.11.6]$ sudo vi /opt/nginx/conf/nginx.conf
修改前面几行为:
user www www;
worker_processes 8;
error_log logs/error.log crit;
pid logs/nginx.pid;
google_perftools_profiles /tmp/tcmalloc/;
events{
use epoll;
worker_connections 65535;
}
[jeesaas@localhost nginx-1.11.6]$ cd /opt/nginx
[jeesaas@localhost nginx]$ sudo ldconfig
[jeesaas@localhost nginx]$ sudo ./sbin/nginx -t
如果显示下面信息,即表示配置没问题
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
[jeesaas@localhost nginx]$ sudo /opt/nginx/sbin/nginx
[jeesaas@localhost nginx]$ ps au|grep nginx
如果显以类似下面的信息,即表示nginx已经启动
jeesaas 9033 0.0 0.0 103324 868 pts/0 S+ 11:33 0:00 grep nginx
[jeesaas@localhost nginx]$ sudo lsof -n | grep tcmalloc //检测是否支持加速
如果显示类似下面的信息,即表示支持tcmalloc加速 (mysqld和nginx两个线程都支持)
mysqld 1777 mysql mem REG 253,0 2200512 2235134 /usr/local/lib/libtcmalloc.so.4.3.0
nginx 9024 www 10w REG 253,0 0 2633513 /tmp/tcmalloc/.9024
nginx 9025 www 12w REG 253,0 0 2633518 /tmp/tcmalloc/.9025
nginx 9026 www 14w REG 253,0 0 2633515 /tmp/tcmalloc/.9026
nginx 9027 www 16w REG 253,0 0 2633516 /tmp/tcmalloc/.9027
nginx 9028 www 18w REG 253,0 0 2633517 /tmp/tcmalloc/.9028
nginx 9029 www 20w REG 253,0 0 2633512 /tmp/tcmalloc/.9029
nginx 9030 www 22w REG 253,0 0 2633514 /tmp/tcmalloc/.9030
nginx 9031 www 24w REG 253,0 0 2633519 /tmp/tcmalloc/.9031
[jeesaas@localhost nginx]$ sudo vi /etc/init.d/nginx //编写nginx 启动服务
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/opt/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/opt/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
killall -9 nginx
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
[jeesaas@localhost nginx]$ sudo chmod 755 /etc/init.d/nginx
[jeesaas@localhost nginx]$ sudo chkconfig --add nginx
[jeesaas@localhost nginx]$ sudo chkconfig --level 345 nginx on
[jeesaas@localhost nginx]$ sudo service nginx stop
7、安装 PHP
[jeesaas@localhost nginx]$ cd ~
//更新依赖
[jeesaas@localhost ~]$ sudo yum -y install autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libXpm* gcc gcc-c++
[jeesaas@localhost ~]$ cd /usr/local/src/
[jeesaas@localhost src]$ sudo wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
//安装libiconv (加强系统对支持字符编码转换的功能)
[jeesaas@localhost ~]$ cd /usr/local/src/
[jeesaas@localhost src]$ sudo tar zvxf libiconv-1.14.tar.gz
[jeesaas@localhost src]$ cd libiconv-1.14
[jeesaas@localhost libiconv-1.14]$ sudo ./configure --prefix=/usr/local
[jeesaas@localhost libiconv-1.14]$ sudo make
[jeesaas@localhost libiconv-1.14]$ sudo make install
//安装libmcrypt(加密算法库,PHP扩展mcrypt功能对此库有依耐关系,要使用mcrypt必须先安装此库)
[jeesaas@localhost src]$ sudo wget http://jaist.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/
[jeesaas@localhost libiconv-1.14]$ cd ../
[jeesaas@localhost src]$ sudo tar zvxf libmcrypt-2.5.8.tar.gz
[jeesaas@localhost src]$ cd libmcrypt-2.5.8
[jeesaas@localhost libmcrypt-2.5.8]$ sudo ./configure //不推荐
//执行上面命令会照成安装到mcrypt的时候出现了问题:configure: error: *** libmcrypt was not found,所以,使用下面的命令
[jeesaas@localhost libmcrypt-2.5.8]$ sudo ./configure --prefix=/usr/local/libmcrypt // 推荐
[jeesaas@localhost libmcrypt-2.5.8]$ sudo make
[jeesaas@localhost libmcrypt-2.5.8]$ sudo make install
//安装libltdl
[jeesaas@localhost libmcrypt-2.5.8]$ cd libltdl/
[jeesaas@localhost libltdl]$ sudo ./configure --enable-ltdl-install
[jeesaas@localhost libltdl]$ sudo make
[jeesaas@localhost libltdl]$ sudo make install
//更新共享
[jeesaas@localhost src]$ sudo ln -sf /usr/local/lib/libmcrypt.* /usr/lib64/
[jeesaas@localhost src]$ sudo ln -sf /usr/local/lib/libmcrypt.* /usr/lib/
[jeesaas@localhost src]$ sudo ln -sf /usr/local/bin/libmcrypt-config /usr/lib64/
[jeesaas@localhost src]$ sudo ln -sf /usr/local/bin/libmcrypt-config /usr/lib/
[jeesaas@localhost src]$ sudo ln -sf /usr/local/lib/libiconv.so.2 /usr/lib64/
[jeesaas@localhost src]$ sudo ln -sf /usr/local/lib/libiconv.so.2 /usr/lib/
[jeesaas@localhost src]$ sudo ldconfig
//安装mhash(hash加密算法库)
[jeesaas@localhost libltdl]$ cd ../../
[jeesaas@localhost src]$ sudo wget http://jaist.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
[jeesaas@localhost src]$ sudo tar zvxf mhash-0.9.9.9.tar.gz
[jeesaas@localhost src]$ cd mhash-0.9.9.9
[jeesaas@localhost mhash-0.9.9.9]$ sudo ./configure
[jeesaas@localhost mhash-0.9.9.9]$ sudo make
[jeesaas@localhost mhash-0.9.9.9]$ sudo make install
//更新共享
[jeesaas@localhost mhash-0.9.9.9]$ sudo ln -sf /usr/local/lib/libmhash.* /usr/lib64/
[jeesaas@localhost mhash-0.9.9.9]$ sudo ln -sf /usr/local/lib/libmhash.* /usr/lib/
//安装mcrypt
[jeesaas@localhost mhash-0.9.9.9]$ cd ../
[jeesaas@localhost src]$ sudo wget http://jaist.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
[jeesaas@localhost src]$ sudo tar zvxf mcrypt-2.6.8.tar.gz
[jeesaas@localhost src]$ cd mcrypt-2.6.8
[jeesaas@localhost mcrypt-2.6.8]$ sudo ./configure
//如果出现以下错误代码:
checking for libmcrypt - version >= 2.5.0...
*** 'libmcrypt-config --version' returned 2.4.0, but LIBMCRYPT (2.5.8)
*** was found! If libmcrypt-config was correct, then it is best
*** to remove the old version of LIBMCRYPT. You may also be able to fix the error
*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing
*** /etc/ld.so.conf. Make sure you have run ldconfig if that is
*** required on your system.
*** If libmcrypt-config was wrong, set the environment variable LIBMCRYPT_CONFIG
*** to point to the correct copy of libmcrypt-config, and remove the file config.cache
*** before re-running configure
configure: error: *** libmcrypt was not found
//提示没有发现 ,这一步明确了是PATH变量的问题,执行如下命令即可
[jeesaas@localhost mcrypt-2.6.8]$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
[jeesaas@localhost mcrypt-2.6.8]$ sudo ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
[jeesaas@localhost mcrypt-2.6.8]$ sudo ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
[jeesaas@localhost mcrypt-2.6.8]$ sudo ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
[jeesaas@localhost mcrypt-2.6.8]$ sudo ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
[jeesaas@localhost mcrypt-2.6.8]$ sudo ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
[jeesaas@localhost mcrypt-2.6.8]$ sudo ldconfig
[jeesaas@localhost mcrypt-2.6.8]$ sudo ./configure
[jeesaas@localhost mcrypt-2.6.8]$ sudo make
[jeesaas@localhost mcrypt-2.6.8]$ sudo make install
//安装PHP,创建mysql软连接、ldap软连接
[jeesaas@localhost mcrypt-2.6.8]$ sudo mkdir -p /usr/local/mysql/include/mysql
[jeesaas@localhost mcrypt-2.6.8]$ sudo ln -s /usr/local/mysql/include/* /usr/local/mysql/include/mysql/
[jeesaas@localhost mcrypt-2.6.8]$ sudo ln -s /usr/lib64/libldap* /usr/lib
[jeesaas@localhost mcrypt-2.6.8]$ cd ../
[jeesaas@localhost php-7.0.13]$ sudo yum install epel-release //扩展包更新包
[jeesaas@localhost php-7.0.13]$ sudo yum update //更新yum源
[jeesaas@localhost php-7.0.13]$ sudo yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libmcrypt libmcrypt-devel libXpm-devel
[jeesaas@localhost src]$ sudo wget http://cn2.php.net/distributions/php-7.0.13.tar.gz
[jeesaas@localhost src]$ sudo tar zvxf php-7.0.13.tar.gz
[jeesaas@localhost src]$ cd php-7.0.13
[jeesaas@localhost php-7.0.13]$ sudo ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/opt/mysql/bin/mysql_config --with-php-config=/usr/local/webserver/php/bin/php-config --with-iconv-dir=/usr/local --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-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-pdo-mysql --with-curl --without-pdo-sqlite --without-sqlite3
[jeesaas@localhost php-7.0.13]$ sudo make ZEND_EXTRA_LIBS='-liconv'
[jeesaas@localhost php-7.0.13]$ sudo make
[jeesaas@localhost php-7.0.13]$ sudo make install
//安装php-fpm
[jeesaas@localhost src]$ sudo cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[jeesaas@localhost src]$ sudo vi /usr/local/php/etc/php-fpm.conf
//修改以下代码
[global]
pid = run/php-fpm.pid-p
error_log = log/php-fpm.log
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5s
pm.max_children = 35
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
[www]
user = www
group = www
//修改nginx,支持php
[jeesaas@localhost src]$ sudo vi /opt/nginx/conf/nginx.conf
找到并修改以下代码:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
include fastcgi_params;
}
//将php-fpm 作为服务运行
[jeesaas@localhost src]$ cd php-7.0.13
[jeesaas@localhost php-7.0.13]$ sudo cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[jeesaas@localhost php-7.0.13]$ sudo chmod 700 /etc/init.d/php-fpm
[jeesaas@localhost php-7.0.13]$ sudo chkconfig --add php-fpm
[jeesaas@localhost php-7.0.13]$ sudo chkconfig --level 345 php-fpm on
[jeesaas@localhost php-7.0.13]$ sudo service php-fpm start
//启动过程中如果出现如下错误:
Starting php-fpm [28-Nov-2016 05:27:16] WARNING: Nothing matches the include pattern '/usr/local/php/etc/php-fpm.d/*.conf' from /usr/local/php/etc/php-fpm.conf at line 125.
[28-Nov-2016 05:27:16] ALERT: [pool www] no listen address have been defined!
[28-Nov-2016 05:27:16] ERROR: failed to post process the configuration
[28-Nov-2016 05:27:16] ERROR: FPM initialization failed
//从最初的warning开始追起 大概知道是在/usr/local/php/etc/php-fpm.d/缺少了一个.conf文件 然后进入此目录发现有一个 www.conf.default 按照常识应该应该进行如下操作:
[jeesaas@localhost init.d]$ cd /usr/local/php/etc/php-fpm.d
[jeesaas@localhost php-fpm.d]$ sudo cp www.conf.default www.conf
[jeesaas@localhost php-fpm.d]$ sudo vi www.conf
//其中www.conf内修改了 user 和group将nobody 改成 www
//编写测试页面
[jeesaas@localhost php-fpm.d]$ sudo vi /data/www/index.php
<html>
<head><title>hello php</title></head>
<body>
<?php phpinfo();?>
</body>
</html>
[jeesaas@localhost php-fpm.d]$ sudo chown -R www:www /data/www
[jeesaas@localhost php-fpm.d]$ sudo service nginx restart
[jeesaas@localhost php-fpm.d]$ sudo service php-fpm restart
//打开浏览器进行测试
http://localhost/index.html
http://localhost/index.php
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于