You can use the rpm package and compile the lamp server in two ways: A & gt; the rpm package is relatively simple # yum-yinstallmysql-servermysql-develhttpdhttpd-develphpphp-develphp-mysql #/etc/init. d/mysqlstart #/etc/init. d/httpdstart # chkconfigmysqlon # chkconfigh
To set up a lamp server, you can use the rpm package and compile the following two methods:
A> the rpm package is relatively simple.
# Yum-y install mysql-server mysql-devel httpd-devel php-mysql
#/Etc/init. d/mysql start
#/Etc/init. d/httpd start
# Chkconfig mysql on
# Chkconfig httpd on
B> compilation and installation is a little complicated, but you can better understand the underlying structure. Let's take a look at the compilation and installation methods!
Compilation and installation sequence
1. lamp linux-mysql-apache-php
2. lnmp linux-mysql-php-nginx
1> compile installation mysql-5.5.12
# Yum-y install cmake gcc-c ++ ncurses-devel bison openssl-devel zlib-devel
Common options include the following:
Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
# Installation directory
-DMYSQL_DATADIR =/usr/local/mysql/data \
# Database storage directory
-DMYSQL_UNIX_ADDR =/usr/local/mysql/data/mysql. sock \
# Unix socket file path
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
# Install the myisam storage engine
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
# Installing the innodb Storage Engine
-DWITH_ARCHIVE_STORAGE_ENGINE = 1 \
# Installing the archive storage engine
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1 \
# Installing the blackhole storage engine
-DWITH_PARTITION_STORAGE_ENGINE = 1 \
# Install database partitions
-DENABLED_LOCAL_INFILE = 1 \
# Allow Local Data Import
-DWITH_READLINE = 1 \
# Shortcut key
-DWITH_SSL = yes \
# SSL support
-DDEFAULT_CHARSET = utf8 \
# Use utf8 characters
-DDEFAULT_COLLATION = utf8_general_ci \
# Verification characters
-DEXTRA_CHARSETS = all \
# Install all extended character sets
-DMYSQL_TCP_PORT = 3306 \
# MySQL listening port
# Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/usr/local/mysql/data-DMYSQL_UNIX_ADDR =/usr/local/mysql/data/mysql. sock-DWITH_MYISAM_STORAGE_ENGINE = 1-DWITH_PARTITION_STORAGE_ENGINE = 1-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DMYSQL_TCP_PORT = 3306
# Make & make install
Ps:
Required for recompilation
# Make clean
# Rm-f CMakeCache.txt
# Useradd-M-s/sbin/nologin mysql
# Chown-R mysql. mysql/usr/local/mysql/
# Cd/usr/local/mysql/
# Cp support-files/my-medium.cnf/etc/my. cnf
# Scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data
This error occurs: latin1_swedish_ci 'is not valid for character set 'utf8' because the DDEFAULT_COLLATION = utf8_general_ci option is not added during compilation.
# Chown-R root.
# Chown-R mysql data/
# Cp support-files/mysql. server/etc/init. d/mysqld
# Ll/etc/init. d/mysqld // check whether the x permission exists
-Rwxr-xr-x. 1 root 10650 Sep 21 :41/etc/init. d/mysqld
# Chkconfig mysqld on
#/Etc/init. d/mysqld start
Starting MySQL... SUCCESS!
# Echo "export PATH =\$ PATH:/usr/local/mysql/bin" >> ~ /. Bash_profile
# Source ~ /. Bash_profile
# Mysql_secure_installation // you can directly start mysql initialization. Here mysql compilation is complete.
2> compile and install php-5.3.6
# Tar xf libmcrypt-2.5.8.tar.bz2
# Cd libmcrypt-2.5.8
#./Configure-libdir =/usr/local/lib64
# Make & make install
# Cd libltdl/
#./Configure-libdir =/usr/local/lib64/-enable-ltdl-install & make install
# Yum-y install net-snmp-devel curl-devel libxml2-devel libpng-devel libjpeg-devel freetype-devel gmp-devel
# Useradd-M-s/sbin/nologin www
# Tar xf php-5.3.6.tar.bz2
# Cd php-5.3.6
# Ln-s/usr/local/mysql/lib/usr/local/mysql/lib64 // otherwise the mysql library file cannot be found during php Compilation
#. /Configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc -- with-mysql =/usr/local/mysql/ -- with-openssl -- with-snmp -- with-gd -- with-zlib -- with-curl -- with-libxml-dir -- with-png-dir -- with-jpeg-dir -- -freetype-dir -- with-pear -- with-gettext -- with-gmp -- with-mcrypt -- enable-optimization -- enable-soap -- enable-ftp -- enable-sockets -- enable-mbstring -- with-mysqli =/usr/local/mysql/bin/mysql_config -- enable-fpm -- with-fpm-user = www -- with-fpm-group = www -- with-libdir = lib64
# Make & make install
# Cp php. ini-production/usr/local/php/etc/php. ini
# Cp/mnt/php-5.3.6/sapi/fpm/init. d. php-fpm/etc/init. d/php-fpm
# Vi/usr/local/php/etc/php. ini
Cgi. fix_pathinfo = 0 // row 842
# Cd/usr/local/php/etc
# Cp php-fpm.conf.default php-fpm.conf
Pid = run/php-fpm.pid
Pm. max_children = 50
Pm. start_servers = 10
Pm. min_spare_servers = 5
Pm. max_spare_servers = 15
Pm. max_requests = 500
#/Etc/init. d/php-fpm start // start the service
# Chkconfig php-fpm on
Now php is complete!
3> compile and install nginx-1.0.2
# Yum install-y pcre-devel
# Tar-xf nginx-1.0.2.tar.gz
# Vim auto/cc/gcc
# CFLAGS = "$ CFLAGS-g" comment out the 175 lines and remove the debug mode
# Vim src/core/nginx. h
# Define NGINX_VERSION "1.0.2"
# Define NGINX_VER "nginx" (modify this line and remove the "NGINX_VERSION" next to it. To ensure security, the version of the program cannot be obtained after compilation)
#./Configure -- user = www -- group = www -- prefix =/usr/local/nginx -- with-http_stub_status_module -- with-http_ssl_module
# Make & make install
# Ln-s/usr/local/nginx/sbin/nginx/usr/sbin
# Vim/usr/local/nginx/conf/nginx. conf // valid information in my configuration file
User www;
Worker_processes 8;
Events {
Use epoll;
Worker_connections 65535;
}
Http {
Include mime. types;
Default_type application/octet-stream;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 65;
Server {
Listen 80;
Server_name localhost;
Location /{
Root html;
Index index.html index.htm I index. php;
}
Error_page 500 502 503 x.html;
Location =/50x.html {
Root html;
}
Location ~ \. Php $ {
Root html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Include fastcgi. conf;
}
Location/status {
Stub_status on;
Access_log off;
}
Location/phpmyadmin {
Root html;
Index. php;
} // The lines here are just for publishing a phpmyadmin for convenient management.
}
}
# Tar xf phpMyAdmin-3.4.2-all-languages.tar.bz2-C/usr/loca/nginx/html
# Phpmyadmin mv phpMyAdmin-3.4.2-all-languages
# Nginx-t // check the configuration file
Nginx: the configuration file/usr/local/nginx/conf/nginx. conf syntax is OK
Nginx: configuration file/usr/local/nginx/conf/nginx. conf test is successful
# Nginx // start the service
You can create an index. php file under/usr/local/nginx/html. The content is as follows:
- <?Php
- Phpinfo();
- ?>
Now you can access our background management interface:
Enter the mysql management account and password! Do you still remember the password set by executing mysql_secure_installation!
Close the work!