使用pecl install 命令安装扩展库报错:bash: pecl: command not found

出现这个问题是因为没有安装php的扩展开发导致的,建议将php以及apache的开发都安装上,使用如下的命令。

yum install php-devel php-pear httpd-devel

如果还不行的话,执行:yum install php-pear php5-dev

pecl install channel://pecl.php.net/libevent-0.1.0 提示libevent installation [autodetect]: 时按回车

如果报错:ERROR: `/var/tmp/libevent/configure –with-libevent’ failed

执行:yum install libevent-devel

SELinux是什么意思

简单来说SELinux是一个安全加强工具  要关闭可以使用命令:setenforce 0

永久关闭可以修改文件/etc/sysconfig/selinux,找到以下内容:

SELINUX=enforcing
修改为:

SELINUX=disabled

这个工具一般情况不会用到,可以永久关闭。

 


 

 

Linux下的防火墙是iptables和ip6tables服务可以用下面的命令打开

 

长期性:

chkconfig iptables on

service iptabls start

chkconfig ip6tables on

service ip6tables start

注意:在用service命令前用service servicename status检查是否该服务已经打开了,如果没打开才用上面列出start选项, 否则应该用restart选项更改。

 

一次性:

如果是临时一次性的,则只需要按照上面的说明使用service命令就可以了。

在centos7上搭建Apache+mariadb+php7

  • 安装mariadb

# yum install mariadb-server mariadb

啟動及設定開機自動執行 MariaDB:

# systemctl start mariadb
# systemctl enable mariadb

安装Apache

# yum install httpd

跟著回答 “y” 後便會完成安裝, 然後輸入以下指令啟動及設定 Apache 開機自動執行:

# systemctl start httpd
# systemctl enable httpd

安裝 PHP 7

下载php7包到/usr/local/src/ 目录并解压

安装扩展包

# yum install gcc libxml2-devel pkgconfig openssl-devel bzip2-devel libpng-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel httpd-devel

进入php7解压包

# ./configure \
–prefix=/usr/local/php7/usr \
–with-config-file-path=/usr/local/php7/usr/etc \
–enable-mbstring \
–enable-zip \
–enable-bcmath \
–enable-pcntl \
–enable-ftp \
–enable-exif \
–enable-calendar \
–enable-sysvmsg \
–enable-sysvsem \
–enable-sysvshm \
–enable-wddx \
–with-curl \
–with-mcrypt \
–with-iconv \
–with-gmp \
–with-pspell \
–with-gd \
–with-jpeg-dir=/usr \
–with-png-dir=/usr \
–with-zlib-dir=/usr \
–with-xpm-dir=/usr \
–with-freetype-dir=/usr \
–enable-gd-native-ttf \
–enable-gd-jis-conv \
–with-openssl \
–with-pdo-mysql=/usr \
–with-gettext=/usr \
–with-zlib=/usr \
–with-bz2=/usr \
–with-recode=/usr \
–with-mysqli=/usr/bin/mysql_config \
–with-apxs2

然后

#make

#make test

#make install

复制 php.ini-development 文件到 /usr/local/lib 保存为 php.ini

编辑Apache配置文件 /etc/httpd/conf/httpd.conf  加入以下内容

LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>

保存后重启Apache

最小化安装centos7后上网设置

在虚拟机中以最小化方式安装centos7,后无法上网,因为centos7默认网卡未激活。

可以设置

文件 /etc/sysconfig/network-scripts/ifcfg-enp0s3

将 ONBOOT=no 改为 ONBOOT=yes

保存后重启网卡: service network restart

此时就可以上网了。

因为是最小化安装,此时ifconfig命令不能用,可用

命令:ip addr  查看分配网卡情况。

联网后可运行命令:

yum install net-tools

来安装ifconfig功能

此时virtualbox采用的网络连接方式为:网络地址转化(NAT)方式

CentOS 中 YUM 安装桌面环境

1. yum 的 group 指令

yum 可以以程序组的模式来安装成套的软件包。支持的软件包可以通过,

# yum grouplist

查询到。在 group 软件包中,

  • 对于 CentOS 6,Desktop、Desktop Platform、KDE Desktop、X Window System 是主要的桌面环境。
  • 对于 CentOS 7,有 KDE Plasma Workspaces 和 Gnome Desktop 两大桌面环境。

软件包列表根据系统使用的语言来显示,支持简体中文文件名。所以安装前最好用上述指令查询一下看看。如果系统使用了简体中文,而安装指令使用英文,可能会导致查询不到软件包这样的错误。下面的安装指令用的都是英语。

2. 安装图形桌面环境

CENTOS 7

CentOS 7 上的桌面环境安装包组合进行了调整,比以前要简单了。主要有两大阵营,KDE 和 GNOME。

因为没时间测试,只是预估着下面的指令应该能完成任务,请注意!

要安装 KDE 桌面环境(使用的是 Plasma 作为默认的桌面管理器了,很漂亮

# yum groupinstall “KDE Plasma Workspaces”

要安装 GNOME 环境,

# yum groupinstall “GNOME Desktop”

既然是桌面环境,可能还需要诸如字体、管理工具之类的,如,

# yum -y groupinstall “Graphical Administration Tools”
# yum -y groupinstall “Internet Browser”
# yum -y groupinstall “General Purpose Desktop”
# yum -y groupinstall “Office Suite and Productivity”
# yum -y groupinstall “Graphics Creation Tools”

3. 启用

从命令行直接启动图形桌面环境,

# startx

这样就会启动默认的 Gnome 或者 KDE 桌面环境。如果有人喜欢同时安装 GNOME 和 KDE,切换方法可以参考 CentOS 文档

如果希望启动时自动启动到图形桌面,需要修改启动配置。因为 CentOS 7 开始使用 systemd 管理器,其操作方式与之前版本有所不同。

CENTOS 7

CentOS 7 中直接使用 systemd 指令修改启动目的状态即可。

使用,

# systemctl get-default

可以查询到当前所设定的状态。multi-user.target 相当于以前的 level 3,也就是命令行终端;而 graphical.target 相当于以前的 level 5,也就是图形界面。

所以如果要设置默认启动到图形界面,则执行,

# systemctl set-default graphical.target

ng!