Build a LAMP environment (source code)

Source: Internet
Author: User


-- 1. Install Development tools and ncurses-devel [root @ serv01 ~] # Yum grouplist | grep Devel Additional Development Desktop Platform Development tools Server Platform Development [root @ serv01 ~] # Yum groupinstall "Development tools"-y [root @ serv01 ~] # Yum install ncurses-devel-y -- 2. Unzip [root @ serv01 ~] # Tar-xf mysql-5.1.58.tar.gz-C/usr/src/# file error, re-copy [root @ serv01 ~] # Tar-xf mysql-5.1.58.tar.gz-C/usr/src/tar: Skipping to next headertar: Exiting with failure status due toprevious errors [root @ serv01 ~] # Cd/usr/src/mysql-5.1.58/# Help File [root @ serv01 ~] #. /Configure-help -- 3. configure the [root @ serv01 mysql-5.1.58] #. /configure -- prefix =/usr/local/mysql -- with-extra-charsets = gbk, gb2312-with-plugins = partition, innobase, innodb_plugin, myisam -- 4. compile [root @ serv01 mysql-5.1.58] # make -- 5. install the [root @ serv01 mysql-5.1.58] # make install -- 6. copy the configuration file and run the script [root @ serv02 mysql-5.1.58] # cpsupport-files/my-medium.cnf/etc/my. cnfcp: overwrite'/etc/my. cnf '? Y [root @ serv02 mysql-5.1.58] # cpsupport-files/mysql. server/etc/init. d/mysqld [root @ serv02 mysql-5.1.58] # chmod a + x/etc/init. d/mysqld [root @ serv02 mysql-5.1.58] # ls-l/etc/init. d/mysqld-rwxr-xr-x. 1 root 12302 Aug 15 23: 36/etc/init. d/mysqld -- 7. create a data file storage path and modify my. cnf and mysqld files [root @ serv02 mysql-5.1.58] # mkdir/usr/local/mysql/data [root @ serv02 mysql-5.1.58] # vim/etc/my. cnf [root @ serv02 mysql-5.1.58] # Grep "^ datadir"/etc/my. cnf-n27: datadir =/usr/local/mysql/data [root @ serv02 mysql-5.1.58] # vim/etc/init. d/mysqld [root @ serv02 mysql-5.1.58] # sed "p"/etc/init. d/mysqld-nbasedir =/usr/local/mysqldatadir =/usr/local/mysql/data -- 8. add users and add MySQL users [root @ serv02 mysql-5.1.58] # groupadd mysql [root @ serv02 mysql-5.1.58] # useradd-g mysqlmysql [root @ serv02 mysql-5.1.58] #. /scripts/mysql_install_db -- use R = mysql -- 9. start MySQL, enter/usr/local/mysql/bin/, execute mysql, query MySQL version [root @ serv02 mysql-5.1.58] #/etc/init. d/mysqld startstartstarting MySQL. SUCCESS! [Root @ serv02 mysql-5.1.58] # cd/usr/local/mysql/bin/[root @ serv02 bin] #. /mysqlWelcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 1 Server version: 5.1.58-log Sourcedistribution Copyright (c) 2000,201 0, Oracle and/or itsaffiliates. all rights reserved. this software comes with absolutely nowarranty. this is free software, and you are welcome to modify andredistribute it under the GPL v2 license Type 'help; 'or' \ H' for help. type '\ C' toclear the current input statement. mysql> select version (); + ------------ + | version () | + ------------ + | 5.1.58-log | + ------------ + 1 row in set (0.00 sec) mysql> create database larry defaultcharset utf8; Query OK, 1 row affected (0.00 sec) mysql> use larry; Database changedmysql> show tables; Empty set (0.00 sec) mysql> create table t_user (id int (11) primary key auto_increment, name varchar (20); Query OK, 0 rows affected (0.01 sec) mysql> insert into t_user (name) values ('larrywen'); Query OK, 1 row affected (0.00 sec) mysql> insert into t_user (name) values ('justdb'); Query OK, 1 row affected (0.00 sec) mysql> insert into t_user (name) values ('wgb'); Query OK, 1 row affected (0.00 sec) mysql> select * from t_user; + ---- + ---------- + | id | name | + ---- + ---------- + | 1 | larrywen | 2 | justdb | 3 | wgb | + ---- + ---------- + 3 rows in set (0.00 sec) mysql> create table t_log (id int (11) primary key auto_increment, content varchar (20), t_user_id int (11), constraintfk_larry_t_log_usr_id foreign key (t_user_id) references t_user (id )); query OK, 0 rows affected (0.01 sec) mysql> insert into t_log (content, t_user_id) values ('logining system', 1); Query OK, 1 row affected (0.01 sec) mysql> select * from t_log; + ---- + ----------------- + ----------- + | id | content | t_user_id | + ---- + ----------------- + ----------- + | 1 | Logining System | 1 | + ---- + ------------------- + ----------- + 1 row (0.00 sec) mysql> exitBye -- 10. modify the mysql directory owner and group owner [root @ serv02 mysql-5.1.58] # cd/usr/local/mysql [root @ serv02 mysql] # chown-R mysql. [root @ serv02 mysql] # chgrp-R mysql.

-- 1. unzip [root @ serv02 httpd-2.2.21] # tar -xfhttpd-2.2.21.tar.gz-C/usr/src -- 2. go to the installation directory and check the configuration [root @ serv02 httpd-2.2.21] # cd/usr/src/httpd-2.2.21/[root @ serv02 httpd-2.2.21] #. /configure -- help [root @ serv02 httpd-2.2.21] #. /configure -- prefix =/usr/local/apache -- enable-modules = all -- enable-mod-shared = all -- enable-so -- with-mpm = workerchecking for zlib location... not found # If zlib not found appears, install zlib-devel [root @ serv02 httpd-2.2.21] # yum installzlib-devel-y -- 3. compile [root @ serv02 httpd-2.2.21] # make -- 4. install [root @ serv02 bin] # make install -- 5. go to the/usr/local/apache/bin/directory and start [root @ serv02 apache] # cd/usr/local/apache/bin/[root @ serv02 bin] #. /apachectl-k starthttpd: apr_sockaddr_info_get () failed forserv02.host. comhttpd: cocould not reliably determine theserver's fully qualified domain name, using 127.0.0.1 for ServerName [root @ serv02 bin] # netstat-langput | grephttpd # edit httpd. conf file, add ServerName serv02.host.com; edit the hosts file, add 192.168.1.12 serv02.host.com (note that the IP address of the local machine is 192.168.1.12) [root @ serv02 bin] # vim .. /conf/httpd. conf [root @ serv02 bin] # grep "ServerName"/usr/local/apache/conf/httpd. conf # ServerName gives the name and port that theserver uses to identify itself. # ServerName www.example.com: 80 ServerName serv02.host.com [root @ serv02 bin] # echo "192.168.1.12serv02.host.com">/etc/hostshosts hosts. allow hosts. deny [root @ serv02 bin] # echo "192.168.1.12serv02.host.com">/etc/hosts [root @ serv02 bin] # tail-n1/etc/hosts192.168.1.12 serv02.host.com # Start again and check the port, succeeded [root @ serv02 bin] #. /apachectl-k start [root @ serv02 bin] # netstat-langput | grephttpdtcp 0 0 ::: 80 ::* LISTEN 20441/httpd -- 6. enter http: // 192.168.1.12/in the test browser. If "It works" is displayed, It is successful.

-- 1. Decompress [root @ serv02 ~] # Tar-xf php-5.3.6.tar.bz2-C/usr/src/-- 2. go to the/usr/src/php-5.3.6/directory and configure [root @ serv02 php-5.3.6] # cd/usr/src/php-5.3.6/[root @ serv02 php-5.3.6] #. /configure-help [root @ serv02 php-5.3.6] #. /configure -- prefix =/usr/local/php5 -- with-apxs2 =/usr/local/apache/bin/apxs -- with-mysql-sock =/tmp/mysql. sock -- with-mysql =/usr/local/mysql/checking libxml2 install dir... nochecking for xml2-config path... configure: error: xml2-config not found. please check your libxml2 installation. # If the above error occurs, install libxml2 [root @ serv02 php-5.3.6] # yum install libxml2 *-y + License + | License: | This software is subject to the PHPLicense, available in this | distribution in the file LICENSE. by continuing this installation | process, you are bound by the terms of thislicense agreement. | If you do not agree with the terms of thislicense, you must abort | the installation process at thispoint. | + ---------------------------------------------------------------------- + # If the following text appears, the configuration is successful Thank you for using PHP. -- 3. compile [root @ serv02 php-5.3.6] # make -- 4. install the [root @ serv02 php-5.3.6] # make install -- 5. copy php. INI file, modify httpd. conf file [root @ serv02 bin] # cp php. ini-development/usr/local/php5/lib/php. ini [root @ serv02 bin] # grep-e "AddHandler"-e "AddType"/usr/local/apache/conf/httpd. conf AddHandler php5-script. phpAddType text/html. php

-- 1. modify the root user password and create the test database and table [root @ serv02 bin] #. /mysqlWelcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 2 Server version: 5.1.58-log Sourcedistribution Copyright (c) 2000,201 0, Oracle and/or itsaffiliates. all rights reserved. this software comes with absolutely nowarranty. this is free software, and you are welcome to modify andredistribute it under the GPL v2 license T Ype 'help; 'or' \ H' for help. type '\ C' toclear the current input statement. mysql> set password = password ("helloworld"); Query OK, 0 rows affected (0.00 sec) mysql> exitBye [root @ serv02 bin] #. /mysql-uroot-phelloworldWelcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 3 Server version: 5.1.58-log Sourcedistribution Copyright (c) 2000,201 0, Oracle and/or itsaffiliates. All rights reserved. this software comes with absolutely nowarranty. this is free software, and you are welcome to modify andredistribute it under the GPL v2 license Type 'help; 'or' \ H' for help. type '\ C' toclear the current input statement. mysql> use larryDatabase changedmysql> show tables; + --------------- + | Tables_in_larry | + ----------------- + | t_log | t_user | + ----------------- + 2 rows in Set (0.00 sec) mysql> select * from t_user; + ---- + ---------- + | id | name | + ---- + ---------- + | 1 | larrywen | 2 | justdb | 3 | wgb | + ---- + ---------- + 3 rows in set (0.00 sec) -- 2. create a test PHP file [root @ serv02 php5] # cd/usr/local/apache/htdocs/[root @ serv02 htdocs] # vim index. php [root @ serv02 htdocs] # cat index. php <? Php phpinfo ();?> [Root @ serv02 htdocs] # vim user_list.php [root @ serv02 htdocs] # pwd/usr/local/apache/htdocs [root @ serv02 htdocs] # vim user_list.php [root @ serv02 htdocs] # cat user_list.php <? Php $ conn = mysql_connect ("localhost", "root", "helloworld"); mysql_select_db ("larry", $ conn ); $ users = mysql_query ("select * from t_user"); while (!! $ User = mysql_fetch_array ($ users) {echo $ user ["id"]. "-------> ". $ user ["name"]. "<br>" ;}mysql_close () ;?> [Root @ serv02 htdocs] # -- 3. Enter http: // 192.168.1.12/index. php In the browser. If php-related configuration information appears, the configuration is successful. Enter http: // 192.168.1.12/user_list.php. If the following information appears, the integration of PHP, MySQL, and Apache is successful. 1 -------> larrywen2 -------> justdb3 -------> wgb





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.