LAMP = Linux + Apache + Mysql + Php, lampapache

Source: Internet
Author: User
Tags openldap

LAMP = Linux + Apache + Mysql + Php, lampapache

I. Mainstream Internet web Services

Static service:

1. apache --- the mainstream of Small and Medium-sized static web Services, the eldest brother in web Servers

2. nginx --- mainstream of large new types of static web Services, and the newborn calf in web Servers

3. lighttpd: static web services are not warm and gradually obsolete. The community is inactive and efficient.

Dynamic service:

1. IIS (Internet information services) --- Microsoft web Server (asp, aspx)

2. tomcat --- mainstream dynamic web services for small and medium-sized enterprises and mainstream Internet java containers (jsp, do)

3. resin --- mainstream web Services for Large Dynamic websites and mainstream Internet java containers (jsp and do)

4. php (fcgi) --- A parsing container for large and medium-sized websites and php programs

A. with apache, php is not a daemon, but mod_php5.so (module)

B. Use nginx, lighttpd, php daemon mode, and FCGI mode.

 

Ii. apache installation

1. First confirm to install httpd service (yum install httpd-y)

OK: yum install gcc ++ zlib-devel-y

2. install apache (Address: http://apache.fayea.com/httpd/)

Apache source code compilation:

./Configure -- prefix =/application/apache2.2.32 \

-- Enable-expires \

-- Enable-headers \

-- Enable-modules = most \

-- Enable-so \

-- With-mpm = worker \

-- Enable-deflate \

-- Enable-rewrite

Make & make install

3. Start the apache service:

1) Check whether apache syntax is feasible: [root @ localhost local] #/application/apache/bin/apachectl-t

2) start the apache service: [root @ localhost local] #/application/apache/bin/apachectl start

3) check whether the apache service is enabled: lsof-I: 80 or ps-ef | grep apache

 

 

It works indicates successful

If not OK, check the port, firewall, selinux, Process

Strace command for process tracing

Modify the compilation content to include index.html under/application/apache/htdocs /.

 

Iii./application/apache directory structure

 

 

 

 

 

Apache optimization 1. Add a-sign or delete the Index in root @ localhost conf] # vi httpd. conf

 

 

 

/Application/apache/conf/extra three key files

 

Iv. VM

1. VM: deploy multiple sites. Different domain names and site directories, or ports, and virtual hosts are required for different IP addresses.

In a word, a virtual machine is required to configure multiple sites for an http service.

Virtual Machine category:

A. Based on domain names

B. Port-based

C. IP-based

 

2. Build a Virtual Machine (based on domain names)

Domain site directory

Www.etiantian.org/var/html/www

Blog.etiantian.org/var/html/blog

Bbs.etiantian.org/var/html/bbs

Create a home page file:

[Root @ localhost apache] # mkdir/var/html/{www, blog, bbs}-p

[Root @ localhost apache] # touch/var/html/{www, blog, bbs}/index.html

[Root @ localhost apache] # for name in www blog bbs; do echo "http: // $ name.etiantian.org">/var/html/$ name/index.html; done

[Root @ localhost apache] # for name in www blog bbs; do cat/var/html/$ name/index.html; done

 

Vim/APP/apache/conf/extra/httpd-vhosts.conf

<VirtualHost *: 80>

ServerAdmin 928939638@qq.com

DocumentRoot "/var/html/www"

ServerName www.etiantian.org

ServerAlias etiantian.org

ErrorLog "log/www-error_log"

CustomLog "logs/www-access_log" common

</VirtualHost>

 

<VirtualHost *: 80>

ServerAdmin 928939638@qq.com

DocumentRoot "/var/html/blog"

ServerName blog.etiantian.org

ErrorLog "log/blog-error_log"

CustomLog "logs/blog-access_log" common

</VirtualHost>

 

<VirtualHost *: 80>

ServerAdmin 928939638@qq.com

DocumentRoot "/var/html/bbs"

ServerName bbs.etiantian.org

ErrorLog "log/bbs-error_log"

CustomLog "logs/bbs-access_log" common

</VirtualHost>

 

Vim/application/apache/conf/httpd. conf (Click comment on the next two lines)

 

 

 

[Root @ localhost extra] #/application/apache/bin/apachectl-t

Syntax OK

Check syntax

[Root @ localhost extra] #/application/apache/bin/apachectl graceful Restart apache

 

Vim/application/apache/conf/httpd. conf Add the following content to the last line:

<Directory "/application/apache2.2.32/htdocs">

Options FollowSymLinks

AllowOverride None

Order allow, deny

Allow from all

</Directory>

The above configuration is to prevent 403 errors and then check the syntax for error http://blog.csdn.net/u011130583/article/details/42363831 (with error viewing

 

Modify windows Local system32 drives hosts (192.168.76.128 www.etiantian.org blog.etiantian.org bbs.etiantian.org

)

[Root @ localhost extra] # grep "^ Include"/application/apache/conf/httpd. conf

Include conf/extra/httpd-mpm.conf

Include conf/extra/httpd-vhosts.conf

 

I. mysql

Create mysql: useradd mysql-g mysql-M-s/sbin/nologin

 

Mysql Compilation:

./Configure -- prefix =/application/mysql5.1.72 \

-- With-unix-socket-path =/application/mysql5.1.72/tmp/mysql. sock \

-- Localstatedir =/application/mysql5.1.72/data \

-- Enable-Cycler \

-- Enable-thread-safe-client \

-- With-mysqld-user = mysql \

-- With-big-tables \

-- Without-debug \

-- With-pthread \

-- Enable-Cycler \

-- With-extra-charsets = complex \

-- With-readline \

-- With-ssl \

-- With-embedded-server \

-- Enable-local-infile \

-- With-plugins = partition, innobase \

-- With-mysqld-ldflags =-all-static \

-- With-client-ldflags =-all-static

Yum-y install ncurses-devel (error solution)

 

Root @ localhost application] # cd/home/cai/tools/

[Root @ localhost tools] # mysql-5.1.72/support-files/

[Root @ localhost support-files] # cp my-small.cnf/etc/my. cnf

Cp: overwrite "/etc/my. cnf "? Y

[Root @ localhost support-files] # cd/etc/

[Root @ localhost etc] # less my. cnf

[Root @ localhost etc] # mkdir/application/mysql/date-p

[Root @ localhost etc] # chown-R mysql. mysql/application/mysql

[Root @ localhost etc] #/application/mysql/bin/mysql_install_db -- basedir =/application/mysql -- datadir =/application/mysql/data/-- user = mysql

Installing MySQL system tables...

170314 20:15:22 [Warning] '-- skip-locking' is deprecated and will be removed in a ure release. Please use '-- skip-external-locking' instead.

OK

Filling help tables...

170314 20:15:22 [Warning] '-- skip-locking' is deprecated and will be removed in a ure release. Please use '-- skip-external-locking' instead.

OK

 

To start mysqld at boot time you have to copy

Support-files/mysql. server to the right place for your system

 

Please remember to set a password for the MySQL root USER!

To do so, start the server, then issue the following commands:

 

/Application/mysql/bin/mysqladmin-u root password 'new-password'

/Application/mysql/bin/mysqladmin-u root-h localhost. localdomain password 'new-password'

 

Alternatively you can run:

/Application/mysql/bin/mysql_secure_installation

 

Which will also give you the option of removing the test

Databases and anonymous user created by default. This is

Stronugly recommended for production servers.

 

See the manual for more instructions.

 

You can start the MySQL daemon:

Cd/application/mysql;/application/mysql/bin/mysqld_safe &

 

You can test the MySQL daemon with mysql-test-run.pl

Cd/application/mysql-test; perl mysql-test-run.pl

 

Please report any problems with the/application/mysql/scripts/mysqlbug script!

 

 

Start mysql:/application/mysql/bin/mysqld_safe)

[Root @ localhost support-files] # netstat-lntup | grep mysql (check whether the service is enabled)

 

Add a user line at the end of vi/etc/profile

 

 

 

Close:

Mysqladmin shutdown

 

 

/Application/mysql/bin/mysqladmin-u root-h localhost. localdomain password 'new-password' to set the password

Mysql-uroot-p (how to log on to mysql after the password is set)

 

Ii. php

Php under LAMP

Apache = libphp5.so

Nginx php = fcgi php-

 

Yum-y install gcc-c ++ autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses- devel curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn-devel openssl-devel openldap-devel nss_ldap openldap-clients openldap-servers (various libraries to be installed)

 

Yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel-y (in oldboy)

Libiconv library required (Compilation and installation)

 

Php Compilation:

 

./Configure \

-- Prefix =/application/php5.3.27 \

-- With-apxs2 =/application/apache/bin/apxs \

-- With-mysql =/application/mysql \

-- With-xmlrpc \

-- With-openssl \

-- With-zlib \

-- With-freetype-dir \

-- With-gd \

-- With-jpeg-dir \

-- With-png-dir \

-- With-iconv =/usr/local/libiconv \

-- Enable-short-tags \

-- Enable-sockets \

-- Enable-zend-multibyte \

-- Enable-soap \

-- Enable-mbstring \

-- Enable-static \

-- Enable-gd-native-ttf \

-- With-curl \

-- With-xsl \

-- Enable-ftp \

-- With-libxml-dir

 

[Root @ localhost php] # ll/application/apache/modules/

Total usage 23908

-Rw-r -- 1 root 9262 April 15 09:27 httpd. exp

-Rwxr-xr-x 1 root 24465701 April 15 10:15 libphp5.so

[Root @ localhost php] # grep libphp5/application/apache/conf/httpd. conf

LoadModule php5_module modules/libphp5.so

 

Configure the PHP file:

 

 

There are two: one is the production environment and the other is the development environment (the test environment)

[Root @ localhost php-5.3.27] # diff php. ini-development php. ini-production

[Root @ localhost php-5.3.27] # cp php. ini-production/application/php/lib/php. ini

Summary: The official configuration file usually closes the display LOG and does not output the LOG.

 

Configure apache to support php

Vim/application/apache/conf/httpd. conf modify 98 rows of ServerName 192.168.76.128: 80

 

 

Vim/application/apache/conf/httpd. conf add two lines under row 311

AddType application/x-httpd-php. php. phtml

AddType application/x-httpd-php-source. phps

 

 

Change user daemon to another one (by default, everyone knows that it must be modified)

Change row 166

 

 

[Root @ localhost conf] # diff httpd. conf httpd. conf. ori

67, 68c67, 68

<User www

<Group www

---

> User daemon

> Group daemon

168c168

<DirectoryIndex index. php index.html

---

> DirectoryIndex index.html

320,321 d319.

<AddType application/x-httpd-php. php. phtml

<AddType application/x-httpd-php-source. phps

 

Add www User: useradd www-s/sbin/nologin-M

[Root @ localhost conf] #/application/apache/bin/apachectl graceful Restart apache service

 

Test/var/html/blog vi index. php In the created virtual machine.

 

[Root @ localhost blog] # cat index. php

<? Php

Phpinfo ();

?>

 

 

This interface indicates that php + apache is successful.

 

Vi/var/html/blog/index. php

 

<? Php

// $ Link_id = mysql_connect ('hostname ', 'user', 'Password ');

$ Link_id = mysql_connect ('localhost', 'root', 'oldboy123 ') or mysql_error ();

 

If ($ link_id ){

Echo "mysql successful by oldboy! ";

} Else {

Echo mysql_error ();

}

?>

 

 

The above interface indicates that mysql is successful.

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.