Linux Service lamp source installation (CentOS)

Source: Internet
Author: User
Tags php and mysql

linux+apache+mysql+php Source Installation

A Installation Environment:

System: centos6.5x64

Apache:httpd-2.4.10.tar.gz

Mysql:mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz

Php:php-5.6.0.tar.gz

Apr:apr-1.5.1.tar.gz

Apr-util:apr-util-1.5.3.tar.gz

Libxml2:libxml2-2.9.1.tar.gz

Default installation path We install it uniformly under/usr/local

Two Apache Installation:

Install the required development package before installing Apache, use yum–y install gcc gcc-c++ pcre pcre-devel python python-devel


The APR version required to install the Apache2.4 is more than 1.4, and the Centos6.5 comes with the APR version is 1.39, so to download the corresponding version of the Apr.apache.net website, we have downloaded the latest 1.5.1 version, Apr-util is 1.5.3 version, also Need LIBXML2 software, because LIBXML2 is a C language parser, so we need to install Apache, the source when the installation of the system will not recognize the LIBXML2 installation path, so we can install the tar package, I download here is 2.9.1 version. Use the Rpm–qa Apr apr-util libxml2 command to view the version of the Centos6.5 installation:

To create the installation directory:

To create a relative installation package directory: Use Mkdir/usr/local/{apr,apr-util,libxml2,apache,php}–v

Install Apr:

Shell>tar XF apr-1.5.1.tar.gz

SHELL>CD apr-1.5.1

Shell>./configure--PREFIX=/USR/LOCAL/APR

Shell>make && make Install



To install the Apr-util package:

Shell>tar XF apr-util-1.5.3.tar.gz

SHELL>CD apr-util-1.5.3

Shell>./configure--PREFIX=/USR/LOCAL/APR-UTIL–WITH-APR=/USR/LOCAL/APR

Shell>make && make Install



To install the LIBXML2 package:

Shell>tar XF libxml2-2.9.1.tar.gz

SHELL>CD libxml2-2.9.1

Shell>./configure--PREFIX=/USR/LOCAL/LIBXML2

Shell>make && make Install



Before installing Apache, remove the Apache package from Centos6.5:





To install the Apache package:

Shell>tar XF L httpd-2.4.10.tar.gz

SHELL>CD httpd-2.4.10

Shell>./configure--prefix=/usr/local/apache--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util-- WITH-LIBXML2=/USR/LOCAL/LIBXML2--enable-so--enable-cgi--enable-rewrite

Shell>make && make Install

Apache installation complete, launch Apache service, view port 80, test Web page:

Shell>/usr/local/apache/bin/apachectl start

SHELL>NETSTAT–LNTP | Grep:80

Shell>curl http://127.0.0.1

Third, install MySQL

This is a binary-format MySQL installation package that creates users and groups for MySQL before installation:

Shell>groupadd MySQL

Shell>useradd–r–g MySQL MySQL



Shell> Tar XF mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz-c/usr/local/

shell> ln-s/usr/local/mysql-5.6.20-linux-glibc2.5-x86_64/usr/local/mysql #给mysql设置软链接

shell> Cd/usr/local/mysql # #进入mysql目录

Shell> chown-r Mysql.mysql. # #给mysql目录设置所属主和组

shell> scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data/--user=mysql # # Initialize the MySQL database and specify the MySQL installation directory, the database storage directory and the owning user



Shell> chown-r Root. # #为了安全将mysql目录下的mysql主改为root用户主

shell> chown-r MySQL data/# #因为我们的数据库默认保存在data目录下, so the database is created as a failure because it should be MySQL for the master of the data directory.



shell> CP Support-files/mysql.server/etc/init.d/mysqld # #将mysql自带的服务启动文件拷贝到系统启动目录下

shell> chmod +x/etc/init.d/mysqld # #给启动服务添加执行权限

shell> chkconfig--add mysqld # #将服务添加到系统启动中

shell> chkconfig--list mysqld # #查看mysql服务启动项

shell> rm-rf/etc/my.cnf # #要删除/etc/my.cnf file, because this is the file that comes with Centos6.5, when we start the MySQL service, the MySQL service will go first. etc under the My.cnf file, and then also in the database installation directory to find the my.cnf file, you can not delete/etc my.cnf file, but remember to modify the configuration file, here for easy to map, so it is deleted, so that the system will automatically find the database installation directory under the My.cnf file

Shell> service mysqld Start # #启动mysql服务



shell>/usr/local/mysql/bin/mysqladmin-u root password ' 123456 '; # #给mysql中的root用户设置密码, default is empty

shell>/usr/local/mysql/bin/mysql-u Root–p # #以root用户登录mysql数据库



Iv. Installation of PHP

Shell> Tar XF php-5.6.0.tar.gz

SHELL>CD php-5.6.0

shell>./configure--prefix=/usr/local/php--with-libxml-dir=/usr/local/libxml2--with-mysql=/usr/local/mysql-- With-apxs2=/usr/local/apache/bin/apxs--with-config-file-path=/etc

Shell> make && make install

shell> CP Php.ini-production/etc/php.ini # #将安装目录下的php. ini-production Copy to/etc as configuration file

V. Configure Apache to combine with PHP

Edit the vi/usr/local/apache/conf/httpd.conf file to see if the PHP module is automatically added in the LoadModule module:

To make Apache associated with the file type extension. PHP: Add a sentence in the/usr/local/apache/conf/httpd.conf file: AddType application/x-httpd-php. php



Add index.php page as default access page:



Restart the Apache service and add the PHP and MySQL test pages:

Six, test lamp Web page

Turn off the MySQL service and revisit the webpage:



At this point, lamp construction is complete.

Linux Service lamp source installation (CentOS)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.