centos 6.5 yum php(centos7更换yum源)

如何在CentOS 7/6.5/6.4 下安装PostgreSQL 9.3 与 phpPgAdmin

PostgreSQL是一个强大开源的对象关系类型数据库系统,它能运行于几乎所有主要的操作系统,包括Linux、Unix(AIX、BSD、HP-UX、SGI IRIX、Mac OS、Solaris、Tru64)、Windows OS。在这篇教程里,我们将学习如何在CentOS7/6.5/6.4 server中建立PostgreSQL。

1.安装PostgreSQL

首先根据你的服务器架构添加PostgreSQL库:

对CentOS 6.x 32bit:

rpm-Uvh 1.noarch.rpm

对CentOS 6.x 64bit:

rpm-Uvh

对CentOS 7 64bit:

rpm-Uvh

对于其它的发行版,可查看以下链接并建立库:

使用以下命令来更新库:

yum update

使用以下命令来安装PostgreSQL:

yum install postgresql93-server postgresql93-contrib

使用以下命令来初始化PostgreSQL数据库:

在CentOS 6.x系统中:

service postgresql-9.3 initdb

在CentOS 7系统中:

/usr/pgsql-9.3/bin/postgresql93-setup initdb

然后启动PostgreSQL服务并使之开机自启:

在CentOS 6.x系统中:

service postgresql-9.3 start

chkconfig postgresql-9.3 on

在CentOS 7系统中:

systemctl enable postgresql-9.3

systemctl start postgresql-9.3

2.调整Iptables/Firewall

接下来调整防火墙出站规则:

在CentOS 6.x系统中:

vi/etc/sysconfig/iptables

并添加以下行

-A INPUT-m state--state NEW-m tcp-p tcp--dport 5432-j ACCEPT

-A INPUT-m state--state NEW-m tcp-p tcp--dport 80-j ACCEPT

退出并保存文件。重启iptables服务:

service iptables restart

在CentOS系统中:

firewall-cmd--permanent–add-port=5432/tcp

firewall-cmd--permanent–add-port=80/tcp

firewall-cmd--reload

3.访问PostgreSQL常用的命令提示符

默认情况下数据库名和用户名都是postgres。切换至用户以执行相关操作:

su– postgres

输入以下命令登陆:

psql

会有以下样例输出:

psql(9.3.5)

Type"help" for help.

Postgres=#

可通过输入\q退出postgresql返回命令终端:

4.设置用户密码

登陆至postgres命令提示符界面

su– postgres

psql

然后使用命令设置密码

postgres=#\password postgres

Enter new password:

Enter it again:

postgres=#\q

输入命令以建立PostgreSQL系统管理工具

postgres=# CREATE EXTENSION adminpack;

CREATE EXTENSION

5.创建用户和数据库

例如:用户名:senthil密码:centos数据库名:mydb

转到postgres用户

su– postgres

创建用户senthil

$ createuser senthil

创建数据库

$ createdb mydb

现在登陆至psql提示符界面,为用户senthil设置密码及授权对数据库mydb的访问:

$ psql

psql(9.3.5)

Type"help" for help.

postgres=# alter user senthil with encrypted password'centos';

ALTER ROLE

postgres=# grant all privileges on database mydb to senthil;

GRANT

postgres=#

6.删除用户和数据库

首先转到postgres界面

su– postgres

输入命令

$ dropdb<database-name>

删除用户名可输入

$ dropuser<user-name>

7.配置PostgreSQL-MD5认证

MD5认证需要客户端提供一个MD5-encrypted密码以便身份验证。你需要编辑/var/lib/pgsql/9.3/data/pg_hba.conf文件:

vi/var/lib/pgsql/9.3/data/pg_hba.conf

添加或修改的行如下:

[...]

# TYPE DATABASE USER ADDRESS METHOD

#"local" is for Unix domain socket connections only

local all all md5

# IPv4 local connections:

host all all 127.0.0.1/32 md5

host all all 192.168.1.0/24 md5

# IPv6 local connections:

host all all::1/128 md5

[...]

重启postgresql服务以应用更改

在CentOS 6.x系统中

service postgresql-9.3 restart

在CentOS 7系统中

systemctl restart postgresql-9.3

8.配置PostgreSQL-Configure TCP/IP

默认情况下,TCP/IP连接是不可行的,所以其他计算机用户不能连接到postgresql。编辑文件/var/lib/pgsql/9.3/data/postgresql.conf可以允许连接:

vi/var/lib/pgsql/9.3/data/postgresql.conf

找到下面的行:

[...]

#listen_addresses='localhost’

[...]

#port= 5432

[...]

把两行都取消并设置为你的postgresql服务器IP地址或设置为“*”监听所有客户端。如下所示:

listen_addresses='*'

port= 5432

重启以应用更改

在CentOS6.x系统中:

/etc/init.d/postgresql-9.3 restart

在CentOS7系统中:

systemctl restart postgresql-9.3

9.使用phpPgAdmin管理PostgreSQL

phpPgAdmin是使用PHP编写的基于web的管理工具,用于管理PostgreSQL。它只适用与PostgreSQL RPM库。

如果你没有添加PostgreSQL库,你可以添加EPEL库。

可根据下面的链接在CentOS 6.x中建立EPEL库

CentOS 7的话参考下面的链接

使用命令更新库

yum update

现在输入命令安装phpPgAdmin:

yum install phpPgAdmin httpd

注意phpPgAdmin区分大小写,要准确使用上面所示的大小写!

默认你可以使用访问phpPgAdmin。若要远程访问需要继续:

编辑文件/etc/httpd/conf.d/phpPgAdmin.conf

vi/etc/httpd/conf.d/phpPgAdmin.conf

修改如下加粗的部分:

[...]

Alias/phpPgAdmin/usr/share/phpPgAdmin

<Location/phpPgAdmin>

<IfModule mod_authz_core.c>

# Apache 2.4

Require all granted

#Require host example.com

</IfModule>

<IfModule!mod_authz_core.c>

# Apache 2.2

Order deny,allow

Allow from all

# Allow from.example.com

</IfModule>

</Location>

启动或重启Apache服务

在CentOS 6.x系统中

service httpd start

chkconfig httpd on

在CentOS 7系统中

systemctl enable httpd

systemctl start httpd

现在打开浏览器并转到。终于看到下面的界面了!

使用你之前创建的用户登录,我的是用户senthil密码CentOS。

你可能会遇到:Login failed。

这是因为SELLinux可能限制用户连接到PostgreSQL,只需输入以下命令更改即可:

setsebool-P httpd_can_network_connect_db 1

现在你应该能正常登录了。

如何在Ubuntu / CentOS 6.x上安装Bugzilla 4.4

1.安装依赖程序

安装Bugzilla相当简单。这篇文章特别针对Ubuntu 14.04和CentOS 6.5两个版本(不过也适用于更老的版本)。

为了获取并能在Ubuntu或CentOS系统中运行Bugzilla,我们要安装Apache网络服务器(启用SSL),MySQL数据库服务器和一些需要来安装并配置Bugzilla的工具。

要在你的服务器上安装使用Bugzilla,你需要安装好以下程序:

Perl(5.8.1或以上)

MySQL

Apache2

Bugzilla

Perl模块

使用apache的Bugzilla

正如我们所提到的本文会阐述Ubuntu 14.04和CentOS 6.5/7两种发行版的安装过程,为此我们会分成两部分来表示。

以下就是在你的Ubuntu 14.04 LTS和CentOS 7机器安装Bugzilla的步骤:

准备所需的依赖包:

你需要运行以下命令来安装些必要的包:

Ubuntu版本:

$ sudo apt-get install apache2 mysql-server libapache2-mod-perl2 libapache2-mod-perl2-dev libapache2-mod-perl2-doc perl postfix make gcc g++

CentOS版本:

$ sudo yum install httpd mod_ssl mysql-server mysql php-mysql gcc perl* mod_perl-devel

注意:请在shell或者终端下运行所有的命令并且确保你用root用户(sudo)操作机器。

2.启动Apache服务

你已经按照以上步骤安装好了apache服务,那么我们现在需要配置apache服务并运行它。我们需要用sodo或root来敲命令去完成它,我们先切换到root连接。

$ sudo-s

我们需要在防火墙中打开80端口并保存改动。

# iptables-I INPUT-p tcp--dport 80-j ACCEPT

# service iptables save

现在,我们需要启动服务:

CentOS版本:

# service httpd start

我们来确保Apache会在每次你重启机器的时候一并启动起来:

#/sbin/chkconfig httpd on

Ubuntu版本:

# service apache2 start

现在,由于我们已经启动了我们apache的http服务,我们就能在默认的127.0.0.1地址下打开apache服务了。

3.配置MySQL服务器

现在我们需要启动我们的MySQL服务:

CentOS版本:

# chkconfig mysqld on

# service start mysqld

Ubuntu版本:

# service mysql-server start

用root用户登录连接MySQL并给Bugzilla创建一个数据库,把你的mysql密码更改成你想要的,稍后配置Bugzilla的时候会用到它。

CentOS 6.5和Ubuntu 14.04 Trusty两个版本:

# mysql-u root-p

# password:(You'll need to enter your password)

# mysql> create database bugs;

# mysql> grant all on bugs.* to root@localhost identified by"mypassword";

#mysql> quit

注意:请记住数据库名和mysql的密码,我们稍后会用到它们。

4.安装并配置Bugzilla

现在,我们所有需要的包已经设置完毕并运行起来了,我们就要配置我们的Bugzilla。

那么,首先我们要下载最新版的Bugzilla包,这里我下载的是4.5.2版本。

使用wget工具在shell或终端上下载:

wget/pub/mozilla.org/webtools/bugzilla-4.5.2.tar.gz

你也可以从官方网站进行下载。

从下载下来的bugzilla压缩包中提取文件并重命名:

# tar zxvf bugzilla-4.5.2.tar.gz-C/var/www/html/

# mv-v bugzilla-4.5.2 bugzilla

注意:这里,/var/w/html/bugzilla/就是Bugzilla主目录.

现在,我们来配置buzilla:

# cd/var//html/bugzilla/

./checksetup.pl--check-modules

检查完成之后,我们会发现缺少了一些组件,我们需要安装它们,用以下命令即可实现:

# cd/var/www/html/bugzilla

# perl install-module.pl--all

这一步会花掉一点时间去下载安装所有依赖程序,然后再次运行checksetup.pl--check-modules命令来验证有没有漏装什么。

现在我们需要运行以下这条命令,它会在/var/www/html/bugzilla路径下自动生成一个名为localconfig的文件。

#./checksetup.pl

确认一下你刚才在localconfig文件中所输入的数据库名、用户和密码是否正确。

# nano./localconfig

# checksetup.pl

如果一切正常,checksetup.pl现在应该就成功地配置Bugzilla了。

现在我们需要添加Bugzilla至我们的Apache配置文件中。那么,我们需要用文本编辑器打开/etc/httpd/conf/httpd.conf文件(CentOS版本)或者/etc/apache2/apache2.conf文件(Ubuntu版本):

CentOS版本:

# nano/etc/httpd/conf/httpd.conf

Ubuntu版本:

# nano etc/apache2/apache2.conf

现在,我们需要配置Apache服务器,我们要把以下配置添加到配置文件里:

<VirtualHost*:80>

DocumentRoot/var/www/html/bugzilla/

</VirtualHost>

<Directory/var/www/html/bugzilla>

AddHandler cgi-script.cgi

Options+Indexes+ExecCGI

DirectoryIndex index.cgi

AllowOverride Limit FileInfo Indexes

</Directory>

接着,我们需要编辑.htaccess文件并用“#”注释掉顶部“Options-Indexes”这一行。

让我们重启我们的apache服务并测试下我们的安装情况。

CentOS版本:

# service httpd restart

Ubuntu版本:

# service apache2 restart

这样,我们的Bugzilla就准备好在我们的Ubuntu 14.04 LTS和CentOS 6.5上获取bug报告了,你就可以通过本地回环地址或你网页浏览器上的IP地址来浏览bugzilla了。

centos5 源码安装Nginx + mysql + apache + php的方法

主要依照的是张宴的一篇博文《》,安装的软件是也是从他提供的列表中下载,这里都是tar.gz格式,如果更希望是rpm格式的话,提供一个网址《》这里列出了比较完全的下载包。

我安装的系统:Centos5

1、下载;

我安装的下载来自张宴博文下的地址,下载保存的是home下自己目录的一个文件夹下:

复制代码

   

代码如下:

cd/home/xuxx/software

   wget

   wget

   wget

   wget

   wget

   wget

   wget

   wget

   wget

   wget

   wget

   wget

   wget

   wget

2、准备编译安装环境,需要编译源码用到gc++

建议如果是新安装的系统,使用yum upgrade更新下系统。

复制代码

   

代码如下:

sudo-s

   LANG=C

   yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel

   glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel

   openldap openldap-devel nss_ldap openldap-clients openldap-servers

注意:这里所有的命令是一行的而不能有换行符,如果是copy的时候,注意要去处该换行符

确保安装成功!才能正确使用编译。

3、安装:

一、安装PHP 5.2.8(FastCGI模式)

1、编译安装PHP 5.2.8所需的支持库:

1] libiconv库

复制代码

   

代码如下:

tar zxvf libiconv-1.13.tar.gz

   cd libiconv-1.13/

   ./configure--prefix=/usr/local

   make

   make install

   make clean

   make distclean

   cd../

make clean和make distclean都是删除安装过程中生成的缓存文件。当然如果你不介意放着也可以跳过这两步清理操作。

2]libmcrypt库

复制代码

   

代码如下:

tar zxvf libmcrypt-2.5.8.tar.gz

   cd libmcrypt-2.5.8/

   ./configure

   make

   make install

   make clean

   make distclean

   /sbin/ldconfig

   cd libltdl/

   ./configure--enable-ltdl-install

   make

   make install

   make clean

   make distclean

   cd

3] mhash库

复制代码

   

代码如下:

tar zxvf mhash-0.9.9.9.tar.gz

   cd mhash-0.9.9.9/

   ./configure

   make

   make install

   cd../

4]mcrypt库

注意:因为该库和libmcrypt有依赖性,所以在安装前必须知道libmcrypt,否则的话会出现:

错误

复制代码

   

代码如下:

checking for libmcrypt– version= 2.5.0…

   ***‘libmcrypt-config–version’ returned 2.4.0, but LIBMCRYPT(2.5.8)

   *** was found! If libmcrypt-config was correct, then it is best

   *** to remove the old version of LIBMCRYPT. You may also be able to fix the error

   *** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing

   ***/etc/ld.so.conf. Make sure you have run ldconfig if that is

   *** required on your system.

   *** If libmcrypt-config was wrong, set the environment variable LIBMCRYPT_CONFIG

   *** to point to the correct copy of libmcrypt-config, and remove the file config.cache

   *** before re-running configure

   configure: error:*** libmcrypt was not found

是因为path的问题,所以执行:

复制代码

   

代码如下:

ln-s/usr/local/lib/libmcrypt.la/usr/lib/libmcrypt.la

   ln-s/usr/local/lib/libmcrypt.so/usr/lib/libmcrypt.so

   ln-s/usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4

   ln-s/usr/local/lib/libmcrypt.so.4.4.8/usr/lib/libmcrypt.so.4.4.8

   ln-s/usr/local/lib/libmhash.a/usr/lib/libmhash.a

   ln-s/usr/local/lib/libmhash.la/usr/lib/libmhash.la

   ln-s/usr/local/lib/libmhash.so/usr/lib/libmhash.so

   ln-s/usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2

   ln-s/usr/local/lib/libmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1

   ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config

然后再安装:

复制代码

   

代码如下:

tar zxvf mcrypt-2.6.8.tar.gz

   cd mcrypt-2.6.8/

   /sbin/ldconfig

   ./configure

   make

   make install

   cd../

二、安装mysql

复制代码

   

代码如下:

/usr/sbin/groupadd mysql

   /usr/sbin/useradd-g mysql xxx

   unzip mysql-5.1.33.zip

   cd mysql-5.1.33/

   ./configure--prefix=/usr/local/webserver/mysql/--enable-assembler--with-extra-charsets=complex--enable-thread-safe-client--with-big-tables

   --with-readline--with-ssl--with-embedded-server--enable-local-infile--with-plugins=innobase

   make

   make install

   make clean

   make distclean

   chmod+w/usr/local/webserver/mysql

   chown-R xxx:mysql/usr/local/webserver/mysql

   cp support-files/my-medium.cnf.sh/usr/local/webserver/mysql/my.cnf

   cd../

注意:这里编译./configure命令是一行的而不能有换行符,如果是copy的时候,注意要去处该换行符

在最后一步拷贝的时候,我安装完在support-files下没有my-medium.cnf而只有my-medium.cnf.sh所以将这个文件拷贝过去。

@张宴原文:

附:以下为附加步骤,如果你想在这台服务器上运行MySQL数据库,则执行以下两步。如果你只是希望让PHP支持MySQL扩展库,能够连接其他服务器上的MySQL数据库,那么,以下两步无需执行。

①、以xxx用户帐号的身份建立数据表:

复制代码

   

代码如下:

/usr/local/webserver/mysql/bin/mysql_install_db--basedir=/usr/local/webserver/mysql--datadir=/usr/local/webserver/mysql/data--user=xxx

②、启动MySQL(最后的表示在后台运行)

复制代码

   

代码如下:

/bin/sh/usr/local/webserver/mysql/bin/mysqld_safe--defaults-file=/usr/local/webserver/mysql/my.cnf

3、编译安装PHP(FastCGI模式)

复制代码

   

代码如下:

tar zxvf php-5.2.8.tar.gz

   gzip-cd php-5.2.8-fpm-0.5.10.diff.gz| patch-d php-5.2.8-p1

   cd php-5.2.8/

   ./configure--prefix=/usr/local/webserver/php--with-config-file-path=/usr/local/webserver/php/etc--with-mysql=/usr/local/webserver/mysql

   --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config--with-iconv-dir=/usr/local--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib

   --with-libxml-dir=/usr--enable-xml--disable-rpath--enable-discard-path--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem

   --enable-inline-optimization--with-curl--with-curlwrappers--enable-mbregex--enable-fastcgi--enable-fpm--enable-force-cgi-redirect

   --enable-mbstring--with-mcrypt--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-ldap

   --with-ldap-sasl

   make ZEND_EXTRA_LIBS='-liconv'

   make install

   cp php.ini-dist/usr/local/webserver/php/etc/php.ini

   cd../

注意:这里./configure命令是一行的而不能有换行符,如果是copy的时候,注意要去处该换行符

4、编译安装PHP5扩展模块--可选安装

复制代码

   

代码如下:

tar zxvf memcache-2.2.5.tgz

   cd memcache-2.2.5/

   /usr/local/webserver/php/bin/phpize

   ./configure--with-php-config=/usr/local/webserver/php/bin/php-config

   make

   make install

   make clean

   make distclean

   cd../

   tar jxvf eaccelerator-0.9.5.3.tar.bz2

   cd eaccelerator-0.9.5.3/

   /usr/local/webserver/php/bin/phpize

   ./configure--enable-eaccelerator=shared--with-php-config=/usr/local/webserver/php/bin/php-config

   make

   make install

   make clean

   make distclean

   cd../

   tar zxvf PDO_MYSQL-1.0.2.tgz

   cd PDO_MYSQL-1.0.2/

   /usr/local/webserver/php/bin/phpize

   ./configure--with-php-config=/usr/local/webserver/php/bin/php-config--with-pdo-mysql=/usr/local/webserver/mysql

   make

   make install

   make clean

   make distclean

   cd../

   tar zxvf ImageMagick.tar.gz

   cd ImageMagick-6.5.1-2/

   ./configure

   make

   make install

   make clean

   make distclean

   cd../

   tar zxvf imagick-2.2.2.tgz

   cd imagick-2.2.2/

   /usr/local/webserver/php/bin/phpize

   ./configure--with-php-config=/usr/local/webserver/php/bin/php-config

   make

   make install

   make clean

   make distclean

   cd../

5、修改php.ini文件

STRONG手工修改:/STRONG查找/usr/local/webserver/php/etc/php.ini中的extension_dir="./"

修改为extension_dir="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"

并在此行后增加以下几行,然后保存:

extension="memcache.so"

extension="pdo_mysql.so"

extension="imagick.so"

再查找output_buffering= Off

修改为output_buffering= On

6、配置eAccelerator加速PHP:

mkdir-p/usr/local/webserver/eaccelerator_cache

vi/usr/local/webserver/php/etc/php.ini

按shift+g键跳到配置文件的最末尾,加上以下配置信息:

复制代码

   

代码如下:

[eaccelerator]

   zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"

   eaccelerator.shm_size="128"

   eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"

   eaccelerator.enable="1"

   eaccelerator.optimizer="1"

   eaccelerator.check_mtime="1"

   eaccelerator.debug="0"

   eaccelerator.filter=""

   eaccelerator.shm_max="0"

   eaccelerator.shm_ttl="300"

   eaccelerator.shm_prune_period="120"

   eaccelerator.shm_only="0"

   eaccelerator.compress="1"

   eaccelerator.compress_level="9"

修改配置文件:

vi/etc/sysctl.conf

kernel.shmmax= 134217728

然后执行以下命令使配置生效:/sbin/sysctl-p

以下的步骤和张宴步骤中一样配置,不再赘诉

阅读剩余
THE END