0%

Centos apache2.2.4 MySql5.6.X PHP5.5.3手记自己备查

看软件安装帮助比什么都重要!!!

*首先卸载干净以前的 apache mysql php aprapr-util 等


安装PHP第三方扩展包

安装jpeg6需要注意
首先看有没有安装libtool 及 libtool-ltdl-devel
rpm -qa | grep libtool
然后进入jpeg-6b的源码目录,然后执行以下步骤,切记!COPY到当前目录注意后面的点(.)
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
也就是把 libtool里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件
make clean 再重新configure
没有权限的时候先建立对应的文件夹,再次make install就行了

mkdir -p /usr/local/libxm2
mkdir -p /usr/local/libmcrypt
mkdir -p /usr/local/zlib
mkdir -p /usr/local/libpng
mkdir -p /usr/local/jpeg6
mkdir -p /usr/local/jpeg6/bin
mkdir -p /usr/local/jpeg6/lib
mkdir -p /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man/man1
mkdir -p /usr/local/pcre
mkdir -p /usr/local/apr
mkdir -p /usr/local/apr-util
mkdir -p /usr/local/gd
mkdir -p /usr/local/autoconf
mkdir -p /usr/local/freetype
mkdir -p /usr/local/libevent
mkdir -p /usr/local/libiconv
mkdir -p /usr/local/mhash
mkdir -p /usr/local/autoconf

./configure --prefix=/usr/local/pcre
./configure --prefix=/usr/local/apr
./configure --prefix=/usr/local/apr-util
./configure --prefix=/usr/local/libxm2
./configure --prefix=/usr/local/libmcrypt
./configure --prefix=/usr/local/zlib
./configure --prefix=/usr/local/libpng
./configure --prefix=/usr/local/jpeg6 -enable-shared -enable-static
./configure --prefix=/usr/local/gd -with-jpeg=/usr/local/jpeg6
./configure --prefix=/usr/local/autoconf
./configure --prefix=/usr/local/freetype
./configure --prefix=/usr/local/libevent
./configure --prefix=/usr/local/libiconv
./configure --prefix=/usr/local/mhash

安装ZendOptimizer
注意:安装ZendOptimizer 进入到 ZendOptimizer/data/5_2_x_comp 拷贝ZendOptimizer.so 到任意方便的地方

mysql 问题处理
/usr/local/mysql/scripts/mysql_install_db --user=mysql
/usr/local/mysql/bin/mysqld_safe & 添加&是后台运行

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
上网查了下:
这种情况大多数是因为你的mysql是使用rpm方式安装的,它会自动寻找 /var/lib/mysql/mysql.sock 这个文件,
通过unix socket登录mysql。
常见解决办法如下:
1、
创建/修改文件 /etc/my.cnf,至少增加/修改一行
[mysql]
[client]
socket = /tmp/mysql.sock
#在这里写上你的mysql.sock的正确位置,通常不是在 /tmp/ 下就是在 /var/lib/mysql/ 下

2、
指定IP地址,使用tcp方式连接mysql,而不使用本地sock方式
#mysql -h127.0.0.1 -uuser -ppassword

3、
为 mysql.sock 加个连接,比如说实际的mysql.sock在 /tmp/ 下,则
#ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock即可

问题:
Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/Server03.mylinux.com.pid).
解决:
修改/etc/my.cnf 中datadir,指向正确的mysql数据库文件目录

问题:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
解决:
新建一个链接或在mysql中加入-S参数,直接指出mysql.sock位置。
ln -s /usr/local/mysql/data/mysql.sock /tmp/mysql.sock
/usr/local/mysql/bin/mysql -u root -S /usr/local/mysql/data/mysql.sock

cmake 中文使用说明
http://www.blogjava.net/kelly859/archive/2012/09/04/387005.html

安装 mysql
先安装 cmake(mysql5.6.X)

注意小'-'必须有 这个是指定目录安装的
cmake -DCMAKE_INSTALL_PREFIX=/www/mysql \
-DMYSQL_UNIX_ADDR=/www/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/www/mysql/data \
-DMYSQL_USER=mysql \ 有的时候会出错哦
-DMYSQL_TCP_PORT=3306

注:重新运行配置,需要删除CMakeCache.txt文件
rm -rf CMakeCache.txt
编译
make && make install

权限
chown -R mysql:mysql mysql
chmod -R 775 mysql

初始化
scripts/mysql_install_db –user=mysql –datadir=/data/mysqldb
配置文件
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
vim /etc/my.conf
[mysqld]
basedir = /www/mysql
datadir = /www/mysql/data
port = 3306
# server_id = /www/mysql/data/65.pid
socket = /www/mysql/mysql.sock
user=mysql

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket = /www/mysql/mysql.sock

复制mysql服务启动脚本及加入PATH路径
cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/profile
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH
source /etc/profile

启动mysql服务并加入开机自启动
service mysqld start
chkconfig –level 35 mysqld on

检查mysql服务是否启动
netstat -tulnp | grep 3306
mysql -u root -p
密码为空,如果能登陆上,则安装成功。

修改MySQL用户root的密码
mysqladmin -u root password ’123456′

产考:

/>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
shell> groupadd mysql<br />
shell> useradd -r -g mysql mysql<br />
shell> cd /usr/local<br />
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz<br />
shell> ln -s full-path-to-mysql-VERSION-OS mysql<br />
shell> cd mysql<br />
shell> chown -R mysql .<br />
shell> chgrp -R mysql .<br />
shell> scripts/mysql_install_db --user=mysql<br />
shell> chown -R root .<br />
shell> chown -R mysql data<br />
# Next command is optional<br />
shell> cp support-files/my-medium.cnf /etc/my.cnf<br />
shell> bin/mysqld_safe --user=mysql &#038;<br />
# Next command is optional<br />
shell> cp support-files/mysql.server /etc/init.d/mysql.server<br />

`````

scripts/mysql_install_db -user=mysql -datadir=/data/mysqldb

scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb
安装apache前
*首先卸载干净以前的 apache mysql php aprapr-util 等

yum install -y cups-php graphviz-php php-bcmath php-cli php-common php-dba
yum install -y php-devel php-embedded php-fpm php-gd php-imap php-intl
yum install -y php-ldap php-mbstring php-mysql php-odbc php-pdo php-pear
yum install -y php-pecl-apc php-pgsql php-process php-pspell php-recode
yum install -y php-snmp php-soap php-tidy php-xml php-xmlrpc
yum install -y php-zts rrdtool-php uuid-php
yum install -y php-enchant php-pecl-apc-devel php-pecl-memcache

安装 apr apr-util unzip
a:解决apr not found问题>>>>>>

tar -zxf apr-1.4.5.tar.gz
cd apr-1.4.5
./configure –prefix=/usr/local/apr
make && make install

b:解决APR-util not found问题>>>>

tar -zxf apr-util-1.3.12.tar.gz
cd apr-util-1.3.12
./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
make && make install

c:解决pcre问题>>>>>>>>>

unzip -o pcre-8.10.zip
cd pcre-8.10
./configure –prefix=/usr/local/pcre
make && make install

apahce安装

tar jvxf httpXXX
./configure --prefix=/www/apache \ #写自己的目录
--with-mysql=/usr/local/mysql \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--with-pcre=/usr/local/pcre \
--enable-rewrite=shared \
--enable-module=so \
--enable-shared=max
make && make install

vim /usr/local/apache/conf/http.conf
打开
ServerName IP:80
修改自己网站的路径
#DocumentRoot "/usr/local/apache/htdocs"
#
添加 index.php
DirectoryIndex index.php index.html
找到 AddType后添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
将所有“AllowOverride None”,改为:
AllowOverride All
找到 LoadModule 添加
LoadModule php5_module modules/libphp5.so

cp apache/bin/apachectl /etc/init.d/httpd

打开 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)
#chkconfig: 2345 10 90
#description: Activates/Deactivates Apache Web Server
chkconfig --add httpd
启动
service httpd start
查看一下端口
netstat -an |grep 80
最后web浏览一下
如果不能访问
方法一
停止防火墙
service iptables stop

安装PHP

tar jvxf phpXXX

以下的配置都可以用:
1:
./configure \
--prefix=/www/php \
--with-mysql=/www/mysql \
--with-apxs2=/www/apache/bin/apxs \
--with-mcrypt \
--enable-mbst

2:
./configure --prefix=/www/php --with-mysql=/www/mysql --with-apxs2=/www/apache/bin/apxs --with-mcrypt=/usr/local/libmcrypt --enable-mbst

3:
./configure
--prefix=/web/php \
--bindir=/web/php/bin \
--libdir=/web/php/lib \
--includedir=/web/php/include \
--libdir=/web/php/libexec \
with-mysql=/usr/local/mysql \
with-apxs2=/usr/local/apache/bin/apxs \
with-mcrypt \
enable-mbstr

4:
./configure \
--prefix=/www/php \
--with-config-file-path=/web/php/etc \
--with-apxs2=/www/apache/bin/apxs \
--with-mysql=/www/mysql \
--with-libxml-dir=/usr/local/libxml2 \
--with-png-dir=/usr/local/libpng \
--with-jpeg-dir=/usr/local/jpeg6 \
--with-freetype-dir=/usr/local/freetype \
--with-gd=/usr/local/gd \
--with-zlib-dir=/usr/local/zlib \
--with-mcrypt=/usr/local/libmcrypt \
--with-mysqli=/www/mysql/bin/mysql_config \
--with-iconv-dir=/usr/local/libiconv \
--with-mhash=/usr/local/mhash \
--with-mysql-sock=/www/mysql/mysql.sock \
--enable-soap \
--enable-mbstring=all \
--enable-sockets

# make && make install

以下是自动安装:第三方扩展:
yum -y install yum-fastestmirror
yum -y install patch make flex bison tar
yum -y install libtool libtool-libs kernel-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel
yum -y install libtiff libtiff-devel gettext gettext-devel
yum -y install libxml2 libxml2-devel zlib-devel net-snmp
yum -y install file glib2 glib2-devel bzip2 diff* openldap-devel
yum -y install bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs
yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
yum -y install openssl openssl-devel vim-minimal unzip
# 安装PHP支持GD库软件包
yum -y install freetype freetype-devel png jpeg zlib gd php-gd*
# 安装PHP 5.* 组件
yum -y install libiconv libevent mhash mcrypt
yum install ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel net-snmp-devel -y

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!