linux搭建nginx1.16+php7.3 详细步骤

25 阅读3分钟

​linux系统版本:CentOS Linux release 7.7.1908 (Core)

搭建环境的根目录:/usr/local/webserver

下载软件存放目录:/usr/local/src

一、安装nginx

cd /usr/local/src

tar zxvf nginx-1.16.1.tar.gz

cd nginx-1.16.1

./configure --prefix=/usr/local/webserver/nginx \--with-http_ssl_module  \--with-pcre=/usr/local/src/pcre-8.43 \--with-zlib=/usr/local/src/zlib-1.2.11 \--with-openssl=/usr/local/src/openssl-1.1.1d

make install

/usr/local/webserver/nginx/sbin/nginx

测试nginx是否启动成功:curl 127.0.0.1

出现类似以下截图的提示,说明到这边nginx就安装成功了

nginx 报错解决

问题1:./configure: error: C compiler cc is not found

解决安装gcc-c++包 :yum -y install gcc-c++

二、安装php

yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libXpm libXpm-devel openldap openldap-devel libmcrypt libmcrypt-devel gd gd-devel gmp-devel 

tar zxvf php-7.3.14.tar.gz

cd php-7.3.14


 ./configure --prefix=/usr/local/webserver/php7.3 --with-config-file-scan-dir=/opt/php/etc/php.d --disable-debug --with-pic --disable-rpath --with-bz2 --without-gdbm --with-gettext --with-gmp --enable-mbregex --enable-mbstring --with-iconv --with-openssl=/usr --with-zlib --with-layout=GNU --enable-exif --enable-ftp --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-shmop --enable-calendar --enable-xml --with-pear --enable-fpm --with-pdo-mysql --with-curl --with-ldap --with-gd --with-freetype-dir  --with-mysqli  --enable-soap --enable-bcmath --with-jpeg-dir=/usr --with-xpm-dir=/usr --with-libdir=lib64 --with-fpm-user=www --with-fpm-group=www

make && make install

安装完成 出现以下提示

php配置:

cd /usr/local/webserver/php7.3/etc/

cp php-fpm.conf.default php-fpm.conf

groupadd www

useradd -g www www

mkdir -p /data/webroot/test

vim php-fpm.conf文件增加两行:

user = www

group = www

pid = run/php-fpm.pid

vim /data/webroot/test/phpinfo.php增加以下