对于centos中yum安装php都是老的版本,而且安装起来很不方便,编译安装恐怕是最合适的选择了。
1.安装msyql
2.1 参考链接 卸载服务器上老的mysql 编译安装mysql5.6.20 http://www.onephper.com/archive/24.html
2.下载各种依赖先
1.1 yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel pcre-devel
3.下载 libmcrypt-2.5.8.tar.gz
3.1 wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz
3.2 tar zxvf libmcrypt-2.5.8.tar.gz
3.3 cd libmcrypt-2.5.8
3.4 ./configure
3.5 make && make install
4.下载php5.6.2 wget http://cn2.php.net/get/php-5.6.20.tar.gz/from/this/mirror
4.1 添加一个用户和组 groupadd www && useradd -g www www
4.2 编译参数
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc/ --enable-fpm --with-mysql=/usr/local/mysql # php7 不需要此参数 --with-mysql-sock --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --with-libxml-dir --with- --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-pdo-mysql --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --with-fpm-user=www --with-fpm-group=www
4.3 make && make install
4.4 cp /usr/local/php/etc/php-fpm.conf.default php-fpm.conf 拷贝一份作为php-fpm.conf
4.5 接着参考我写的另外一篇文章 http://www.onephper.com/archive/5.html
4.6 参考链接
http://www.centoscn.com/image-text/install/2015/0516/5451.html
http://www.tuicool.com/articles/F3A7ru
5.安装nginx1.8.1
5.1 wget http://nginx.org/download/nginx-1.8.1.tar.gz
5.2 usermod -s /sbin/nologin -g www www 禁止www用户登录系统
5.3. tar zxvf nginx-1.8.1.tar.gz
5.4 cd nginx-1.8.1
5.5 编译参数
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module \ --without-http_rewrite_module --with-http_ssl_module --with-pcre --with-http_ssl_module
5.7 (这里加上--without-http_rewrite_module“不安装重新模块” 会导致配置文件中使用不了if和set命令,会使nginx不支持rewrite功能,删掉这句话默认是安装的)
5.8 make && make install
5.9 如果需要添加开启自启需要添加到/etc/init.d/nginx 需要一份启动文件 这里可以下载
# wget http://www.onephper.com/uploads/archive/201604/1461131525845650.txt # cp 1461131525845650.txt /etc/init.d/nginx (如果你的nginx不在/usr/local/nginx 需要更改一下你自己的配置) # chmod +x /etc/init.d/nginx # chkconfig --add nginx
结束语
本文有任何错误,或有任何疑问,欢迎留言说明。
网友最新评论