Build a LAMP-based Web application platform
Introduction to LAMP
Linux + Apache + Mysql/MariaDB + Perl/PHP/Python is a group of open-source software commonly used to build dynamic websites or servers. They are independent programs, however, because it is often used together, it has a higher degree of compatibility and forms a powerful Web application platform.
LAMP construction process
Installation sequence: httpd --> mysql --> php
Because php compilation and installation depend on the httpd development environment and MySQL development environment, php final installation
I. Prepare the environment
First install development tools and servers
- Yum groupinstall "Development Tools" "Server Platform Development"
- Yum install-y pcre-devel
- Yum install-y gcc
- Yum install openssl
- Yum install openssl-devel
Next, download arp and api-util
: Arp.apache.org
Compile and install:
[Root @ localhost ~] # Tar xf apr-1.5.2.tar.bz2
[Root @ localhost ~] # Cd apr-1.5.2
[Root @ localhost apr-1.5.2] #./configure -- prefix =/usr/local/apr
[Root @ localhost apr-1.5.2] # make & make install
[Root @ localhost ~] # Tar xf apr-util-1.5.4.tar.bz2
[Root @ localhost ~] # Cd apr-util-1.5.4
[Root @ localhost apr-util-1.5.4] #./configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr
[Root @ localhost apr-util-1.5.4] # make & make install
Ii. Install httpd
Installation version: httpd-2.2.31.tar.bz2
: Httpd.apache.org
Installation Process:
1) Installation
Tar xf httpd-2.2.31.tar.bz2
Cd httpd-2.2.31.tar.bz2
[Root @ localhost httpd-2.2.31] #. /configure -- prefix =/usr/local/apache22 -- sysconfdir =/etc/httpd22 -- enable-so -- enable-ssl -- enable-cgi -- enable-rewrite -- with-zlib -- -pcre -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util -- with-modules = most -- enable-mpms-shared = all -- with-mpm = prefork
[Root @ localhost httpd-2.2.31] # make & make install
-- Prefix =/usr/local/apache22: installation path
-Sysconfdir =/etc/httpd22: configuration file path
-- Enable-so: enables the apache core to load DSO
-- Enable-ssl: supports ssl
-- Enable-cgi: cgi supported
-- Enable-rewrite: supports rewriting.
-- With-zlib: supports data compression
-- With-pcre: supports pcre regular expressions.
-- With-apr =/usr/local/apr: apr location
-- With-apr-util =/usr/local/apr-util: apr-util location
-- With-modules = most: More modules are supported.
-- Enable-mpms-shared = all: all modes of mpms are supported.
-- With-mpm = prefork: Set the mpm mode to prefork
2) Configure PATH
[Root @ localhost ~] # Cat/etc/profile. d/httpd22.sh
Export PATH =/usr/local/apache22/bin: $ PATH
3) configure the service script
[Root @ localhost ~] # Cp/etc/rc. d/init. d/httpd/etc/rc. d/init. d/httpd22 # directly copy the script modification from the original system
[Root @ localhost ~] # Cat/etc/rc. d/init. d/httpd22
Prog = httpd
Httpd =$ {HTTPD-/usr/local/apache22/bin/httpd}
Pidfile =$ {PIDFILE-/usr/local/apache22/logs/$ {prog}. pid}
# Pidfile =$ {PIDFILE-/var/run/$ {prog}. pid}
Lockfile =$ {LOCKFILE-/var/lock/subsys/$ {prog }}
RETVAL = 0
Note: the location of the httpd-2.2.31 version's httpd. pid has been changed, so you need to modify the location of the pidfile
Start the service and you will be able to run normally. Check whether the service is normal in the browser. Note that SELinux needs to be disabled to configure iptable for Internet browsing.
3. Install mysql (mariadb)
General binary format install MySQL :(: https://mariadb.org)
Installation Process:
1) create a mysql group and user:
Groupadd-r mysql
Useradd-r-g mysql
2) decompress mysql
Tar xf mariadb-5.5.36-linux-i686.tar.gz-C/usr/local # It must be decompressed here
Cd/usr/local
Ln-sv mariadb-5.5.36-linux-i686 mysql # connection required
3). Create required directories and modify permissions
Cd mysql/
Mkdir mydata # storage location of created data
Pvcreate/dev/sda3
Vgcreate myvb/dev/sda3
Lvcreate-L 10G-m mylv # create logical volume
Mkfs-t ext4/dev/myvg/mylv
Vim/etc/fstab
/Dev/myvg/mylv/mydata xfs defaults # mount the mydata directory to the new logical volume
Mount-
Mount
Mkdir/mydata/data
Chown-R mysql: mysql/mydata/data # modify the user and permission to store the data directory
4) initialize mysql
Scripts/mysql_install_db -- help
Scripts/mysql_install_db -- user = mysql -- datadir =/mydata/data # Set the user to mysql. The data exists in the/mydata/data directory.
5) Verification:
Ls/mydata/data # if a file exists, the file is created successfully.
6). configuration file:
[Root @ localhost mysql] # mkdir/etc/mysql
[Root @ localhost mysql] # cp support-files/my-large.cnf/etc/mysql/my. cnf
[Root @ localhost mysql] # vim/etc/mysql/my. cnf
[Mysqld]
Port = 3306
Socket =/tmp/mysql. sock
Skip-external-locking key_buffer_size = 256 M
Max_allowed_packet = 1 M
Table_open_cache = 256
Sort_buffer_size = 1 M
Read_buffer_size = 1 M
Read_rnd_buffer_size = 4 M
Myisam_sort_buffer_size = 64 M
Thread_cache_size = 8
Query_cache_size = 16 M
# Try number of CPU's * 2 for thread_concurrency
Thread_concurrency = 8
Datadir =/mydata/data
Innodb_file_per_table = on
#
The innodb_file_per_table parameter can be modified to the InnoDB standalone tablespace mode. Each table in each database generates a data space.
# Note: The support-files directory is available in the mysql extract directory, through which you can set most configuration files
Service script:
Cp support-files/mysql. server/etc/rc. d/init. d/mysqld
Chkconfig -- add mysqld
Service mysqld start
Ls/mydata/data
Vim/etc/profile. d/mariadi. sh and bin
Exprot PATH =/usr/local/mysql/bin: $ PATH
Mysql
SHOW DATABASES
So far, mariaDB installation is complete.
Iv. modular installation of php:
Yum install libxml2-devel libmcrypt-devel bzip2-devel
./Configure -- help | less
./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-zlib -- with-libxml-dir =/usr -- enable-xml -- enable-sockets -- with-apxs2 =/usr/local/apache22/bin/apxs
-- With-mcrypt -- with-bz2 -- with-config-file-path =/etc/php. ini
-- With-config-file-scan-dir =/etc/php. d/
You need to automatically create a configuration file:
Mkdir-pv/etc/php. d
Cp php. ini-production/etc/php. ini
Configure the httpd Program
Cd/etc/httpd22/
Vim httpd22
AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps
LoadMoudle php5_module modules/libphp5.so
DirectoryIndex index. php index.html
Configure index.html
<? Php
$ Conn = mysql_cnnect ('127. 0.0.1 ', 'root ','');
If ($ conn)
Echo "success ";
Else
Echo "failure ";
Mysql_close ()
<? Php>
Deployment: phpMyAdmin
Set users for MySQL users:
1. set password for 'username' @ 'host' = PASSWORD ('your _ password ')
2. update mysql. user set password = password ('You _ password') where user = "your user"
Mysql
Use mysql
Upadate user set password = password ('magedu') where user = 'root'
Select User, Host, Password FROM user;
FLUSE PRIVILEGES
Mysql-uroot-p link mysql and log on again
Unzip phpAyAdmin-4.0.5-all-languages.zip
Cd phpAyAdmin-4.0.5-all-languages
Mv */usr/local/apache/htdocs/pma
Cd/usr/local/apache/htdocs/pma
Cp config. sample. inc. php config. inc. php
Install the stress testing tool xcache
/Usr/local/php/bin/phpize
./Configure -- help
./Conifgure -- with-php-config =/usr/local/php/bin/php-config
Make & make install
// There is an extension path at the end of compilation/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/record down
# Cp xcache. ini/etc/php. d/
[Root @ localhost xcache-3.1.2] # cd/etc/php. d
[Root @ localhost php. d] # vim xcache. ini
[Xcache-common]
; Non-Windows example:
Extension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xcache. so # change path
; Windows example:
; Extension = php_xcache.dll
Restart the httpd service and complete the configuration.
You may also like the following LAMP-related content:
Install Xcache and Memcached on the LAMP platform to accelerate website operation
Build a LAMP platform environment in CentOS 7
CentOS 6.5 system installation and configuration LAMP (Apache + PHP5 + MySQL) server environment
Configure the LAMP + phpMyAdmin PHP (5.5.9) development environment in Ubuntu 14.04
Install LAMP in Ubuntu 14.10
LAMP combines NFS to build a small blog site
This article permanently updates the link address: