源码包安装

源码包安装

 三种:rpm、yum、源码包安装

1、源码安装nginx

- 下载源码包

  ```bash
  wget http://nginx.org/download/nginx-1.18.0.tar.gz
  
  tar -xf nginx-1.18.0.tar.gz -C /opt
  
  cd /opt/nginx-1.18.0
  
  # 就可以看到nginx源代码
  
  
  # 第二种方式:https://repo.huaweicloud.com/epel/7/x86_64/Packages/n/
  
  wget https://repo.huaweicloud.com/epel/7/x86_64/Packages/n/nginx-1.16.1-3.el7.x86_64.rpm
  ``

- 直接编译

  ```bash
  # 编译前,系统检测
  [root@www nginx-1.18.0]# ./configure
  
  # 如果出现对应的错误,则执行下面命令
  [root@www nginx-1.18.0]# yum install pcre pcre-devel -y
  [root@www nginx-1.18.0]# yum install zlib zlib-devel -y
  
  # 开始编译
  make 
  	-j : 使用多核编译
  	
  

> 这里是引用

# 安装
  make install PROFIX=/usr/local
  
  # 测试
  [root@www ~]# /usr/local/nginx/sbin/nginx 
  
  # 环境变量
  
  ## 添加环境变量
  /etc/profile   # 所用用户的环境变量
  /root/.bash_profile  # 当前用户的环境变量
  
  NGINX_HOME=/usr/local/nginx/sbin
  PATH=$PATH:$NGINX_HOME
  export PATH
  
  /usr/local/sbin
  /usr/local/bin
  /usr/sbin
  /usr/bin
  /root/.local/bin
  /root/bin
  /root/.local/bin
  /root/bin
  /usr/local/nginx/sbin
   

源码包编译 PHP

第一步 :下载安装PHP
wget  -O  /opt/ php.tar.gz     https://www.php.net/distributions/php-7.4.16.tar.gz

或者
cd/opt
wget  php.tar.gz     https://www.php.net/distributions/php-7.4.16.tar.gz

第二步 解压
tar xvf  php.tar.gz 

第三步 直接编译

 1. #编译测试 
   . - 在cd /opt/php-7.4.16/  目录下测试
       输入   ./configure
  
2.# 如果出现对应的错误,则执行下面命令

#报错

#解决
 yum install libxml2 ibxml2-devel 

 **# libxml2安装包有的话无需添加**

#报错  
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:

No package 'sqlite3' found
#解决

yum install sqlite sqlite-devel 

**# sqlite安装包有的话无需添加**

   
# 开始编译   make    	-j : 使用多核编译 	
   
   > 这里是引用
   
   # 安装   make install PROFIX=/usr/local

  
3. #执行 ./configure 命令时,可能会因为 Linux 尚未安装某些库而报错,
安装即可解决。
配置成功后会看到授权信息
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

4.#HP 源码的 ext 目录中,有大量的扩展 ls

[root@mm_centos php-7.2.12]# ls
acinclude.m4      configure.ac     libtool             modules                   README.NEW-OUTPUT-API             scripts
aclocal.m4        CONTRIBUTING.md  LICENSE             NEWS                      README.PARAMETER_PARSING_API      server-tests-config.php
appveyor          CREDITS          ltmain.sh           pear                      README.REDIST.BINS                server-tests.php
build             ext              main                php7.spec                 README.RELEASE_PROCESS            snapshot
buildconf         EXTENSIONS       makedist            php7.spec.in              README.SELF-CONTAINED-EXTENSIONS  stamp-h.in
buildconf.bat     footer           Makefile            php.gif                   README.STREAMS                    tests
CODING_STANDARDS  generated_lists  Makefile.frag       php.ini-development       README.SUBMITTING_PATCH           travis
config.guess      genfiles         Makefile.fragments  php.ini-production        README.TESTING                    TSRM
config.log        header           Makefile.gcov       README.EXT_SKEL           README.TESTING2                   UPGRADING
config.nice       include          Makefile.global     README.GIT-RULES          README.UNIX-BUILD-SYSTEM          UPGRADING.INTERNALS
config.status     INSTALL          Makefile.objects    README.input_filter       README.WIN32-BUILD-SYSTEM         vcsclean
config.sub        install-sh       missing             README.MAILINGLIST_RULES  run-tests.php                     win32
configure         libs             mkinstalldirs       README.md                 sapi                              Zend
[root@VM_139_38_centos php-7.2.12]# ls ext/
bcmath      dba                 filter   imap       mysqli   pcre          pdo_pgsql   recode      soap      sysvsem    xmlrpc
bz2         dom                 ftp      interbase  mysqlnd  pdo           pdo_sqlite  reflection  sockets   sysvshm    xmlwriter
calendar    enchant             gd       intl       oci8     pdo_dblib     pgsql       session     sodium    tidy       xsl
com_dotnet  exif                gettext  json       odbc     pdo_firebird  phar        shmop       spl       tokenizer  zend_test
ctype       ext_skel            gmp      ldap       opcache  pdo_mysql     posix       simplexml   sqlite3   wddx       zip
curl        ext_skel_win32.php  hash     libxml     openssl  pdo_oci       pspell      skeleton    standard  xml        zlib
date        fileinfo            iconv    mbstring   pcntl    pdo_odbc      readline    snmp        sysvmsg   xmlreader


默认路径  /usr/bin/php
    # 测试
           [root@2021~]#  /usr/bin/php
  
  # 环境变量
  
5.  # 添加环境变量
  /etc/profile   # 所用用户的环境变量
  /root/.bash_profile  # 当前用户的环境变量
  
  phg_mm=/usr/bin/
  PATH=$PATH:$phg_mm
  export PATH
 
6.  #加载生效
     source /root/.bash_profile
7.正常安装使用
     
     php -m

你可能感兴趣的:(linux,基础,linux,nginx)