Install apache + mysql + php + phpMyAdmin in the source code

Source: Internet
Author: User
This article describes how to install apache + mysql + php + phpMyAdmin in the source code. If other software packages are missing during installation, we will use yum for installation. If your RHEL is not charged and cannot use yum, configure the yum source of CentOS or download the rpm package.

This article describes how to install apache + mysql + php + phpMyAdmin in the source code. If other software packages are missing during installation, we will use yum for installation. If your RHEL is not charged and cannot use yum, configure the yum source of CentOS or download the rpm package.

This article describes how to install apache + mysql + php + phpMyAdmin in the source code.
If other software packages are missing during the installation process, we will use yum for installation. If your RHEL is not charged and you cannot use yum, configure the CentOS yum source or download the rpm package for installation.
The settings of the firewall and selinux are invalid before installation.
The test environment RHEL5.5 in this article is also suitable for centos5.5.
This article is suitable for beginners to learn and install and is not suitable for the production environment.

1. Download Software

[Root @ RHEL src] # cd/usr/local/src/[root @ RHEL src] # wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.7/phpMyAdmin-3.3.7-all-languages.tar.bz2

2. install and configure mysql

2. 1. compile and install [root @ RHEL src] # tar-xzvf mysql-5.1.50.tar.gz [root @ RHEL src] # cd mysql-5.1.50 [root @ RHEL mysql-5.1.50] # more INSTALL-SOURCE2.3.1. source Installation OverviewThe basic commands that you must execute to install a MySQL sourcedistribution are: shell> groupadd mysqlshell> useradd-g mysql (We will modify it later to prevent mysql users from logging on to the system) shell> gunzip <mysql-VERSION.tar.gz | tar-xvf-(I have extracted this step omitted) shell> cd mys Ql-VERSION (we have already entered the decompressed directory) shell>. /configure -- prefix =/usr/local/mysqlshell> makeshell> make installshell> cp support-files/my-medium.cnf/etc/my. cnfshell> cd/usr/local/mysqlshell> chown-R mysql. shell> chgrp-R mysql. shell> bin/mysql_install_db -- user = mysqlshell> chown-R root. shell> chown-R mysql varshell> bin/mysqld_safe -- user = mysql & [root @ RHEL mysql-5.1.50] # groupadd mysql [root @ RHEL mysql -5.1.50] # useradd-g mysql-s/bin/false mysql [root @ RHEL mysql-5.1.50] #. /configure -- prefix =/usr/local/mysql ...... checking for termcap functions library... configure: error: No curses/termcap library found ...... OOPS! Error! [Root @ RHEL mysql-5.1.50] # yum-y install ncurses-devel (rpm http://ftp.sjtu.edu.cn/centos/5.5/os/i386/CentOS/ncurses-devel-5.5-24.20060715.i386.rpm ) [Root @ RHEL mysql-5.1.50] #. /configure -- prefix =/usr/local/mysql [root @ RHEL mysql-5.1.50] # make [root @ RHEL mysql-5.1.50] # make install [root @ RHEL mysql-5.1.50] # cd/usr/local /mysql [root @ RHEL mysql] # chown-R mysql. [root @ RHEL mysql] # chgrp-R mysql. [root @ RHEL mysql] # bin/mysql_install_db -- user = mysql [root @ RHEL mysql] # chown-R root. [root @ RHEL mysql] # chown-R mysql var [root @ RHEL mysql] # bin/mysqld_safe -- user = mysql & 2. 2. confirm the mysql status and change the password [root @ RHEL mysql] # ps-ef | grep mysql [root @ RHEL mysql] #/usr/local/mysql/bin/mysqladmin-u root password 'mysql' [root @ RHEL mysql] #/usr/local/mysql/bin/mysql-uroot-pEnter password: welcome to the MySQL monitor. commands end with; or/g. your MySQL connection id is 2 Server version: 5.1.50 Source distributionCopyright (c) 2000,201 0, Oracle and/or its affiliates. all rights reserved. this software comes with absolutely no warranty. this is free software, and you are welcome to modify and redistribute it under the GPL v2 licenseType 'help; 'or'/H' for help. type '/C' to clear the current input statement. mysql> 2. 3. use the officially provided boot script and add boot start [root @ RHEL mysql] # cp share/mysql. server/etc/init. d/mysqld [root @ RHEL mysql] #/etc/init. d/mysqld stopShutting down MySQL100909 20:06:48 mysqld_safe mysqld from pid file/usr/local/mysql/var/RHEL. pid ended [OK] [1] + Done bin/mysqld_safe -- user = mysql [root @ RHEL mysql] #/etc/init. d/mysqld startstartstarting MySQL. [OK] [root @ RHEL mysql] #/sbin/chkconfig -- add mysqld [root @ RHEL mysql] #/sbin/chkconfig mysqld on

3. Install apache2.2

3. 1. compile and install [root @ RHEL mysql] # cd/usr/local/src/[root @ RHEL src] # tar-xzvf httpd-2.2.16.tar.gz [root @ RHEL src] # cd httpd-2.2.16 [root @ RHEL httpd-2.2.16] # more INSTALLQuick Start-Unix ------------------ For complete installation documentation, see [ht] docs/manual/install.html or http://httpd.apache.org/docs/2.2/install.html $. /Configure -- prefix = PREFIX $ make install $ PREFIX/bin/apachectl start NOTES: * Replace PREFIX with the filesystem path under which Apache shoshould be installed. A typical installation might use "/usr/local/apache2" for PREFIX (without the quotes ). * In his simplest installation method, we add two compilation parameters * -- enable-rewrite rule based URL manipulation * -- enable-so DSO capability [root @ RHEL httpd-2.2.16] #. /configure -- prefix =/usr/local/apache2 -- enable-rewrite -- enable-so [root @ RHEL httpd-2.2.16] # make [root @ RHEL httpd-2.2.16] # make install3.2. create an apache user [root @ RHEL httpd-2.2.16] # groupadd apache [root @ RHEL httpd-2.2.16] # useradd-g apache-M-s/sbin/nologin apache [root @ RHEL httpd-2.2.16] # vi/usr/ local/apache2/conf/httpd. conf find the following two sentences and add # In the line header comment out the User daemonGroup daemon append the following two sentences User apacheGroup apache3.3. confirm the startup status [root @ RHEL httpd-2.2.16] #/usr/local/apache2/ bin/apachectl start [root @ RHEL httpd-2.2.16] # lsof-I: 80 [root @ RHEL httpd-2.2.16] # lsof-I: 80 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAMEhttpd 14125 root 3u IPv6 194322 TCP *: http (LISTEN) httpd 14354 apache 3u IPv6 194322 TCP *: http (LISTEN) httpd 14355 apache 3u IPv6 194322 TCP *: http (LISTEN) httpd 14356 apache 3u IPv6 194322 TCP *: http (LISTEN) httpd 14357 apache 3u IPv6 194322 TCP *: http (LISTEN) httpd 14358 apache 3u IPv6 194322 TCP *: http (LISTEN) [root @ RHEL httpd-2.2.16] # curl http://localhost (You can enter http://ip Test) <ptml> <body> It works! </Body> </ptml>

* With apachectl, you can easily start and close apache. I will not start the script.
* If you need to, you can search for it online or modify one based on apachectl by referring to other scripts in/etc/init. d /.
* Alternatively, you can add a sentence in/etc/rc. local to start apache at startup/usr/local/apache2/bin/apachectl start.

4. Compile and install php with source code

4. 1. compile and install the root @ RHEL httpd-2.2.16] # cd/usr/local/src/[root @ RHEL src] # tar-jxvf php-5.2.14.tar.bz2 [root @ RHEL src] # cd php-5.2.14 [root @ RHEL php-5.2.14] # more INSTALLApache 2.0 on Unix systems ·....... you are highly encouraged to take a look at the Apache Documentation to get a basic understanding of the Apache 2.0 Server ....... example 2-4. installation Instructions (Apache 2 Shared Module Version) 1. Gzip-d httpd-2_0_NN.tar.gz2. tar xvf httpd-2_0_NN.tar3. gunzip php-NN.tar.gz4. tar-xvf php-NN.tar5. cd httpd-2_0_NN6 .. /configure -- enable-so7. make8. make installNow you have Apache 2.0.NN available under/usr/local/apache2, configured with loadable module support and the standard MPM prefork. to test the installation use your normal procedure for startingthe Apache server, e.g. :/usr/local/apac He2/bin/apachectl startand stop the server to go on with the configuration for PHP:/usr/local/apache2/bin/apachectl stop.9. cd .. /php-NN10 .. /configure -- with-apxs2 =/usr/local/apache2/bin/apxs -- with-mysql (the installation path of mysql will be specified later) 11. make12. make install ....... 13. setup your php. inicp php. ini-dist/usr/local/lib/php. ini ....... 14. edit your httpd. conf to load the PHP module ....... for PHP 5: LoadModule Php5_module modules/libphp5.so15. tell Apache to parse certain extensions as PHP ....... addType application/x-httpd-php. php. phtmlIt's also common to setup. phps extension to show highlighted PHPsource, this can be done with: AddType application/x-httpd-php-source. phps16. Use your normal procedure for starting the Apache server, e.g. :/usr/local/apache2/bin/apachectl start ...... [root @ RHEL Php-5.2.14] #. /configure -- with-apxs2 =/usr/local/apache2/bin/apxs -- with-mysql =/usr/local/mysql ...... configure: error: xml2-config not found. please check your libxml2 installation ....... OOPS! Error! [Root @ RHEL php-5.2.14] # yum-y install libxml2-devel (my situation depends on zlib-devel when installing the libxml2-devel) (rpm http://ftp.sjtu.edu.cn/centos/5.5/os/i386/CentOS/zlib-devel-1.2.3-3.i386.rpm ) (Rpm http://ftp.sjtu.edu.cn/centos/5.5/os/i386/CentOS/libxml2-devel-2.6.26-2.1.2.8.i386.rpm ) [Root @ RHEL php-5.2.14] #. /configure -- with-apxs2 =/usr/local/apache2/bin/apxs -- with-mysql =/usr/local/mysql [root @ RHEL php-5.2.14] # make [root @ RHEL php-5.2.14] # make install [root @ fig php-5.2.14] # cp php. ini-dist/usr/local/lib/php. ini [root @ RHEL php-5.2.14] # vi/usr/local/apache2/conf/httpd. check whether libphp5.so exists in the conf file. If there is no append, the following sentence is not prefixed with # LoadModule foo_module modules/mod_foo.soLoadModule php5_mo. Dule modules/libphp5.so # search for the AddType keyword and append the following AddType application/x-httpd-php. php. phtml then searches for the following section to append the index to the end of the second DirectoryIndex. php <IfModule dir_module> DirectoryIndex index.html index. php </IfModule> 4.1.2 Test php web page [root @ RHEL php-5.2.14] # cd/usr/local/apache2/htdocs/[root @ RHEL htdocs] # vi index. php input content <? Phpphpinfo ();?> [Root @ fig php-5.2.14] #/usr/local/apache2/bin/apachectl restart [root @ RHEL mysql] # curl-I http://localhost/index.php Or enter http://yourip/index.php4.1.3 Test the connection between php and mysql [root @ RHEL htdocs] # vi phpmysql. php input content <? Php mysql_connect ("localhost", "root", "mysql") or die ("MySQL First Test: Failed"); echo "MySQL First Test: Success";?> Because the -- with-mysqli option is not added during php compilation, mysqli extension [root @ RHEL htdocs] # curl is not supported. http://localhost/phpmysql.phpMySQL First Test: Success is ready. I have succeeded here. You can enter it in the browser. http://ip/phpmysql.php

5. install and configure phpMyAdmin

5. 1. configure phpMyAdmin [root @ RHEL mysql] # cd/usr/local/src/[root @ RHEL src] # tar-jxvf phpMyAdmin-3.3.7-all-languages.tar.bz2 we configure phpMyAdmin to/var/www/named phpMyAdmin [root @ RHEL src] # test-d/var/www | mkdir-p/var/www [root @ RHEL src] # mv phpMyAdmin-3.3.7-all-languages/var/www/phpMyAdmin [root @ RHEL src] # cp/var/www/phpMyAdmin/config. sample. inc. php/var/www/phpMyAdmin/config. inc. php [root @ RHEL src] # chmod 660/var/www/phpMyAdmin/config. inc. php [root @ RHEL src] # vi/var/www/phpMyAdmin/config. inc. php append $ cfg ['lang '] = 'zh-UTF-8 '; ---------- optional settings for phpMyAdmin to set a 50-bit phrase password --------------- we recommend that you set it, but to use the mkpasswd command, you need to install the keep CT package [root @ RHEL src] # mkpasswd-l 50clecXjgn7Hg [root @ RHEL src] # vi/var/www/phpMyAdmin/config. inc. php finds the following parameter $ cfg ['blowfish _ secret'] = 'clecxjgn7hg % hangzhou' ---------------------- (optional) End of the Setting --------------------- [root @ RHEL src] # chown-R root. apache/var/www/phpMyAdmin [root @ RHEL src] # cd/usr/local/apache2/conf/[root @ RHEL conf] # vi extra/phpmyadmin. add Alias/phpMyAdmin/var/www/phpMyAdmin <Location/phpMyAdmin> Order deny to the conf file, allowDeny from allAllow from 127.0.0.1Allow from 10.110.108.55 // the ip address you are actually allowed to access. </Location> [root @ RHEL conf] # vi httpd. conf append Include conf/extra/phpmyadmin. conf [root @ RHEL conf] #/usr/local/apache2/bin/apachectl restart5.2. enter the following URL in the browser: http://ip/phpMyAdmin/ Enter the mysql username root and password mysqlEnjoy we set earlier!

When we install php, there will be some warnings when we open phpMyAdmin because there are few parameters added.
But I believe that the reader will re-compile php to solve these problems!

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.