Compile and install the lamp environment in centos 6.2

Source: Internet
Author: User

System Environment: centos 6.2 (pure system environment, preliminary system optimization)

System kernel: 2.6.32-220. el6.x86 _ 64

Software Version: http-2.4.2; mysql-5.5.23; php-5.3.13

Gossip: Install software through source code and prepare the installation environment (such as GCC and other tools)

Qq For personal study and communication: 875656692

yum -y install gcc gcc-c++ openssl openssl-devel yum install -y ncurses ncurses-devel


1. Compile and install the http-2.4.2


1.1 download required software packages

HTTP: http://www.apache.org/

APR: http://www.apache.org/

PC: http://www.pcre.org/


1.2 decompress

tar -xf httpd-2.4.2.tar.bz2 tar -xf apr-util-1.4.1.tar.bz2 tar -xf apr-1.4.6.tar.bz2 tar -xf apr-iconv-1.2.1.tar.bz2 tar -xf pcre-8.35.tar.gz


1.3 compile and install

cd apr-1.4.6./configure --with-apr=/usr/local/aprmake && make installcd ..
cd apr-util-1.4.1./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/make && make installcd ..
cd apr-iconv-1.2.1./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr/make && make installcd ..
cd pcre-8.35./configure --prefix=/usr/local/pcremake && make installcd ..
CD httpd-2.4.2. /configure -- prefix =/usr/local/apache2 -- With-Apr =/usr/local/APR -- With-Apr-util =/usr/local/APR-util --- apr-iconv =/usr/local/APR-iconv -- With-PCRE =/usr/local/PCRE -- enable-SSL -- enable-Rewrite -- enable-Dav -- enable-authz -- enable-cgid -- enable-CGI -- enable-module = somake & make installcd .. ##### http-2.4.2 compilation and installation #####


1.4 Configuration

Create an Apache program user (used to replace the default Daemon) useradd-m-S/sbin/nologin web (do not create a home directory; Disable login)

Edit the Apache configuration file Vim/usr/local/Apache/CONF/HTTP. conf

Change "directoryindex index.html" to "directoryindex index.html index. php"

# Add PHP File Parsing

Change "Options indexes followsymlinks" to "Options followsymlinks"

# Do not display the directory structure

Change "AllowOverride none" to "AllowOverride all"

# Enable Apache to support pseudo-static. There are three

Remove the comment "# loadmodule rewrite_module modules/mod_rewrite.so" as "loadmodule rewrite_module modules/mod_rewrite.so"

# Enable Apache to support pseudo-static

Remove the comment "# servername www.example.com: 80" and set it to "servername www.name.com: 80"

Add Apache to Global Environment Variable

Echo "Export Path = $ path:/usr/local/apache2/bin">/etc/profile & source/etc/profile

Check the syntax/usr/local/Apache/bin/apachectl-tsyntax OK

Start Apache

/usr/local/apache/bin/apachectl

Open your browser and enter IP/index.html.

It works!


2. Compile and install the mysql-5.5.23


2.1 Download required software packages

Cmake: http://www.cmake.org/

MySQL: http://www.mysql.com/downloads/


2.2 decompress

tar -xf cmake-2.8.8.tar.gztar -xf mysql-5.5.23.tar.gz


2.3 compile and install

cd cmake-2.8.8./configuremake && make installcd ..
CD mysql-5.5.23cmake-dcmake_install_prefix =/usr/local/mysql-5.5.23-dmysql_datadir =/usr/local/mysql-5.5.23/data/-ddefault_charset = utf8-ddefault_collation = utf8_general_ci-connector: string = All-rows = 1-dwith_innobase_storage_engine = 1-rows = 1-dwith_readline = 1-denabled_local_infile = 1-dmysql_user = mysql-DWITH-EMBEDDED_SERVER = 1-dsysconfdir =/usr/local/mysql-5.5.23 /CONF/My. CNF-dmysql_tcp_port = 3308-dwith_ssl = yes-dwith_memory_storage_engine = 1-runtime = 1-runtime = 1-dinstall_plugindir =/usr/local/mysql-5.5.23/pluginmake & make installcd .. add a soft connection to facilitate MySQL version upgrade ln-S/usr/local/mysql-5.5.23 // usr/local/MySQL #### mysql-5.5.23 compilation and installation #####


2.4 configure MySQL

Create a MySQL user (LOGIN prohibited and home directory not created) useradd-m-S/sbin/nologin MySQL initialize CMD/usr/local/mysql-5.5.23/scripts/mysql_install_db -- basedir =/usr/local/mysql-5.5.23/-- datadir =/usr/local/ mysql-5.5.23/data/-- user = MySQL initialization result display warning: the host '84 'could not be looked up with resolveip. this probably means that your libc libraries are not 100% compatiblewith this binary MySQL version. the MySQL daemon, mysqld, shoshould wo Rknormally with the exception that host name resolving will not work. This means that you should use IP addresses instead of hostnameswhen specifying MySQL privileges! Installing MySQL system tables... okfilling help tables... okto start mysqld at boot time you have to copysupport-files/MySQL. server to the right place for your systemplease remember to set a password for the MySQL Root User! To do so, start the server, then issue the following commands: /usr/local/mysql-5.5.23 // bin/mysqladmin-u Root Password 'new-password'/usr/local/mysql-5.5.23 // bin/mysqladmin-u root-H 84 password' new -Password 'Alternatively you can run: /usr/local/mysql-5.5.23 // bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. this I Sstronugly recommended for production servers. see the manual for more instructions. you can start the MySQL daemon with: CD/usr/local/mysql-5.5.23 /; /usr/local/mysql-5.5.23 // bin/mysqld_safe & you can test the MySQL daemon with mysql-test-run.plcd/usr/local/mysql-5.5.23 // mysql-test; perl mysql-test-run.plPlease report any problems with the/usr/local/mysql-5.5.23 // scripts/mysqlbug script!
Configure the MySQL global environment variable echo "Export Path = $ path:/usr/local/MySQL/bin/MySQL">/etc/profile $ source/etc/profile
Copy the MySQL configuration file to CP/usr/local/MySQL/support-files/my-innodb-heavy-4G.cnf/usr/local/MySQL/CONF/My. CnF in the specified path
Compile the MySQL configuration file and modify my. cnfbasedir =/usr/local/MySQL/datadir =/usr/local/MySQL/data: mySQL/usr/local/mysql-5.5.23/Data
Start mysqlmysqld_safe -- defaults-file =/usr/local/MySQL/CONF/My. CNF &
Set the login password of the MySQL user root (MySQL is installed for the first time, and the root login password is blank. You can directly log on) mysqladmin-u Root Password 'new-password'
PS: export and import data (many methods, you can choose from) Export: mysqldump-uroot-P (passwd) db_name>/DIR/db_name. SQL import: mysql-uroot-P (passwd) db_name </DIR/db_name. SQL


3. Compile and install the php-5.3.13

3.1 decompress

tar -xf php-5.3.13.tar.bz2


3.2 compile and install

PS: You can choose the parameter, the more you choose, the more dependencies you want to install (personal understanding, for reference only) I need to install a ibxml2-devel here

yum install -y libxml2-devel
CD php-5.3.13. /configure -- prefix =/usr/local/php-5.3.13 -- With-config-file-Path =/usr/local/php-5.5.13/etc -- With-mysql =/usr/local/mysql-5.5.23/ -- With-mysqli =/usr/local/mysql-5.5.23/bin/mysql_config -- With-iconv-dir -- With-libxml-dir -- With-FreeType-dir -- With-JPEG-dir -- with-PNG-dir -- With-zlib -- With-PCRE-Dir =/usr/local/PCRE -- enable-XML -- with-apxs2 =/usr/local/apache2/bin/apxs -- enable-inline-optimization -- enable-zip -- with-bz2 -- without-pear -- With-curl =/usr/local/curl-7.3make & make installcd .. ##### php-5.3.13 compilation and installation #####


3.3 configure PHP (refer to http://sonice.blog.51cto.com/994545/796317 here)

cp /usr/local/src/php-5.5.23/php.ini-production  /usr/local/php5/etc/php.inivi /usr/local/php5/etc/php.ini

Find "; open_basedir ="; change it to "open_basedir =.:/tmp/" # prevent PHP trojans from being cross-site

Find "disable_functions =" and change it to "disable_functions = passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_get_status, ini_alter, ini_alter, DL, openlog, syslog, readlink, symlink, delimiter, DLL, popen, disk_free_space, checkdnsrr, checkdnsrr, getservbyname, getservbyport, delimiter, posix_ctermid, delimiter, expires, posix_getegid, expires, signature, delimiter, delimiter, posix_getgroups, delimiter, posix_getpid, signature, posix_getpwnam, posix_getpwuid, signature, posix_getsid, posix_getuid, signature, posix_kill, posix_mkfifo, signature, expires, posix_setpgid, posix_setsid, posix_setuid, posix_strerror, posix_times, posix_ttyname, posix_uname"

# List functions that can be disabled by PHP. If some programs need this function, they can be deleted to cancel the function.

Find "; date. timezone =", and change it to "date. timezone = PRC"

Find "expose_php = on" and change it to "expose_php = OFF" # disable displaying PHP version information
Find "display_errors = on" and change it to "display_errors = OFF" # Disable Error prompt

Configure Apache to support PHP

vi /usr/local/apache2/conf/httpd.conf

# Edit the Apache configuration file

Add,
Addtype application/X-httpd-PHP. php (Note: There is a space in front of PHP. php)
Service httpd restart # restart Apache

PS: After configuration, You need to reload Apache

/Usr/local/Apache/bin/Apache graceful # If you have configured global environment variables, you can directly use Apache graceful.

Verify Configuration results

# Place the following PHP file in the Apache root directory. Open the browser and enter: IP/index. php to view a series of PHP information cat index. php <? Phpphpinfo ();?>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/48/12/wKioL1QFjCqTT9GYAAR_TnI5Uwk479.jpg "Title =" F90751BA-E799-468A-BDB1-FB4A6611F62D.png "alt =" wkiol11_jcqtt9gy1__tni5uwk479.jpg "/>

Conclusion: This blog post aims to summarize and record the use of it. It is ***. Although it refers to the excellent blog posts of many others on the internet, it still has many shortcomings, I hope to help readers who are interested in it and will add it later.



This article is from the "contain big" blog, please be sure to keep this source http://yumao.blog.51cto.com/9298275/1547950

Compile and install the lamp environment in centos 6.2

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.