LAMP=Linux+Apache+Mysql+Php

巴扎黑
巴扎黑Original
2017-06-23 14:34:402868browse

1. The current mainstream of the InternetwebService

Static service:

1.apache---Small and medium-sized staticwebThe mainstream of services, webThe big brother in the server

2.nginx---Large new network staticwebService mainstream,webNewborn calf in the server

3 .lighttpd---staticwebThe service is tepid, which means it is gradually being eliminated. The community is not active and the efficiency is very high.

Dynamic services:

1.IIS (Internet information services)---Microsoft’s web server (aspaspx

2.tomcat---SME NewswebService mainstream, InternetjavaContainer mainstream (jsp,do

3.resin---Large dynamic websitewebService mainstream, Internet java Container mainstream (jsp, do)

4.phpfcgi---Large, medium and small websites,php Parsing container of the program

a.With apache, php is not Daemon process, but mod_php5.so(module)

b. Cooperate withnginx,lighttpd, php daemon mode, FCGI mode.

2. Installation of apache

1.First make sure to install httpd Service (yum install httpd -y)

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

2.Installationapache (Address can be found on the official website)

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 apache service:

1) Check whether the 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 started: lsof -i:80 or ps -ef|grep apache

it works indicates success

If notokCheck the port, firewall,selinux, process

straceCommand to trace the process

Modify the compiled content under /application/apache/htdocs/index.html

三、/application/apacheDirectory structure

##apache optimization 1. Put root@localhost conf]# vi Add a - sign in front of the Index in httpd.conf or delete it directly

##/application/apache/conf/extra

Three key files

4. Virtual host

1.

Virtual host: When deploying multiple sites, each site wants to use a different domain name and site directory, or a different port, or a different

IP, a virtual host is required.

In a word, if a

http service needs to configure multiple sites, a virtual machine is required. Virtual machine classification:

a. Based on domain name

b. Based on port

c.

Based on

IP

2. Build a virtual machine (based on domain name)

Domain name

                                                                                                                                  www.etiantian.org                                                                                                                                                                                                      #Create 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 /application/apache/conf/extra/httpd-vhosts.conf

ServerAdmin 928939638@qq .com

DocumentRoot "/var/html/www"

ServerName www.etiantian.org

ServerAlias ​​etiantian.org

ErrorLog "logs/www -error_log"

CustomLog "logs/www-access_log" common

ServerAdmin 928939638@qq.com

DocumentRoot "/var/html/blog"

ServerName blog.etiantian.org

ErrorLog "logs/blog-error_log "

CustomLog "logs/blog-access_log" common

ServerAdmin 928939638@qq.com

DocumentRoot "/var/html/bbs"

ServerName bbs.etiantian.org

ErrorLog "logs/bbs-error_log"

CustomLog "logs/bbs-access_log" common

vim /application/apache/conf/httpd.conf (go Click on the two lines to comment)

[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:

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

The above configuration is to prevent 403 errors, and then check whether the syntax is wrong (if there are any errors, check

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

1. mysql

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

Compilation of

mysql:

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

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

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

--enable-assembler \

--enable-thread-safe-client \

--with-mysqld-user=mysql \

--with-big-tables \

-- without-debug \

--with-pthread \

--enable-assembler \

--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]# cd 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 future 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 future 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

strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd /application/mysql ; /application/mysql/bin/mysqld_safe &

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

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

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

Startmysql:/application /mysql/bin/mysqld_safe & (When starting the service, please add it to auto-start at boot)

[root@localhost support-files]# netstat -lntup|grep mysql (Confirm whether the service is started)

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

Close:

mysqladmin shutdown

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

mysql -uroot -p (method to log in to mysql after setting password)

2.

phpapache== under php

LAMPlibphp5.so

nginx php==fcgi php-

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg- devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel opens sl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers(Various libraries that need 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 (compile and install)

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--r-- 1 root root 9262 April 15 09:27 httpd.exp

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

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

LoadModule php5_module modules/libphp5.so

ConfigurationphpFile:

There are two, one is the production environment The other is the development environment (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 formal configuration file is generally closed to display LOG, and does not output LOG

Configurationapache support php

vim /application/apache/conf/httpd.conf Modify line 98 ServerName 192.168.76.128:80

vim /application/apache /conf/httpd.conf Add two lines under line 311

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

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

The user daemon should be modified to other ones below (the default one everyone knows must be modified)

line 166 should be modified to

[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,321d319

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

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

Addwww user: useradd www -s /sbin/nologin -M

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

Testphp In the virtual machine built before/var/html/blog vi index.php

[root@localhost blog]# cat index.php

phpinfo();

?>

##The appearance of this interface indicates that php+apache is successful

vi /var/html/blog/index.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 upper interface indicates mysqlsuccess

The above is the detailed content of LAMP=Linux+Apache+Mysql+Php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn