Centos6 编译安装apache2.4.23+yum升级mysql5.5+编译安装php5.6.28, 搭建LAMP

作者: wxfeng 分类: linux 发布时间: 2018-12-04 00:00    阅读 678 次


微信小程序开发 开发工具中运行正常,预览时在手机端调式控制台:提示SSL握手失败;

SSL握手失败原因:需要apache服务器支持TSL1.2. 而如果使apache服务器支持TSL1.2,apache对应版本应>=2.2.23,所以有了下面这个坎坷的安装历程.


[root@iZ28ppn9h91Z ~]# cat /etc/issue
CentOS release 6.6 (Final


CentOS’s package installed version of apache is out of date. We will compile our own from source.

First, install the required packages.

# yum groupinstall "Development Tools"
# yum install openssl-devel
# yum install pcre-devel

Download Apache

Download Apache from httpd.apache.org. The current stable release is 2.4.23.

Once you get the direct URL to download the latest stable version of
Apache, use wget as shown below to download it directly to your server.

cd /usr/src
wget http://apache.mirrors.tds.net//httpd/httpd-2.4.23.tar.gz
tar zxvf httpd-2.4.23.tar.gz

Download APR and APR-Util

Now we have to download APR and APR-Util because CentOS’s versions aren’t compatible with the latest version of apache. Visit http://apr.apache.org/download.cgi to get the URL for the latest versions, then use wget as shown below.

cd /usr/src
wget http://apache.mirrors.tds.net/apr/apr-1.5.2.tar.gz
wget http://apache.mirrors.tds.net/apr/apr-util-1.5.4.tar.gz
tar zxvf apr-1.5.2.tar.gz
tar zxvf apr-util-1.5.4.tar.gz

Now we want to put the apr and apr-util we downloaded into our apache source files.

mv apr-1.5.2.tar.gz /usr/src/httpd-2.4.4/srclib/apr
mv apr-util-1.5.4.tar.gz/usr/src/httpd-2.4.4/srclib/apr-util


Sweet, now it’s time to compile. We want to use –enable-ssl –enable-so –with-mpm=prefork –with-included-apr

# cd /usr/src/httpd-2.4.23
# ./configure --enable-so --enable-ssl --with-mpm=prefork --with-included-apr
# make
# make install

Enable SSL in httpd.conf

Apache configuration file httpd.conf is located under /usr/local/apache2/conf.

Uncomment the httpd-ssl.conf Include line and the LoadModule ssl_module line in the /usr/local/apache2/conf/httpd.conf file.

# nano /usr/local/apache2/conf/httpd.conf
LoadModule ssl_module modules/mod_ssl.soInclude conf/extra/httpd-ssl.conf

View the httpd-ssl.conf to review all the default SSL configurations. For most cases, you don’t need to modify anything in this file.

# nano /usr/local/apache2/conf/extra/httpd-ssl.conf

The SSL certificate and key are required before we start the Apache. The server.crt and server.key file mentioned in the httpd-ssl.conf needs to be created before we move forward.

# cd /usr/local/apache2/conf/extra
# egrep 'server.crt|server.key' httpd-ssl.confSSLCertificateFile "/usr/local/apache2/conf/server.crt"
SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"

Generate server.crt and server.key file

First, Generate the server.key using openssl.

# cd /usr/src
# openssl genrsa -des3 -out server.key 1024

The above command will ask for the password. Make sure to remember
this password. You need this while starting your Apache later.

Next, generate a certificate request file (server.csr) using the above server.key file.

# openssl req -new -key server.key -out server.csr

Finally, generate a self signed ssl certificate (server.crt) using the above server.key and server.csr file.

# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Copy the server.key and server.crt file to appropriate Apache configuration directory location.

cp server.key /usr/local/apache2/conf/
cp server.crt /usr/local/apache2/conf/

Start Apache

If you are getting the below error message, make sure to uncomment the line shown below in httpd.conf.

# /usr/local/apache2/bin/apachectl start
AH00526: Syntax error on line 51 of /usr/local/apache2/conf/extra/httpd-ssl.conf:
Invalid command 'SSLCipherSuite', perhaps misspelled or defined by a module not included in the server configuration
# nano /usr/local/apache2/conf/httpd.confLoadModule ssl_module modules/mod_ssl.so

If you are getting the below error message, make sure to uncomment the line shown below in httpd.conf.

# /usr/local/apache2/bin/apachectl start
AH00526: Syntax error on line 76 of /usr/local/apache2/conf/extra/httpd-ssl.conf:
SSLSessionCache: 'shmcb' session cache not supported (known names: ). Maybe you need to load the appropriate socache module 
# vi /usr/local/apache2/conf/httpd.confLoadModule socache_shmcb_module modules/mod_socache_shmcb.so

Finally, this will prompt you to enter the password for your private key before starting up the apache.

# /usr/local/apache2/bin/apachectl start
Apache/2.4.23 mod_ssl (Pass Phrase Dialog)
Some of your private key files are encrypted for security reasons.
In order to read them you have to provide the pass phrases.
Server www.example.com:443 (RSA)
Enter pass phrase:
OK: Pass Phrase Dialog successful.

Verify that the Apache httpd process is running in the background.

# ps -ef | grep http
root 29529 1 0 13:08 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
daemon 29530 29529 0 13:08 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
daemon 29531 29529 0 13:08 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
daemon 29532 29529 0 13:08 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
root 29616 18260 0 13:09 pts/0 00:00:00 grep http

To stop apache, use apachectl stop.

# /usr/local/apache2/bin/apachectl stop

Use httpd -l to view all the modules that are compiled inside the Apache httpd daemon.

# /usr/local/apache2/bin/httpd -l
Compiled in modules:

By default Apache SSL runs on 443 port. Open a web browser and verify that you can access your Apache using https://{your-ip-address}

Add apache bin folder to $PATH

Now for the sake of convenience, we’re going to add the directory for
apache binaries (apachectl, httpd, etc.) to the $PATH

variable so that
you don’t have to type /usr/local/apache2/bin/whatever each time.

# echo 'pathmunge /usr/local/apache2/bin' > /etc/profile.d/httpd.sh
# chmod +x /etc/profile.d/httpd.sh

Now, reload the profile by either logging out and back in, or by running:

# . /etc/profile

That will reload the $PATH variable.

Yeah, not too bad at all now that you know what you’re doing.



How to Upgrade MySQL 5.1 to MySQL 5.5 on CentOS 6.7

Today you’re going to learn how to upgrade MySQL 5.1 to MySQL 5.5 on
CentOS 6.7. This article assumes that you are running

the CentOS BASE
version of MySQL 5.1. We are ALSO assuming that you are not running this
on a live, production environment. 


If you do plan on running this on a
live server, please make sure to backup your databases beforehand. You
will also need to run

the mysql_upgrade command after the upgrade from 5.1 to 5.5, to make sure all databases and tables are compatible.


1. Confirm your version of MySQL is CentOS 6.7 default

Type in the following to confirm that you have CentOS 6.7 default of MySQL 5.1 installed:

 rpm -qa | grep mysql

 Output should look similar to the following:


 Everything looks good, moving on!

2. Install and activate the REMI and EPEL RPM Repositories

 If you have not done so already, install and activate the REMI and EPEL repositories;

 wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm && rpm -Uvh epel-release-latest-6.noarch.rpm

wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && rpm -Uvh remi-release-6*.rpm

 Now to enable the REMI repository globally:

 nano /etc/yum.repos.d/remi.repo

 Under the section that looks like [remi] make the following changes:

name=Remi's RPM repository for Enterprise Linux 6 - $basearch

 Type CTRL-O to save, and CTRL-X to exit

 3. Update MySQL from 5.1 to 5.5

Simply type in the following:

yum -y update mysql*

 Once that’s done, we can verify:

 rpm -qa | grep mysql

 And we should see something similar to the below:


 Now we need to make sure MySQL is working correctly.

 If you’ve set a root password already, type the following;

 mysql -u root -p

 If you have not yet set a root password, you can simply type;


 You should see something similar to the following

 Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.45 MySQL Community Server (GPL) by Remi

 There you go! That was easy right?


[root@localhost src]#wget http://cn2.php.net/distributions/php-5.6.28.tar.gz
[root@localhost src]#tar xzvf php-5.6.28.tar.gz
[root@localhost src]#cd php-5.6.28
[root@localhost php-5.5.28]# find / -name mysql.h
[root@localhost php-5.5.28]#yum install mysql-devel
[root@localhost php-5.5.28]#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config --with-iconv-dir --with-freetype-dir=/data/apps/libs --with-jpeg-dir=/data/apps/libs --with-png-dir=/data/apps/libs --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt=/data/apps/libs --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql --enable-maintainer-zts





通过YUM安装的mysql,可指定/usr/ 作为mysql的安装路径选项,否则,在编译时会提示找不到mysql





# nano /usr/local/apache2/conf/httpd.conf
# 找到下面三行进行修改,如果没有则进行添加.
LoadModule php5_module modules/libphp5.so
DirectoryIndex index.html 修改为DirectoryIndex index.html index.php
AddType application/x-httpd-php .php

小结:YUM or compile?





设置完成后,网站目录的所属用户组以及用户应该是:daemon daemon

$chown daemon.daemon -R 网站项目目录


$chown daemon.daemon -R 网站项目目录
$chmod 755 -R  网站项目目录



yum升级mysql5.1至mysql5.5: https://www.zerostopbits.com/how-to-upgrade-mysql-5-1-to-mysql-5-5-on-centos-6-7/