当前位置: 首页 > 后端技术 > PHP

Centos7x86_64Nginx+PHP安装步骤

时间:2023-03-29 15:44:45 PHP

Centos7Nginx+PHP安装步骤Centos7下PHP7/Nginx/Memcached安装步骤与之前Centos7Nginx+PHP安装步骤不同的是这次是针对64位编译的-bit,所有库都编译到/usr/local/lib64目录下。网上那些教程一般都不指定编译路径。其实是错的,都编译到默认路径在/usr/local/lib下然后软链接到lib64,简直恶心。另外Centos7.4升级了openssl库,所以本文不再单独安装新版Openssl。特别是对于大批量部署的机器,编译完成后,除了yum安装的部分,/usr/local可以直接打包,直接在其他同版本的Centos机器上运行,节省了编译时间。对于云环境,请直接克隆!一、获取相关开源程序1、安装环境所需的程序库yum-yupdateyumremovemariadb*yum-yinstallpatchmakecmakegccgcc-c++bisonflexfilelibtoollibtool-libsautoconfkernel-devellibjpeglibjpeg-devellibpnglibpng-develgdgd-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-devellibidnlibidn-develgmp-develget文本gettext-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-serversvim-minimalnanogmp-develunziplibcapdiffutilsreadline-devellibxsltlibxslt-develntpwgetctagslibeditlibedit-devellibaiodygitmailxjwhoisbind-utils-desystemdsystemdlibtidy-developensslopenssl-develyum-yinstallsupervisoryum-yinstallmemcached2,准备环境变量echo-e"/lib64\n/usr/lib64\n/usr/local/lib64\n/lib\n/usr/lib\n/用户/本地/lib\n`cat/etc/ld.so.conf`">/etc/ld.so.conf/sbin/ldconfig3,下载程序源码包cd/usr/local/srcwgethttp://7xk96f.com1.z0。glb.clouddn.com/software/libiconv/libiconv-1.15.tar.gzwget-Ophp-7.1.10.tar.gzhttp://cn2.php.net/get/php-7.1.10.tar.gz/来自/this/mirrorwgethttp://7xk96f.com1.z0.glb.clouddn.com/software/mcrypt/libmcrypt-2.5.8.tar.gzwgethttp://7xk96f.com1.z0.glb.clouddn.com/软件/mcrypt/mcrypt-2.6.8.tar.gzwgethttp://7xk96f.com1.z0.glb.clouddn.com/software/mhash/mhash-0.9.9.9.tar.gzwgethttp://7xk96f.com1。z0.glb.clouddn.com/software/icu/icu4c-58_2-src.tgzwgethttp://7xk96f.com1.z0.glb.clouddn.com/software/libmemcached/libmemcached-1.0.18.tar.gzwgethttp://7xk96f.com1.z0.glb.clouddn.com/software/pcre/pcre-8.41.tar.gzwgethttp://7xk96f.com1.z0.glb.clouddn.com/software/openssl/openssl-1.1.0e.tar.gzwgethttp://7xk96f.com1.z0.glb.clouddn.com/software/nginx/nginx-1.13.5.tar.gzwgethttp://pecl.php.net/get/msgpack-2.0.2.tgzwgethttp://pecl.php.net/get/igbinary-2.0.4.tgzwgethttp://pecl.php.net/get/memcached-3.0.3.tgzwgethttp://pecl.php.net/get/redis-3.1.4.tgzwgethttp://pecl.php.net/get/yaml-2.0.2.tgzwgethttp://pecl.php.net/get/mongodb-1.3.0.tgz2.安装PHP7(FastCGI模式)1.编译安装PHP7Support库:tarzxflibiconv-1.15.tar.gz&&cdlibiconv-1.15/./configure--prefix=/usr/local--libdir=/usr/local/lib64--enable-staticmake&&makeinstallcd../tarzxflibmcrypt-2.5.8.tar.gz&&cdlibmcrypt-2.5.8/./configure--prefix=/usr/local--libdir=/usr/local/lib64--enable-staticmake&&makeinstallldconfigcdlibltdl/./configure--prefix=/usr/local--libdir=/usr/local/lib64--enable-ltdl-installmake&&makeinstallcd../../tarzxfmhash-0.9.9.9.tar.gz&&cdmhash-0.9.9.9/./configure--prefix=/usr/local--libdir=/usr/local/lib64make&&makeinstallcd../tarzxfmcrypt-2.6.8.tar.gz&&cdmcrypt-2.6.8//sbin/ldconfig./configure--prefix=/usr/local--libdir=/usr/local/lib64make&&makeinstallcd../tarzxficu4c-58_2-src.tgz&&cdicu/source/./configure--prefix=/usr/local--libdir=/usr/local/lib64--enable-staticmake&&makeinstallcd../../tar-zxvflibmemcached-1.0.18.tar.gz&&cdlibmemcached-1.0.18./configure--prefix=/usr/local--libdir=/usr/local/lib64make&&makeinstallcd../tarzxfpcre-8.41.tar.gz&&cdpcre-8.41/./configure--prefix=/usr/local--libdir=/usr/local/lib64--enable-utfmake&&makeinstallcd../2、编译安装PHP(FastCGI模式)tarzxfphp-7.1.10.tar.gzcdphp-7.1.10//sbin/ldconfig./configure--prefix=/usr/local--libdir=/usr/local/lib64--with-config-file-path=/usr/local/etc--with-config-file-scan-dir=/usr/local/etc/php\--with-libxml-dir--with-openssl--with-kerberos--with-zlib--enable-bcmath--with-bz2--enable-calendar--with-curl\--enable-exif--enable-fpm--enable-ftp--with-png-dir--with-gd--with-jpeg-dir--enable-gd-native-ttf\--with-icu-dir=/usr/local--enable-mbstring--enable-mbregex--enable-shmop--enable-soap--enable-sockets\--enable-sysvmsg--enable-sysvsem--enable-sysvshm--enable-wddx--with-xmlrpc--with-libedit--with-iconv-dir=/usr/local\--with-xsl--enable-zip--with-pcre-regex--with-pcre-jit--with-freetype-dir--enable-xml--with-mysqli=mysqlnd\--with-pdo-mysql=mysqlnd--with-pdo-sqlite--with-sqlite3--disable-rpath--enable-inline-optimization--with-mcrypt\--with-mhash--enable-pcntl--without-pear--with-gettext--enable-fileinfo--enable-intl--启用opcache--enable-cli\--with-gmp--with-tidy--with-pcre-dir=/usr/local--with-readline--with-fpm-systemd--with-zlib-dir--with-libdir=lib64makeZEND_EXTRA_LIBS='-liconv'makeinstallcpphp.ini-production/usr/local/etc/php.inicp/usr/local/etc/php-fpm.conf.default/usr/local/etc/php-fpm.confcpsapi/fpm/php-fpm.service/usr/lib/systemd/system/php-fpm.servicesystemctlenablephp-fpm.servicecd../3、编译安装PHP扩展模块tarzxfmsgpack-2.0.2.tgzcdmsgpack-2.0.2phpize./configuremake&&makeinstallcd../tarzxfigbinary-2.0.4.tgzcdigbinary-2.0.4phpize./configuremake&&makeinstallcd../tarzxfmemcached-3.0.3.tgzcdmemcached-3.0.3phpize./configure--with-libdir=lib64--enable-memcached--enable-memcached-igbinary--enable-memcached-json--enable-memcached-msgpackmake&&makeinstallcd../tarzxfredis-3.1.3.tgzcdredis-3.1.3phpize./configuremake&&makeinstallcd../tarzxfyaml-2.0.2.tgzcdyaml-2.0。2phpize./configuremake&&makeinstallcd../tarzxfmongodb-1.2.9.tgzcdmongodb-1.2.9phpize./configuremake&&makeinstallcd../三、安装Nginxtarzxfnginx-1.13.5.tar.gzcdnginx-1.13.5/./configure--prefix=/usr/local--libdir=/usr/local/lib64--conf-path=/usr/local/etc/nginx/nginx.conf--error-log-path=/var/log/nginx/error.log--http-client-body-temp-path=/var/lib/nginx/body--http-fastcgi-temp-path=/var/lib/nginx/fastcgi--http-log-path=/var/log/nginx/access.log--http-proxy-temp-path=/var/lib/nginx/proxy--lock-path=/run/lock/nginx.lock--pid-path=/run/nginx.pid\--with-http_ssl_module--with-http_v2_module--with-http_image_filter_module--with-http_xslt_module--with-http_realip_module--with-http_stub_status_module\--with-pcre-jit--with-http_flv_module--with-http_mp4_module--with-http_addition_module\--with-threads--with-http_ssl_module--with-http_gzip_static_module--without-mail_imap_module--without-mail_pop3_module--without-mail_smtp_module\--without-http_uwsgi_module--without-http_scgi_module--without-select_module\--with-cc-opt='-O2'make&&makeinstallcd../mkdir/var/log/nginxmkdir/var/lib/nginx四、收尾1、添加www用户/usr/sbin/groupaddwww/usr/sbin/useradd-M-gwwwwww2、优化内核#foraliyuncat>>/etc/security/limits.conf<>/etc/security/limits.conf<>/etc/sysctl.conf3、设置开机启动systemctlenablenginx.servicesystemctlenablephp-fpm.servicesystemctl启用memcached.servicesystemctl启用supervisord.service