一个朋友的服务器被黑客入侵了,无奈之下重装系统,找我帮他搭建环境。
准备工作
安装 EPEL 源:
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm安装编译工具:
yum -y install make gcc gcc-c++ autoconf automake安装 Nginx
yum -y install pcre-devel openssl-devel zlib-devel
wget http://nginx.org/download/nginx-1.9.2.tar.gzwget http://luajit.org/download/LuaJIT-2.0.4.tar.gzwget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz \ -O ngx_devel_kit_v0.2.19.tar.gzwget https://github.com/openresty/lua-nginx-module/archive/v0.9.16.tar.gz \ -O lua-nginx-module_v0.9.16.tar.gz
tar zxf nginx-1.9.2.tar.gz -C /usr/local/srctar zxf LuaJIT-2.0.4.tar.gz -C /usr/local/srctar zxf ngx_devel_kit_v0.2.19.tar.gz -C /usr/local/srctar zxf lua-nginx-module_v0.9.16.tar.gz -C /usr/local/src
cd /usr/local/src/LuaJIT-2.0.4make PREFIX=/usr/local/LuaJITmake PREFIX=/usr/local/LuaJIT installmake cleanecho "/usr/local/LuaJIT/lib" > /etc/ld.so.conf.d/LuaJIT.confldconfig
cd /usr/local/src/nginx-1.9.2export LUAJIT_LIB=/usr/local/LuaJIT/libexport LUAJIT_INC=/usr/local/LuaJIT/include/luajit-2.0./configure --prefix=/usr/local/nginx \ --user=nobody \ --group=nobody \ --with-threads \ --with-file-aio \ --with-http_ssl_module \ --with-http_spdy_module \ --with-http_realip_module \ --with-http_gunzip_module \ --with-http_auth_request_module \ --with-http_secure_link_module \ --with-http_stub_status_module \ --http-client-body-temp-path=/usr/local/nginx/client_body_temp \ --http-proxy-temp-path=/usr/local/nginx/proxy_temp \ --http-fastcgi-temp-path=/usr/local/nginx/fastcgi_temp \ --http-uwsgi-temp-path=/usr/local/nginx/uwsgi_temp \ --http-scgi-temp-path=/usr/local/nginx/scgi_temp \ --with-mail \ --with-mail_ssl_module \ --with-stream \ --with-stream_ssl_module \ --add-module=../ngx_devel_kit-0.2.19 \ --add-module=../lua-nginx-module-0.9.16make && make install && make clean安装 MySQL
yum -y install mysql-server mysql-devel安装 PHP
安装 PHP 5.6:
yum -y install readline-devel gd-devel libjpeg-turbo-devel libpng-devel freetype-devel libcurl-devel
wget http://am1.php.net/distributions/php-5.6.10.tar.gztar zxf php-5.6.10.tar.gz -C /usr/local/src
cd /usr/local/src/php-5.6.10./configure --prefix=/usr/local/php \ --enable-fpm \ --with-fpm-user=nobody \ --with-fpm-group=nobody \ --disable-ipv6 \ --enable-phpdbg \ --with-readline \ --with-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --enable-opcachemake && make installcp php.ini-production /usr/local/php/etc/php.inicp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpmchmod +x /etc/rc.d/init.d/php-fpmcp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cd /usr/local/src/php-5.6.10/ext/gd/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-config \ --with-gd \ --with-jpeg-dir \ --with-png-dir \ --with-freetype-dir \ --enable-gd-native-ttf \ --enable-gd-jis-convmake && make install && make clean
cd /usr/local/src/php-5.6.10/ext/curl./configure --with-php-config=/usr/local/php/bin/php-configmake && make install && make clean因为朋友的某个程序相当古老,重新安装 PHP 5.2:
wget http://museum.php.net/php5/php-5.2.17.tar.gzwget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
tar zxf php-5.2.17.tar.gz -C /usr/local/srcgzip -c -d php-5.2.17-fpm-0.5.14.diff.gz | patch -d /usr/local/src/php-5.2.17 -p1
cd /usr/local/src/php-5.2.17./configure --prefix=/usr/local/php52 \ --enable-fastcgi \ --enable-force-cgi-redirect \ --enable-fpm \ --disable-ipv6 \ --with-mysql \ --with-mysqli \ --with-pdo-mysql \ --with-libdir=lib64make && make installcp php.ini-recommended /usr/local/php52/etc/php.ini