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

Centos7Nginx+PHP安装步骤

时间:2023-03-29 13:59:59 PHP

Centos7Nginx+PHP安装步骤Centos7下PHP7/Nginx/Memcached安装步骤一、获取相关开源程序1、安装环境所需程序库sudo-sLANG=Cyum-yupdateyumremovemariadb*yum-yinstallpatch制作cmakegccgcc-c++bisonflex文件libtoollibtool-libsautoconfkernel-devellibjpeglibjpeg-devellibpnglibpng-develgdgd-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-devellibidnlibidn-develgmp-develgettextgettext-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-serversvim-minimalnanogmp-devel解压缩libcapdiffutilsreadline-devellibxsltlibxslt-develntpwgetctagslibeditlibedit-devellibaiogitmailxsystemjwhoisbinddsystemd-devellibtidylibtidy-develyum-yinstallsupervisoryum-yinstallmemcached2,准备环境变量echo-e"/lib64\n/usr/lib64\n/usr/local/lib64\n/lib\n/usr/lib\n/usr/local/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.5.tar.gzhttp://cn2.php.net/get/php-7.1.5.tar.gz/from/this/mirrorwgethttp://7xk96f.com1.z0.glb.clouddn.com/software/mcrypt/libmcrypt-2.5.8.tar.gzwgethttp://7xk96f.com1.z0.glb.clouddn.com/software/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.40.tar.gzwgethttp://7xk96f.com1.z0.glb.clouddn.com/software/openssl/openssl-1.1.0e.tar.gzwgethttp://7xk96f.com1.z0.glb.clouddn.com/软件/nginx/nginx-1.13.0.tar.gzwgethttp://pecl.php.net/get/msgpack-2.0.2.tgzwgethttp://pecl.php.net/get/igbinary-2.0.1。tgzwgethttp://pecl.php.net/get/memcached-3.0.3.tgzwgethttp://pecl.php.net/get/redis-3.1.2.tgzwgethttp://pecl.php.net/get/swoole-2.0.7.tgz二、安装PHP7(FastCGI模式)1、编译安装PHP7所需的支持库:tarzxflibiconv-1.15.tar.gzcdlibiconv-1.15/./configure--prefix=/usrmake&&makeinstallcd../tarzxflibmcrypt-2.5.8.tar.gzcdlibmcrypt-2.5.8/./configure--prefix=/usrmake&&makeinstallldconfigcdlibltdl/./configure--prefix=/usr--enable-ltdl-installmake&&makeinstallcd../../tarzxfmhash-0.9.9.9.tar.gzcdmhash-0.9.9.9/./configure--prefix=/usrmake&&makeinstallcd../tarzxfmcrypt-2.6.8.tar.gz&&cdmcrypt-2.6.8//sbin/ldconfig./configure--prefix=/usrmake&&makeinstallcd../tarzxficu4c-58_2-src.tgz&&cdicu/source/./configure--prefix=/usrmake&&makeinstallcd../../tarzxfopenssl-1.1.0e.tar.gz&&cdopenssl-1.1.0e./config--prefix=/usr/local/sslsharedzlib-dynamicmake&&makeinstallecho/usr/local/ssl/lib>/etc/ld.so.conf.d/openssl-x86_64.conf/sbin/ldconfigcd../2、编译安装PHP(FastCGI模式)tarzxfphp-7.1.5.tar.gzcdphp-7.1.5/./configure--prefix=/usr/local--mandir=/usr/local/share/man--infodir=/usr/local/share/info--sysconfdir=/usr/local/etc--with-config-file-path=/usr/local/etc--with-config-file-scan-dir=/usr/local/etc/php--with-libxml-dir\--with-openssl=/usr/local/ssl--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--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--enable-sockets--without-pear--with-gettext--enable-fileinfo--enable-intl--enable-opcache--enable-cli--with-gmp--with-tidy--with-pcre-dir--with-readline--with-fpm-systemd--with-zlib-dirmakeZEND_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.service3、编译安装PHP扩展模块tar-zxvflibmemcached-1.0.18.tar.gzcdlibmemcached-1.0.18./configure--prefix=/usrmake&&makeinstallcd../tarzxfmsgpack-2.0.2.tgzcdmsgpack-2.0.2phpize./configuremake&&makeinstallcd../tarzxfigbinary-2.0.1.tgzcdigbinary-2.0.1phpize./configuremake&&makeinstallcd../tarzxfmemcached-3.0.3.tgzcdmemcached-3.0.3phpize./configure--enable-memcached-igbinary--enable-memcached-json--enable-memcached-msgpackmake&&makeinstallcd../tarzxfredis-3.1.2.tgzcdredis-3.1.2phpize./configuremake&&makeinstallcd../tarzxfswoole-2.0.7.tgzcdswoole-2.0.7phpize./configure--enable-coroutinemake&&makeinstallcd../三、安装Nginx1、安装Pcre库tarzxfpcre-8.40.tar.gzcdpcre-8.40/./configure--prefix=/usr--enable-utf8make&&makeinstallcd../2、安装Nginxtarzxfnginx-1.13.0.tar.gzcdnginx-1.13.0/#usingsystemOpenSSLyum-yinstallopensslopenssl-devel./configure--prefix=/usr/local--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'#usecustomizeOpenSSLsed-i"s#/.openssl##g"auto/lib/openssl/conf./configure--prefix=/usr/local--conf-path=/usr/local/etc/nginx/nginx.conf--error-日志路径=/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-openssl=/usr/local/ssl\--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.servicesystemctlenablememcached.servicesystemctlenable监督服务