centos7安装php - 2877206/docs GitHub Wiki

1.查看安装软件包

yum list installed ll /opt

2.安装

2.1 安装nginx

安装: https://blog.csdn.net/jeikerxiao/article/details/72235302 https://www.jianshu.com/p/9a6c96ecc8b8 支持http2: https://yq.aliyun.com/articles/117130?t=t1

先安装openssl,再执行命令: ./configure --user=nginx --group=nginx --prefix=/opt/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module --conf-path=/opt/nginx/conf/nginx.conf
--sbin-path=/opt/nginx/sbin/nginx
--pid-path=/var/run/nginx.pid
--with-http_flv_module
--with-http_mp4_module
--with-http_gunzip_module
--with-http_secure_link_module
--with-http_v2_module
--with-openssl=/opt/openssl-1.1.0f

--with-pcre=/usr/local/pcre-8.36 指的是pcre-8.36 的源码路径。--with-zlib=/usr/local/zlib-1.2.8 指的是zlib-1.2.8 的源码路径。

make && make install

2.2 http2

https://yq.aliyun.com/articles/117130?t=t1

wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz tar xzf openssl.tar.gz cd openssl-1.1.0f ./config --prefix=/usr/local/openssl make && make install

mv /usr/bin/openssl /usr/bin/openssl.old mv /usr/include/openssl /usr/include/openssl.old ln -s /opt/openssl/bin/openssl /usr/bin/openssl ln -s /opt/openssl/include/openssl /usr/include/openssl #链接新库文件 mkdir /opt/openssl/lib64 ln -s /opt/openssl/lib/libssl.so /usr/local/lib64/libssl.so ln -s /opt/openssl/lib/libcrypto.so /usr/local/lib64/libcrypto.so #检查更新后的openssl依赖库是否是1.1.0f strings /usr/local/lib64/libssl.so | grep OpenSSL #显示结果表明已升级到最新版本链接库 OpenSSL 1.1.0f 25 May 2017 #配置openssl库文件的搜索路径 echo '/opt/openssl/lib' >> /etc/ld.so.conf #使修改后的搜索路径生效 ldconfig -v #查看openssl版本,结果显示升级成功 openssl version OpenSSL 1.1.0f 25 May 2017

nginx命令: 启动 $ /usr/local/nginx/sbin/nginx 重启: $ /usr/local/nginx/sbin/nginx –s reload 停止: $ /usr/local/nginx/sbin/nginx –s stop

2.3 安装php

https://segmentfault.com/a/1190000009909817

安装LNMP环境一般是先安装mysql/mariadb, 再安装nginx, 其次是安装php。

安装依赖包

[root@localhost ~]# yum -y install gcc [root@localhost ~]# yum -y install gcc++ [root@localhost ~]# yum -y install gcc-c++ [root@localhost ~]# yum -y install wget [root@localhost ~]# yum -y install make [root@localhost ~]# yum -y install libxml2 [root@localhost ~]# yum -y install libxml2-devel [root@localhost ~]# yum -y install openssl [root@localhost ~]# yum -y install openssl-devel [root@localhost ~]# yum -y install curl-devel [root@localhost ~]# yum -y install libjpeg-devel [root@localhost ~]# yum -y install libpng-devel [root@localhost ~]# yum -y install freetype-devel [root@localhost ~]# yum -y install bison [root@localhost ~]# yum -y install autoconf

yum -y install gcc gcc++ gcc-c++ wget make libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel bison autoconf

创建用户及用户组

创建php用户组

> 创建php用户组(-r选项是创建一个系统用户组的意思)

`[root@localhost ~]# groupadd -r php`

创建用户并加入到php系统用户组

> 添加新用户

> -r: 添加系统用户( 这里指将要被创建的系统用户php )

> -g: 指定要创建的用户所属组( 这里指添加到新系统用户php到php系统用户组 )

> -s: 新帐户的登录shell( `/sbin/nologin` 这里设置为将要被创建系统用户php不能用来登录系统 )

> -d: 新帐户的主目录( 这里指定将要被创建的系统用户php的家目录为 `/usr/local/php` )

> -M: 不要创建用户的主目录( 也就是说将要被创建的系统用户php不会在 `/home` 目录下创建 `php` 家目录 )

[root@localhost ~]# useradd -r -g php -s /sbin/nologin -d /usr/local/php -M php [root@localhost ~]# useradd -r -g php -s /sbin/nologin -d **/opt/php** -M php

./configure \ --prefix=/opt/php \ --exec-prefix=/opt/php \ --bindir=/opt/php/bin \ --sbindir=/opt/php/sbin \ --includedir=/opt/php/include \ --libdir=/opt/php/lib/php \ --mandir=/opt/php/php/man \ --with-config-file-path=/opt/php/etc \ --with-mysql-sock=/tmp/mysql.sock \ --with-mcrypt \ --with-mhash \ --with-openssl \ --with-mysqli=shared,mysqlnd \ --with-pdo-mysql=shared,mysqlnd \ --with-gd \ --with-iconv \ --with-zlib \ --enable-zip \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-mbregex \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --with-curl \ --with-jpeg-dir \ --with-freetype-dir \ --enable-opcache \ --enable-fpm \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --without-gdbm \ --enable-fast-install \ --disable-fileinfo