Description
Operating system: CentOS 6.8 32-bit
Prepare the article:
First , the system contract
Software source code Package storage location:/USR/LOCAL/SRC
Source Package Compilation Installation location:/usr/local/software Name
Second, download the package
Httpd2.2.31.tar.gz
Mysql5.6.31.tar.gz
Php5.3.27.tar.gz
install the compilation tools and library files (using CentOS Yum command installation)
Yum install–y make gcc gcc-c++ zlib-devel pcre pcre-devel Apr apr-devel libxml2-devel OpenSSL openssl-devel bzip2 bzip2-d Evel libpng libpng-devel freetype freetype-devel epel-release libmcrypt-devel
Installation article
installation MySQL
Useradd-r mysql-s/bin/nologin #创建系统用户mysql及用户组mysql
Mkdir-p/data/mysql #创建MySQL数据库存放目录
Mkdir-p/usr/local/mysql #创建MySQL安装目录
Chown-r Mysql:mysql/data/mysql/usr/local/mysql #设置MySQL数据及安装目录权限
Cd/usr/local/src
Tar zxvf mysql-5.6.31.tar.gz #解压
CD mysql-5.6.31
#配置编译参数
CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/mysql-dsysconfdir=/etc
Make && make install #编译 + Install
Cd/usr/local/mysql
CP./SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF #拷贝配置文件 (Note: If the/etc directory has a my.cnf under the default, you can overwrite it directly)
Vi/etc/my.cnf #编辑配置文件, added in [mysqld] section
DataDir =/data/mysql #添加MySQL数据库路径
./scripts/mysql_install_db--user=mysql #生成mysql系统数据库
CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把Mysql加入系统启动
chmod 755/etc/init.d/mysqld #增加执行权限
Chkconfig mysqld on #加入开机启动
Vi/etc/rc.d/init.d/mysqld #编辑
Basedir =/usr/local/mysql #MySQL程序安装路径
DataDir =/data/mysql #MySQl数据库存放目录
Service mysqld Start #启动
Vi/etc/profile #把mysql服务加入系统环境变量: Add the following line at the end
Export path= $PATH:/usr/local/mysql/bin
The following two lines link the MYSLQ library file to the default location of the system, so you can compile software like PHP without specifying the MySQL library file address.
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql
Shutdown-r now #重启系统, wait for the system to restart after the operation continues under the terminal command line
Mysql_secure_installation #设置Mysql密码
Press Y to enter the password 2 times as prompted
or change the password directly/usr/local/mysql/bin/mysqladmin-u root-p password "123456"
Service mysqld Restart #重启
To this, MySQL installation is complete!
installation Apache
Cd/usr/local/src
Tar zxvf httpd2.2.31.tar.gz #解压
CD httpd2.2.31
#配置编译参数
./configure \
--PREFIX=/USR/LOCAL/APACHE2 \
--WITH-INCLUDED-APR \
--ENABLE-SO \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--with-pcre
--PREFIX specifies where to install,--enable-so means that the DSO--enable-deflate=shared is enabled to be compiled in a shared way deflate
This error has occurred:
Error:mod_deflate have been requested but can is built due to prerequisite failures
The solution is:
Yum Install-y zlib-devel
To avoid errors in make, it is best to install some library files in advance:
Yum install-y pcre pcre-devel Apr apr-devel
Make && make install #编译 + Install
Apache Installation Complete!
installation PHP
Cd/usr/local/src
Tar zxvf php5.3.27.tar.gz #解压
CD php5.3.27.tar.gz
#配置编译参数
./configure \
--prefix=/usr/local/php \
--WITH-APXS2=/USR/LOCAL/APACHE2/BIN/APXS \
--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC \
--with-mysql=/usr/local/mysql \
--with-libxml-dir \
--WITH-GD \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--WITH-BZ2 \
--WITH-OPENSSL \
--with-mcrypt \
--ENABLE-SOAP \
--ENABLE-GD-NATIVE-TTF \
--enable-mbstring \
--enable-sockets \
--ENABLE-EXIF \
--disable-ipv6
Encountered the following error:
Configure:error:xml2-config not found. Please check your LIBXML2 installation.
The solution is:
Yum Install-y libxml2-devel
There are also errors:
Configure:error:Cannot find OpenSSL ' s <evp.h>
The solution is:
Yum Install-y OpenSSL Openssl-devel
Error:
Checking for BZIP2 in default path ... not found
Configure:error:Please Reinstall the BZIP2 distribution
Workaround:
Yum install-y bzip2 Bzip2-devel
Error:
Configure:error:png.h not found.
Workaround:
Yum install-y libpng Libpng-devel
Error:
Configure:error:freetype.h not found.
Workaround:
Yum install-y FreeType Freetype-devel
Error:
Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.
Workaround:
Yum Install–y epel-release
Yum Install-y libmcrypt-devel
Make && make install #编译 + Install
Copy the configuration file:
CP Php.ini-production/usr/local/php/etc/php.ini
Apache combined PHP
The Apache master configuration file is:/usr/local/apache2/conf/httpd.conf
Vim/usr/local/apache2/conf/httpd.conf
Found it:
AddType application/x-gzip. gz. tgz
Under this line, add the following:
AddType application/x-httpd-php. php
Found it:
<ifmodule dir_module>
DirectoryIndex index.html
</IfModule>
Change the line to read:
<ifmodule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
Found it:
#ServerName www.example.com:80
Modified to:
ServerName localhost:80
Test LAMP is successful :
Verify that the configuration file is correct before starting Apache:
/usr/local/apache2/bin/apachectl-t
If there is an error, please continue to modify httpd.conf, if it is correct, then display as "Syntax OK",
The command to start Apache is:
/usr/local/apache2/bin/apachectl start
To see if it starts:
[Email protected] ~]# NETSTAT-LNP |grep httpd
TCP 0 0::: +:::* LISTEN 7667/httpd
If this line is displayed, it is started. You can also use the Curl command to simply test:
[[email protected] ~]# curl localhost
This is only true if it is displayed.
Test if PHP is parsed correctly:
vim/usr/local/apache2/htdocs/1.php
Write:
<?php
echo "PHP parsing normal";
?>
After saving, continue testing:
Curl localhost/1.php
See if you can see the following information:
[Email protected] ~]# Curl localhost/1.php
PHP parsing OK
It's only right to show it.
to this, LAMP Basic operating environment to complete!
CentOS 6.8 Compilation installation httpd2.2.31+mysql5.6.31+php5.3.27