search

LAMP=Linux+Apache+Mysql+Php

Jun 23, 2017 pm 02:34 PM
lampphp

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 daemon

> Group daemon

168c168

---

> DirectoryIndex index.html

320,321d319

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
What is Maintenance Mode in Linux? ExplainedWhat is Maintenance Mode in Linux? ExplainedApr 22, 2025 am 12:06 AM

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

Linux: A Deep Dive into Its Fundamental PartsLinux: A Deep Dive into Its Fundamental PartsApr 21, 2025 am 12:03 AM

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

Linux Architecture: Unveiling the 5 Basic ComponentsLinux Architecture: Unveiling the 5 Basic ComponentsApr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux Operations: Utilizing the Maintenance ModeLinux Operations: Utilizing the Maintenance ModeApr 19, 2025 am 12:08 AM

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

Linux: How to Enter Recovery Mode (and Maintenance)Linux: How to Enter Recovery Mode (and Maintenance)Apr 18, 2025 am 12:05 AM

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

Linux's Essential Components: Explained for BeginnersLinux's Essential Components: Explained for BeginnersApr 17, 2025 am 12:08 AM

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

Linux: A Look at Its Fundamental StructureLinux: A Look at Its Fundamental StructureApr 16, 2025 am 12:01 AM

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

Linux Operations: System Administration and MaintenanceLinux Operations: System Administration and MaintenanceApr 15, 2025 am 12:10 AM

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

See all articles

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

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools