Installation and Configuration of LAMP

9.1. Combination of PHP and httpd

Common PHP open source software:

  Forum: phpwind, discuz, phpbb

  Blog System: wordpress

  Portal site: drupal, xooms

  Database: phpMyAdmin, Workbench, MySQL Front, Navicat for MySQL, Toad

  CMS (Content Management System) Content Management System: Drupal, joomla

The combination of PHP and httpd:

  Module as a module loads when needed:

  Preork: A request is processed by one process, which consumes more resources in large concurrent scenarios with good stability. A process is created beforehand to maintain an appropriate process on demand. Module block design has a smaller core. Various functions are added (including php) to support running configuration, compiling modules separately, and supporting various virtual host configurations.

  worker: A process has multiple threads, one thread responds to a request

  Event: A thread responds to multiple requests, event-driven, and the main purpose is to achieve a single thread responding to multiple requests.

  Cgi (Common gateway interface): General gateway interface, a communication tool for HTTP servers to communicate with program services on other machines. (CGI programs must run on network servers, and every time HTTP services encounter dynamic programs, they need to start a new parser.)

  Fastcgi, a scalable, high-speed interface for communication between HTTP servers and dynamic scripting languages, has the advantage of separating dynamic languages from HTTP servers. Its main behavior is to keep the CGI interpreter process in memory and thus achieve higher performance. Repeated loading of CGI interpreters is the main reason for CGI's poor performance. If CGI interpreters remain in memory and accept FastCGI process manager scheduling, they can provide good performance, scalability, Fail-Over characteristics and so on.

  LAMP configuration order: httpd - > MySQL - > PHP - > XCache (buffer / optimizer)

  rpm format configuration lamp

# yum -y install httpd php php-mysql mysql-server mysql php-mcrypt

9.2. Compile and install LAMP

Software version:

apacge: httpd-2.4.25.tar.gz

  Dependency packages: apr-1.5.2. tar. gz, apr-util-1.5.4. tar. GZ

mysql: mysql-5.5.55-linux2.6-x86_64.tar.gz

php:  php-5.6.30-src.zip

Relevant software downloads:
#wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.25.tar.gz
#wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz
#wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
#wget http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz
#wget http://cn2.php.net/distributions/php-5.6.30.tar.gz

1. Install apache

[root@mylinux app]# tar xf apr-1.5.2.tar.gz
[root@mylinux app]# cd apr-1.5.2
[root@mylinux apr-1.5.2]## ./configure --prefix=/usr/local/apr
[root@mylinux apr-1.5.2]## make && make install

[root@mylinux app]# tar xf apr-util-1.5.4.tar.gz 
[root@mylinux app]# cd apr-util-1.5.4
[root@mylinux apr-util-1.5.4]./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[root@mylinux apr-util-1.5.4]make && make install

[root@mylinux home]#yum install pcre-devel -y

[root@mylinux app]# tar xf httpd-2.4.25.tar.gz 
[root@mylinux app]# cd httpd-2.4.25
[root@mylinux httpd-2.4.25]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event
[root@mylinux httpd-2.4.25]#make && make install
[root@mylinux httpd24]# vim /etc/httpd24/httpd.conf     #Modify configuration files
   PidFile  "/var/run/httpd.pid"                        #Add the row
   ServerName 127.0.0.1:80                              #Modify service name 
   
#Providing service scripts
[root@mylinux httpd24]# cp /home/app/httpd-2.4.25/build/rpm/httpd.init /etc/rc.d/init.d/httpd
[root@mylinux init.d]# vim /etc/rc.d/init.d/httpd       #Modify relevant parameters
 CONFFILE=/etc/httpd24/httpd.conf
 apachectl=/usr/local/apache/bin/apachectl
 httpd=${HTTPD-/usr/local/apache/bin/httpd}
 pidfile=${PIDFILE-/var/run/${prog}.pid}
 lockfile=${LOCKFILE-/var/lock/subsys/${prog}}
 RETVAL=0
 prog=httpd
 
[root@mylinux init.d]# chmod +x /etc/rc.d/init.d/httpd   #Give execution privileges to this script
[root@mylinux init.d]# chkconfig --add httpd             #Join the Service List
[root@mylinux init.d]# service httpd start               #Start the test
Starting httpd: [  OK  ]

2. Installing MySQL in Universal Binary Format

[root@mylinux app]# tar xf mysql-5.5.55-linux2.6-x86_64.tar.gz 
[root@mylinux app]# ln -sv /home/app/mysql-5.5.55-linux2.6-x86_64 /usr/local/mysql
`/usr/local/mysql' -> `/home/app/mysql-5.5.55-linux2.6-x86_64'
[root@mylinux app]# cd mysql
[root@mylinux mysql]# chown -R root:mysql .
[root@mylinux mysql]# scripts/mysql_install_db --user=mysql          #Initialization
[root@mylinux mysql]# cp support-files/my-large.cnf /etc/my.cnf      #Provide configuration files
[root@mylinux mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld #Service script
[root@mylinux mysql]# service mysqld start                           #Start the test
Starting MySQL.. SUCCESS! 
[root@mylinux profile.d]# vim /etc/mysql.sh                          #Adding environment variables
[root@mylinux profile.d]# source mysql.sh 
[root@mylinux profile.d]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.55-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye
[root@mylinux profile.d]#

3. Installing PHP

# yum -y groupinstall "Desktop Platform Development"    #Resolving dependencies
# yum -y install bzip2-devel libmcrypt-devel
[root@mylinux app]# tar xf php-5.6.30.tar.gz
[root@mylinux app]# cd php-5.6.30
[root@mylinux php-5.6.30]#  ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts
[root@mylinux php-5.6.30]# make
[root@mylinux php-5.6.30]# make test
[root@mylinux php-5.6.30]# make install
[root@mylinux php-5.6.30]# cp php.ini-production  /etc/php.ini   #Provide configuration files

4. Modify apache-related configuration

 # vim /etc/httpd/httpd.conf
   AddType application/x-httpd-php  .php           #Add two lines
   AddType application/x-httpd-php-source  .phps
   ...
   <IfModule dir_module>
    DirectoryIndex  index.php index.html           #Modify the line
   </IfModule>

5. Testing

[root@mylinux php-5.6.30]# service httpd restart
Stopping httpd: [  OK  ]
Starting httpd: [  OK  ]
[root@mylinux htdocs]# vim /usr/local/apache/htdocs/123.php 
<?php
 $link = mysql_connect('127.0.0.1');
 if ($link)
   echo "Success...";
 else
   echo "Failure...";
 mysql_close();
?>
[root@mylinux htdocs]# vim /usr/local/apache/htdocs/index..php
<?php
phpinfo()
?>

Keywords: MySQL PHP Apache vim

Added by fatherlyons on Tue, 25 Jun 2019 00:20:30 +0300