Ubuntu服务器配置Lnmp环境和编译安装相应的PHP扩展

Ubuntu服务器配置Lnmp环境和安装相应的PHP扩展:

先更新源:

apt update
apt-get update

1.Ubuntu下编译安装Nginx

Nginx官方下载地址:

http://nginx.org/en/download.html

我选择的是
http://nginx.org/download/nginx-1.18.0.tar.gz

下载后进行解压,然后先安装编译需要的依赖:

apt-get install libpcre3g

apt-get install libpcre3-dev

apt-get install zlib1g-dev

apt-get install libssl-dev

apt-get install build-essentialapt-get install openssl libssl-dev

编译前修改nginx版本号,名称。

/nginx(源码)/src/core/nginx.h

\#define nginx_version 1008001

\#define NGINX_VERSION "1.0.19"

\#define NGINX_VER "myth/" NGINX_VERSION

修改src/http/ngx_http_header_filter_module.c(HTTP ResponseHeader)

static char ngx_http_server_string[] = "Server: myth" CRLF;

修改src/http/ngx_http_special_response.c(修改错误页的底部Footer)

static u_char ngx_http_error_tail[] =

"<hr><center>myth</center>" CRLF

"</body>" CRLF

"</html>" CRLF

隐藏版本号

http {
    
    

server_tokens off;

}

进行编译和安装,根据自己的实际环境和需求进行编译安装即可。

./configure 
--prefix=/usr/local/nginx 
--with-http_ssl_module 
--with-openssl= 
--with-http_realip_module

make
make install

2.Ubuntu下编译安装PHP:

PHP7.1版本下载:

wget http://am1.php.net/distributions/php-7.1.4.tar.gz

PHP7.3版本下载

wget https://www.php.net/distributions/php-7.3.18.tar.gz

下载后进行解压,然后先安装编译需要的依赖:

apt-get install libxml2 libxml2-dev

apt-get install openssl

apt-get install libssl-dev apt-get install libgtk2.0-dev

apt install libzip-dev

apt-get install libcurl4-gnutls-dev

apt-get install libbz2-dev

sudo apt-get install libbz2-dev

sudo apt-get install libjpeg-dev

apt-get install libmcrypt-dev

apt-get install mcrypt

apt-get install curl 

apt-get install libcurl4-gnutls-dev

apt-get install autoconf 

apt-get install libcurl4-openssl-dev

进行编译安装,根据自己的实际需求进行配置

./configure 
--prefix=/usr/local/php 
--with-fpm-user=www 
--with-fpm-group=www 
--with-config-file-path=/usr/local/php/etc 
--enable-fpm 
--with-gd 
--with-jpeg-dir 
--with-png-dir 
--with-zlib-dir 
--with-freetype-dir 
--enable-gd-native-ttf 
--with-mcrypt 
--with-gettext 
--with-mhash 
-with-pdo-mysql=mysqlnd 
--enable-mysqlnd 
--enable-shmop 
--enable-soap 
--enable-sysvmsg 
--enable-sysvsem 
--enable-sysvshm 
--enable-mbstring 
--enable-opcache 
--enable-fpm 
--enable-zip 
--enable-bcmath 
--with-pear 
--with-pcre-dir 
--with-bz2 
--enable-exif 
--with-openssl 
--with-libxml-dir 
--with-pcre-regex 
--with-zlib 
--with-iconv-dir=/usr/local/libiconv 
--enable-xml 
--enable-pcntl 
--enable-sockets 
--with-xmlrpc 
--enable-mbregex 
--with-curl 
--disable-debug

猜你喜欢

转载自blog.csdn.net/qq_36228377/article/details/123154384
今日推荐