apache2.4 php mysql_CentOS7 + Apache2.4 + Mysql5.5 + PHP5.5

前面已经介绍了:LAMP的搭建:

不过使用的是集成环境。但有些时候还是需要我们来自己配置相关的环境,这样对于理解各个组件之间的工作原理也更加的熟悉,配置性更加的高了。直接开始:

我的版本:MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar

我的版本:httpd-2.4.12.tar.gz

Apache Protable Runtime(APR)(当然,APR依赖包也要,都在这个连接里): http://apache.osuosl.org//apr/

我的版本:

apr-1.5.2.tar.gz

apr-util-1.5.4.tar.gz

这里要注意是安装pcre,不要下载pcre2版,不然要改名字或改配置,改的东西比较多比较麻烦,也有人不安装,不过我建议安装,正则啊,没得说我选择安装。

我的版本:php-5.5.25.tar.gz

libxml2  and libxml2-devel(这个是不可少的)

另外我的CentOS7已更新

0818b9ca8b590ca3270a3433284dd417.png

安装之前:

安装gcc & gcc-c++,后面有apache时要用,索性就先装上好了

yum install gcc gcc-c++ gcc-g77 autoconf automake make cmake bison make perl perl-devel ncurses ncurses-devel

介绍了硬件环境和要安装的文件,下面开始安装:

安装MySql

在安装之前有一点要交代,下面是来自官方的警告:

Warning

Once the release package is installed on your system, any system-wide update by the yum update command will automatically upgrade MySQL packages on your system and also replace any native third-party packages, if Yum finds replacements for them in the MySQL Yum repository. See Upgrading MySQL with the MySQL Yum Repository and Replacing a Native Third-Party Distribution of MySQL for details.

大概意思就是说,如果安装这个版本包后,只要使用Yum update命令更新系统,MySqL就是自动的更新到最新版本,包括替换第三方的一些Packages,不过也给出了两个连接来帮助我们来更新Mysql也更新第三方Package。

# rpm -ivh MySQL-devel-5.6.24-1.linux_glibc2.5.x86_64.rpm

# rpm -ivh MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm

# rpm -ivh MySQL-client-5.6.24-1.linux_glibc2.5.x86_64.rpm

查看下安装后的版本信息:

#mysql --version

mysql  Ver 14.14 Distrib 5.6.24, for Linux (x86_64) using  EditLine wrapper

去查看已经安装的mariadb信息:

#yum list *maria*

mariadb.x86_64            1:5.5.41-2.el7_0      @base

mariadb-libs.x86_64       1:5.5.41-2.el7_0      @base

mariadb-server.x86_64     1:5.5.41-2.el7_0      @base

咱们来试试看:

#mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

好吧,忘记启动服务了, 来启动我们的mariadb服务。

#systemctl start mariadb.service

#systemctl enable mariadb.service #因为mariadb服务启动正常,将mariadb设置为开机自动启动.

然后进行mariadb的安全设置:

# sudo mysql_secure_installation

/usr/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n

... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] y

... Success!

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y

... Success!

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] Y

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] Y

ERROR 1146 (42S02) at line 1: Table 'mysql.servers' doesn't exist

... Failed!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

里面具体的设置自己看情况设置,我的仅供参考.

现在让我们赶紧进来试试看吧:

# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 24

Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

ok,mysql安装完成,

另外要注意的是,加入您的系统firewall开着,请注意为mysql开放3306端口.

可是我们才走完第一步而已。

安装我们的战斗机(Apache)

#gzip -d httpd-2.4.12.tar.gz

#tar xvf httpd-2.4.12.tar

#cd httpd-2.4.12

开始编译和安装:

# ./configure --prefix=/usr/local/apache

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

configure:

configure: Configuring Apache Portable Runtime library...

configure:

checking for APR... no

configure: error: APR not found.  Please read the documentation.

缺少了APR, 那就装一个APR(在文章开头已经下载过了,直接安装即可):

安装APR:

#mkdir /usr/local/apr

#tar -zxvf apr-1.5.2.tar.gz

#cd apr-1.5.2

#./configure --prefix=/usr/local/apr

balabala......

#make

#make install

ok,接着Apr-util:

#tar -zxvf apr-util.1.5.4.tar.gz

#cd apr-util

#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config

#make

#make install

下来是PRCE:

# mkdir /usr/local/pcre

# tar -zxvf pcre-8.37.tar.gz

# ./configure --prefix=/usr/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config

# make

# make install

好了,这几个依赖包安装好了,重新再来搞战斗机.

# cd httpd-2.4.12

# ./configure --prefix=/usr/local/apache --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

# make

# make install

正常完成,看看正常不:

0818b9ca8b590ca3270a3433284dd417.png

安装PHP

# tar -zxvf php-5.5.25.tar.gz

# cd php-5.5.25

# mkdir /usr/local/php

# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-var --with-xml --with-mysql --with-zlib-dir=/usr/local

configure: error: xml2-config not found. Please check your libxml2 installation.

忘记了,我们的xml组件还没有安装.

# tar -zxvf libxml2-2.9.2.tar.gz

# cd libxml2-2.9.2

# mkdir /usr/local/libxml2

# ./configure --prefix=/usr/local/libxml2

#make

libxml.c:14:20: fatal error: Python.h: No such file or directory

#include 

查下看Python的Package

# yum search python|grep python-devel

dbus-python-devel.i686 : Libraries and headers for dbus-python

dbus-python-devel.x86_64 : Libraries and headers for dbus-python

gstreamer-python-devel.i686 : Headers for developing programs that will use

gstreamer-python-devel.x86_64 : Headers for developing programs that will use

python-devel.x86_64 : The libraries and header files needed for Python

刚好有64位的,赶紧装上:

# yum install python-devel.x86_64

很好,再来装我们的libxml2

#cd libxml2

#./configure --prefix=/usr/local/libxml2

#make

#make install

八错八错,完成了,接者装:libxml2-devel

#yum install libxml2-devel

很ok,接着来第三次来安装PHP

#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-var --with-xml --with-mysql --with-zlib-dir=/usr/local

Configuring SAPI modules

Running system checks

General settings

Configuring extensions

configure: error: Cannot find MySQL header files under /usr/bin/mysql.

Note that the MySQL client library is not bundled anymore!

检查mysql相关的未安装并安装:

# yum list *mariadb*

# yum install mariadb-devel.x86_64

也可以修改参数:

--with-mysql --with-libdir=/lib/x86_64-linux-gnu

再来配置又错了:

configure: error: Cannot find libmysqlclient under /usr.

Note that the MySQL client library is not bundled anymore!

原因分析与解决

通过查找libmysqlclient,发现是在/usr/lib64/mysql/目录内的libmysqlclient.so.15.0.0做的软连接,PHP默认是去的/usr/lib/搜索,所以没有找到.解决办法就是:cp /usr/lib64/mysql/* /usr/lib/mysql/然后进行./configure即可,如果服务器没有/usr/lib/mysql/ 目录,则在/usr/lib/目录下创建mysql目录即可

#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs  --with-libxml2=/usr/local/libxml2 --with-mysql=/usr/bin/mysql

h

或:

#./configure --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-var --with-xml --with-php-config=/usr/local/bin/php-config --with-mysql-dir=/usr --with-zlib-dir

#make

#make install

大功告成,让我们先来测试一下看看:

vim /var/www/info.php

phpinfo();

?>

先给出一些参考连接:

http://stackoverflow.com/questions/11134220/cannot-find-libmysqlclient-under-usr-while-build-php-5-2-from-source-on-ubuntu

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值