本机是新机什么东西都没有,所以记录下从无到有的所有过程。
1、安装unzip
yum install -y vim unzip //-y自动全部选择y
2、下载php源码并解压
wget http://cn.php.net/distributions/php-7.2.7.tar.gz
tar -xzxvf php-7.2.7.tar.gz
3、进入php源码目录后编译
./configure --prefix=/usr/local/php72 --with-config-file-path=/usr/local/php72/etc --with-mhash --with-openssl --enable-mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-iconv-dir --with-zlib --with-zlib-dir --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --without-gdbm --disable-fileinfo --with-libxml-dir --enable-sysvmsg --enable-sysvshm --with-bz2 --with-readline --with-libdir --enable-calendar --enable-exif --enable-intl --with-png-dir --enable-wddx --enable-dom --enable-filter --with-pear=DIR
中间会遇到很多错误,自己解决,一般都是某些应用未安装
make && make install
4、php安装完后开始修改一些配置项
cp php.ini-production /usr/local/php72/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php72-fpm
cd /usr/local/php72/etc
cp php-fpm.conf.default php-fpm.conf
chmod +x /etc/init.d/php72-fpm
chkconfig --add php72-fpm
chkconfig --level 35 php72-fpm on
vim php-fpm.conf
pid = run/php-fpm.pid
error_log = log/php-fpm_error.log
daemonize = yes
events.mechanism = epoll
cd php-fpm.d/
ll
cp www.conf.default www.conf
ll
vi www.conf
user = www
group = www
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
pm = static
pm.max_children = 127
pm.max_requests = 10240
access.log = /data/logs/php-fpm_access.log
access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
slowlog = var/log/$pool.log.slow
request_slowlog_timeout = 5
rlimit_files = 65000
rlimit_core = 65000
catch_workers_output = yes
5、设置全局变量
PATH=$PATH:/usr/local/php72/bin
export PATH
source /etc/profile
php -v
至此PHP已经安装完毕
6、下载nginx
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar zxf nginx-1.14.0.tar.gz
修改一下配置信息
vim src/core/nginx.h //nginx版本信息
#define nginx_version 1014000
#define NGINX_VERSION "66666"
#define NGINX_VER "WTF/" NGINX_VERSION
vim src/http/ngx_http_header_filter_module.c \\修改HTTP头信息中的connection字段,防止回显具体版本号
static u_char ngx_http_server_string[] = "Server: WTF" CRLF;
vim src/http/ngx_http_special_response.c \\ 有时候我们页面程序出现错误,Nginx会代我们返回相应的错误代码,回显的时候,会带上nginx和版本号,我们把他隐藏起来
static u_char ngx_http_error_tail[] =
"
WTF " CRLF
"
" CRLF "