Linux Study notes-the 18th lesson-lamp Environment Construction (a)

Source: Internet
Author: User
Tags openssl

First, the preparation of lamp construction

Lamp is the abbreviation for four sets of software, refers to l-linux,a-apache,m-mysql,p-php, the use of these four sets of software to build the environment of the web.

Need to download good software before building

Apache http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz

MySQL 32-bit: http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz

64-bit: http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-x86_64-icc-glibc23.tar.gz

PHP http://cn2.php.net/distributions/php-5.3.28.tar.gz

Software Image http://mirrors.sohu.com/

Install the extension library address

Yum Install-y epel-release

Install library files

Yum-y install NTP make OpenSSL openssl-devel pcre pcre-devel libpng libpng-devel libtiff-devel libjpeg-6b libjpeg-devel-6 b freetype freetype-devel gd gd-devel fontconfig-devel zlib zlib-devel libevent-devel gcc gcc-c++ Flex Bison bzip2-devel L IBXPM libxpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake Screen sy Sstat compat-libstdc++-33 Curl Curl-devel libmcrypt-devel

Turn off SELinux

Second, Apache

1) compiling

# Unzip the package [[email protected] src]# TAR-ZXVF httpd-2.2.16# into the software directory [[email protected] src]# CD httpd-2.2.16# execute compilation parameters [[Email prot Ected] httpd-2.2.16]#./configure--prefix=/usr/local/apache2--enable-so--enable-mods-shared=most# start compiling [[Email Protected] httpd-2.2.16]# make# install software [[email protected] httpd-2.2.16]# make install

2) Modify the configuration

[[email protected] ~]# vim /usr/local/apache2/conf/httpd.conf ......... ...] Omit .....................# at a local disk.  if you wish to  above Share the same serverroot for multiple# httpd daemons, you will  need to change at least lockfile and pidfile. #ServerRoot   "/usr/ Local/apache2 "       # apache  program directory ........... Omit in the middle ..... # #Listen  12.34.56.78:80Listen 80       -----     #  Monitor Port ## dynamic shared object  (DSO)  support ................... In the middle of the omission ...... # as error documents.  e.g. [email protected]# ..... serveradmin [email protected]           #   Admin e-mail address ....... ..... Middle omitted ......... # if your host doesn ' T have a registered dns name----- ,  enter its ip address here. #ServerName  localhost:80          #  default servername www.example.com:80                                  #  here needs to be modified, by default is the comment "#" comment out of the # ...... In the middle of the omission ...... # symbolic links and aliases may be used to .....  point to other locations. #DocumentRoot   "/usr/local/apache2/htdocs/"          #  Site file storage location, file monitoring directory                                   ## each directory to which apache has access can be configured  With respect ....... ........ Middle omitted ....................# features.#<directory />    options  Followsymlinks    allowoverride none    order deny,allow     Allow from all     #  defaults to deny from  All, deny access, modify to Allow from all, allow access </Directory>## Note that from this  Point forward you must specifically allow

3) Start Apache

# Modify configuration, detect if Ok[[email protected] ~]#/usr/local/apache2/bin/apachectl-tsyntax ok[[email protected] ~]#/usr/local/ Apache2/bin/apachectl start

4) detect whether the HTTPD service has started, whether the network port is turned on, shut down the firewall, or 80 port release, the network can access the

 #  Process Detection [[email protected] ~]# ps aux|grep httpdroot      25675  0.0  0.2   5280  2148 ?         ss   12:30   0:00 /usr/local/apache2/bin/httpd  -k startdaemon   25676  0.0  0.1   5280   1548 ?        S    12:30    0:00 /usr/local/apache2/bin/httpd -k startdaemon   25677  0.0   0.1   5280  1548 ?        s     12:30   0:00 /usr/local/apache2/bin/httpd -k startdaemon    25678  0.0  0.1   5280  1548 ?         s    12:30   0:00 /usr/local/apache2/bin/httpd -k  startdaemon   25679  0.0  0.1   5280  1548 ?         s    12:30   0:00 /usr /local/apache2/bin/httpd -k startdaemon   25680  0.0  0.1    5280  1548 ?        S     12:30   0:00 /usr/local/apache2/bin/httpd -k startroot      25686  0.0  0.0   4356   740 pts/4     s+   12:34   0:00 grep httpd[[email protected]  ~]##  Port Detection [[email protected] ~]# netstat -nlp |grep httpdtcp         0      0 :::80                        :::*                           LISTEN      25675/httpd        #  site State access detection [[email protected] ~]# curl -i localhosthttp/1.1  200 okdate: tue, 28 apr 2015 04:45:54 gmtserver: apache/2.2.16   (Unix)  DAV/2Last-Modified: Sat, 20 Nov 2004 20:16:24 GMTETag:  12a8-2c-3e9564c23b600 "accept-ranges: bytescontent-length: 44content-type: text/html

Enter the IP address in the browser, if displayed

It works!

The rep has started successfully!



Third, MySQL

#  Decompression mysql[[email protected] src]# tar -zxvf  The mysql-5.1.40-linux-i686-icc-glibc23.tar.gz#  file program moves to the specified installation path [[EMAIL&NBSP;PROTECTED]&NBSP;SRC]#&NBSP;MV  mysql-5.1.40-linux-i686-icc-glibc23 /usr/local/mysql#  create a MySQL user with a shell status of/sbin/nologin[[email  protected] mysql]# useradd -s /sbin/nologin mysql#  Enter/usr/local/mysql, Initialize MySQL library, when there are 2 OK, on behalf of the initialization success #  here to note, need to modify/etc/hosts, the host name, added to the file [[email protected] mysql]# ./ scripts/mysql_install_db --user=mysql --datadir=/data/mysqlinstalling mysql system  Tables ... Okfilling help tables ... Ok.................. Below omit ....................#  copy startup script, change permissions [[email protected] mysql]# cp support-files/ mysql.server /etc/init.d/mysqld[[email protected] mysql]# chmod 755 /etc/init.d/ mysqld#  Modifying the startup script [[Email protected] mysql]# vim /etc/init.d/mysqld ........................The above omitted ... basedir=        <== mysql program path datadir=------...         <== mysql data Path ......... .......... The following omit ...................#  copy mysql configuration file, here need to notice how much of their physical memory [[EMAIL&NBSP;PROTECTED]&NBSP;MYSQL]#&NBSP;CP  support-files/my-my-huge.cnf              my-large.cnf             my-small.cnfmy-innodb-heavy-4g.cnf  my-medium.cnf[[email protected] mysql]# cp  support-files/my-large.cnf /etc/my.cnfcp: overwrite  '/etc/my.cnf '? y#  adds mysqld to the list of services, and start [[email protected] mysql]# chkconfig --add mysqld[[email protected]  mysql]# chkconfig mysqld on[[email protected] mysql]# service mysqld  startstarting mysql... success!

Then process detection, port detection



Iv. PHP

#  Unpacking software [[email protected] php-5.3.28]# tar -zxvf php-5.3.28.tar.gz#  Go to php file directory, edit parameter [[email protected] php-5.3.28]# ./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#   Execute compile [[email protected] php-5.3.28]# make#  installation file [ro[email protected]  Php-5.3.28]# make install



V. Combination of PHP and Apache

Modify the Apache configuration file

[[email protected] ~]# vim /usr/local/apache2/conf/httpd.conf ................. Omit ...........................# is requested.#<ifmodule dir_module>    above  DirectoryIndex index.html index.htm index.php  <==  Default no index.htm and index.php, need to add </ifmodule>## the following lines prevent .htaccess  and .htpasswd files from being ......... .......... In the middle of the omission .....     # if the addencoding directives. .....???????  above are commented-out, then you    # probably should  define those extensions to indicate media types:    #     addtype application/x-compress . Z    addtype application/x-gzip .gz .tgz    addtype  application/x-httpd-php .php <==  need to add this line here, to increase the parsing of PHP     #     # addhandler allows you to map certain file extensions  to  "Handlers":    # actions unrelated to filetype.  These can be either built into the server ......... .......... Omitted below ...... ..................

Also check to see if the PHP module is loaded

LoadModule php5_module modules/libphp5.so

After modifying the configuration, the Apache service needs to be restarted (detection required before reboot)

# Write PHP parsing test file [[email protected] ~]# vim/usr/local/apache2/htdocs/test.php<?phpphpinfo ();? >[[email protected] ~]# curl-i localhost/test.phphttp/1.1 okdate:tue, APR 23:03:35 gmtserver:apache/2.2. (Unix) DAV/2 php/5.3.28x-powered-by:php/5.3.28content-type:text/html

Enter the IP address in the browser, display the following interface, on behalf of the resolution of PHP success

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6C/17/wKioL1U_o6TQSPQ2AAOXnETv-XA134.jpg "title=" Qq20150428230714.jpg "alt=" Wkiol1u_o6tqspq2aaoxnetv-xa134.jpg "/>


This is where the lamp environment is built.





This article is from the "Mylinux" blog, make sure to keep this source http://mylinuxlife.blog.51cto.com/4706737/1640056

Linux Study notes-the 18th lesson-lamp Environment Construction (a)

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.