linux(centos)环境下三种安装软件的方式,rpm、yum、手动编译
rpm:
.rpm相当于windows底下的.exe,如果有linux图形界面,双击就能运行安装。就是二进制的包
安装: rpm -ivh 完整包名,如 rpm -ivh sphinx-2.2.6-1.rhel6.x86_64.rpm.bak
卸载: rpm -e 包名,如 rpm -e sphinx
查询: rpm -q sphinx, 查询所有已安装软件: rpm -qa 查询装在哪里: rpm -ql sphinx
yum:
yum与php的composer类似,在互联网上有好多分布式的仓库,软件非常的齐全。你只需要说你想安装什么软件,会自动帮你寻找、下载、安装。遇到依赖性问题,用yum
安装:yum install httpd
卸载:yum remove httpd 注意:yum remove httpd* 会删除httpd-*所有的包
查询:yum list installed
软件编译:
软件编译就是把源代码(c,c++)编译成2进制
基础性的东西用yum安装,可能n多软件都需要它,用yum安装到默认位置,方便其他软件使用。如:
yum install gcc gcc-c++ automake autoconf libtool
如果安装过会提示
具体的应用型软件,可以编译安装。如:
memecached、nginx、php 下载最新stable版本,注意要下载源代码,放到usr/local/src
软件编译三部曲:
1、配置。configure --prefix=/安装路径 configure --prefix=/usr/local/nginx
如果还有其他选项,./configure --help 来查看
2、make 编译 [生成2进制] 编译过程一般不是那么顺利,缺啥补啥
3、make install [把生成的2进制复制到 prefix 指定的安装路径里] # install要求有root权限
其中2,3可以合写成make && make install
编译安装nginx:下载编译安装就行了
看ip通不通 ping 192.168.1.251
看ip下的端口通不通 telnet 192.168.1.251 80
如果网络通,80端口不通,关闭防火墙试试linux关闭防火墙 service iptables stop
编译安装php:
1、安装基本的软件包
yum install gcc gcc-c++ automake autoconf libtool gd zlib zlib-devel openssl openssl-devel pcre pcre-devel libxml-2 libxml-2-devel libjpeg libjpeg-devel libpng libpng-devel curl curl-devel freetype freetype-devel
2、下载php5.6,如果要下最新的php7,要注意memcache、redis等扩展已经跟上来了。解压,cd进去
3、配置。
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir=/usr/local/freetype \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-mysqlnd \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--with-mcrypt \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-gettext \
--disable-fileinfo \
--enable-opcache
--enable-fpm是让php作为独立进程来运行(默认占据9000端口)
如果是和apache配合,php一般是作为apache的模块来使用
3、make && make install
当然,也可以试试 yum install nginx php mysql ,比较傻瓜一点