Centos 7 Nginx + PHP 安装步骤

news/2024/7/3 11:59:16

Centos 7 下的 PHP7/Nginx/Memcached 安装步骤。对的,没有Mysql,有RDS懒得装Mysql了。

一、获取相关开源程序

1、安装环境所需的程序库

sudo -s
LANG=C
yum -y update
yum remove mariadb*
yum -y install patch make cmake gcc gcc-c++ bison flex file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel gmp-devel gettext gettext-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers vim-minimal nano  gmp-devel unzip libcap diffutils readline-devel libxslt libxslt-devel ntp wget ctags libedit libedit-devel libaio git mailx jwhois bind-utils systemd systemd-devel libtidy libtidy-devel
yum -y install supervisor
yum -y install memcached

2、准备环境变量

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/ldconfig

3、下载程序源码包

cd /usr/local/src
wget http://7xk96f.com1.z0.glb.clouddn.com/software/libiconv/libiconv-1.15.tar.gz
wget -O php-7.1.5.tar.gz http://cn2.php.net/get/php-7.1.5.tar.gz/from/this/mirror
wget http://7xk96f.com1.z0.glb.clouddn.com/software/mcrypt/libmcrypt-2.5.8.tar.gz
wget http://7xk96f.com1.z0.glb.clouddn.com/software/mcrypt/mcrypt-2.6.8.tar.gz
wget http://7xk96f.com1.z0.glb.clouddn.com/software/mhash/mhash-0.9.9.9.tar.gz
wget http://7xk96f.com1.z0.glb.clouddn.com/software/icu/icu4c-58_2-src.tgz
wget http://7xk96f.com1.z0.glb.clouddn.com/software/libmemcached/libmemcached-1.0.18.tar.gz
wget http://7xk96f.com1.z0.glb.clouddn.com/software/pcre/pcre-8.40.tar.gz
wget http://7xk96f.com1.z0.glb.clouddn.com/software/openssl/openssl-1.1.0e.tar.gz
wget http://7xk96f.com1.z0.glb.clouddn.com/software/nginx/nginx-1.13.0.tar.gz
wget http://pecl.php.net/get/msgpack-2.0.2.tgz
wget http://pecl.php.net/get/igbinary-2.0.1.tgz
wget http://pecl.php.net/get/memcached-3.0.3.tgz
wget http://pecl.php.net/get/redis-3.1.2.tgz
wget http://pecl.php.net/get/swoole-2.0.7.tgz

二、安装PHP 7(FastCGI模式)

1、编译安装PHP 7 所需的支持库:

tar zxf libiconv-1.15.tar.gz
cd libiconv-1.15/
./configure --prefix=/usr
make && make install
cd ../

tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure --prefix=/usr
make && make install
ldconfig
cd libltdl/
./configure --prefix=/usr  --enable-ltdl-install
make && make install
cd ../../

tar zxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure --prefix=/usr
make && make install
cd ../

tar zxf mcrypt-2.6.8.tar.gz && cd mcrypt-2.6.8/
/sbin/ldconfig
./configure --prefix=/usr
make && make install
cd ../

tar zxf icu4c-58_2-src.tgz && cd icu/source/
./configure --prefix=/usr
make && make install
cd ../../

tar zxf openssl-1.1.0e.tar.gz && cd openssl-1.1.0e
./config --prefix=/usr/local/ssl shared zlib-dynamic
make && make install
echo /usr/local/ssl/lib > /etc/ld.so.conf.d/openssl-x86_64.conf
/sbin/ldconfig
cd ../

2、编译安装PHP(FastCGI模式)

tar zxf php-7.1.5.tar.gz
cd php-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-dir
make ZEND_EXTRA_LIBS='-liconv'
make install

cp php.ini-production /usr/local/etc/php.ini
cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service
systemctl enable php-fpm.service

3、编译安装PHP扩展模块

tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure --prefix=/usr
make && make install
cd ../

tar zxf msgpack-2.0.2.tgz
cd msgpack-2.0.2
phpize
./configure
make && make install
cd ../

tar zxf igbinary-2.0.1.tgz
cd igbinary-2.0.1
phpize
./configure
make && make install
cd ../

tar zxf memcached-3.0.3.tgz
cd memcached-3.0.3
phpize
./configure --enable-memcached-igbinary --enable-memcached-json --enable-memcached-msgpack
make && make install
cd ../

tar zxf redis-3.1.2.tgz
cd  redis-3.1.2
phpize
./configure
make && make install
cd ../

tar zxf swoole-2.0.7.tgz
cd swoole-2.0.7
phpize
./configure  --enable-coroutine
make && make install
cd ../

三、安装Nginx

1、安装Pcre库

tar zxf pcre-8.40.tar.gz
cd pcre-8.40/
./configure --prefix=/usr --enable-utf8
make && make install
cd ../

2、安装Nginx

tar zxf nginx-1.13.0.tar.gz
cd nginx-1.13.0/

#using system OpenSSL
yum -y install openssl openssl-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'

#use customize OpenSSL
sed -i "s#/.openssl##g" auto/lib/openssl/conf
./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-openssl=/usr/local/ssl \
--with-cc-opt='-O2'

make && make install
cd ../
mkdir /var/log/nginx
mkdir /var/lib/nginx

四、收尾

1、添加www用户

/usr/sbin/groupadd www
/usr/sbin/useradd -M -g www www

2、优化内核

#for aliyun
cat >>/etc/security/limits.conf<<eof
* soft nproc 65535
* hard nproc 65535
eof

#other
cat >>/etc/security/limits.conf<<eof
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
eof

echo "fs.file-max=65535" >> /etc/sysctl.conf

3、设置开机启动

systemctl enable nginx.service
systemctl enable php-fpm.service
systemctl enable memcached.service
systemctl enable supervisord.service

http://www.niftyadmin.cn/n/3336794.html

相关文章

中国区优化的Docker安装脚本

说明 为了方便中国区的用户安装不同版本的docker&#xff0c;我们在这里提供针对中国网络环境优化的安装脚本。它们使用中国的软件包仓库&#xff08;在此感谢USTC&#xff09;。 用法 使用需要的docker版本替换以下脚本中的<docker-version-you-want> curl -sSL https:/…

字符设备驱动模型【转】

本文转载自&#xff1a;http://blog.csdn.net/coding__madman/article/details/51347290 字符驱动编程模型&#xff1a; 1. 设备描述结构cdev 1.1 结构定义 1.2 设备号 1.3 设备操作集 在Linux系统中,设备的类型非常繁多&#xff0c;如&#xff1a;字符设备&#xff0c;块设…

LINUX编程实战指发送UDP消息

最近调试媒体服务器&#xff0c;发现被叫的媒体流总是抖动的厉害&#xff0c;不清楚是网络原因还是媒体服务器的代码问题。 为了方便排查问题&#xff0c;我编写了一个UDP发送的小工具。根据传入目的地的IP、PORT和发送的时长。该工具就可以按照20ms的间隔进行重复发送RTP流。…

ioctl--字符设备的控制技术【转】

本文转载自&#xff1a;http://blog.csdn.net/coding__madman/article/details/51356313 字符设备的控制 1. 字符设备控制理论 1.1 作用 大部分驱动程序除了需要提供读写设备的能力外&#xff0c;还需要具备控制设备的能力。比如&#xff1a;改变波特率 1.2 应用程序接口 在用户…

linux中oops信息的调试及栈回溯【转】

本文转载自&#xff1a;http://blog.csdn.net/kangear/article/details/8217329 原文地址&#xff1a;http://blog.micro-studios.com/?p615#comment-1069 看后感想&#xff1a;這点比 ldd3上讲的都仔细 2012年11月29日11:24:17&#xff1a;有BUG_ON就不用反汇编了。。。 201…

如何关闭CenOS/RedHat的X Windows

因为要安装CUDA驱动&#xff0c;CUDA驱动不能X Windows下安装&#xff0c;所以搜索关闭X Windows的方法。 现在总结如下&#xff1a; root用户使用init 3&#xff0c;切换到命令行模式&#xff1b; root用户使用init 5,切换到X Windows图形界面模式

总线设备驱动模型【转】

本文转载自&#xff1a;http://blog.csdn.net/coding__madman/article/details/51428400 总线驱动设备模型&#xff1a; 1. 总线设备驱动模型概述 随着技术的不断进步&#xff0c;系统的拓扑结构也越来越复杂&#xff0c;对热插拔&#xff0c;跨平台移植性的要求也越来越高&…

混杂设备动态次设备号分析【转】

本文转载自&#xff1a;http://blog.csdn.net/yongan1006/article/details/6778285 今天看驱动源码时&#xff0c;发现一个MISC_DYNAMIC_MINOR宏&#xff0c;于是分析了一下内核源码。先粘出源码。在misc_register函数中&#xff0c;有如下语句&#xff1a; if (misc->minor…