LAMP=Linux+Apache+Mysql+Php

Jun 23, 2017 pm 02:34 PM
lamp php

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 of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles