In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to build the LEMP platform", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to build the LEMP platform" this article.
Note: the system I use here is centos6.3 (to avoid the impact, turn off the firewall first)
Mode of operation:
First, compile and install nginx
1. First add the user nginx to run the nginx service process
# groupadd-r-g 108 nginx
# useradd-r-g 108-u 108 nginx
2. Unpack and install the downloaded software package (I am nginx-1.4.7.tar.gz here)
# tar xf nginx-1.4.7.tar.gz
# cd nginx-1.4.7
Then start compiling and installing:
#. / configure\
-- prefix=/usr\
-- sbin-path=/usr/sbin/nginx\
-- conf-path=/etc/nginx/nginx.conf\
-- error-log-path=/var/log/nginx/error.log\
-- http-log-path=/var/log/nginx/access.log\
-- pid-path=/var/run/nginx/nginx.pid\
-- lock-path=/var/lock/nginx.lock\
-- user=nginx\
-- group=nginx\
-- with-http_ssl_module\
-- with-http_flv_module\
-- with-http_stub_status_module\
-- with-http_gzip_static_module\
-- http-client-body-temp-path=/var/tmp/nginx/client/\
-- http-proxy-temp-path=/var/tmp/nginx/proxy/\
-- http-fastcgi-temp-path=/var/tmp/nginx/fcgi/\
-- http-uwsgi-temp-path=/var/tmp/nginx/uwsgi\
-- http-scgi-temp-path=/var/tmp/nginx/scgi\
-- with-pcre\
-- with-file-aio
# make & & make install
When reporting an error, you may be required to install the following package, which can be installed as needed!
# yum-y install pcre-devel
# yum-y install gcc
# yum-y install openssl-devel
3. Provide SysV init script for nginx:
Create a new file / etc/rc.d/init.d/nginx with the following contents:
#! / bin/sh
#
# nginx-this script starts and stops the nginx daemon
#
# chkconfig:-85 15
# description: Nginx is an HTTP (S) server, HTTP (S) reverse\
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: / etc/nginx/nginx.conf
# config: / etc/sysconfig/nginx
# pidfile: / var/run/nginx.pid
# Source function library.
. / etc/rc.d/init.d/functions
# Source networking configuration.
. / etc/sysconfig/network
# Check that networking is up.
["$NETWORKING" = "no"] & & exit 0
Nginx= "/ usr/sbin/nginx"
Prog=$ (basename $nginx)
NGINX_CONF_FILE= "/ etc/nginx/nginx.conf"
[- f / etc/sysconfig/nginx] & &. / etc/sysconfig/nginx
Lockfile=/var/lock/subsys/nginx
Make_dirs () {
# make required directories
User= `nginx-V 2 > & 1 | grep "configure arguments:" | sed's / [^ *] *-- user=\ ([^] *\). * /\ 1Uniple g'- `
Options= `$ nginx-V 2 > & 1 | grep 'configure arguments:' `
For opt in $options; do
If [`echo $opt | grep'. *-temp-path' `]; then
Value= `echo $opt | cut-d "="-f 2`
If [!-d "$value"]; then
# echo "creating" $value
Mkdir-p $value & & chown-R $user $value
Fi
Fi
Done
}
Start () {
[- x $nginx] | | exit 5
[- f $NGINX_CONF_FILE] | | exit 6
Make_dirs
Echo-n $"Starting $prog:"
Daemon $nginx-c $NGINX_CONF_FILE
Retval=$?
Echo
[$retval-eq 0] & & touch $lockfile
Return $retval
}
Stop () {
Echo-n $"Stopping $prog:"
Killproc $prog-QUIT
Retval=$?
Echo
[$retval-eq 0] & & rm-f $lockfile
Return $retval
}
Restart () {
Configtest | | return $?
Stop
Sleep 1
Start
}
Reload () {
Configtest | | return $?
Echo-n $"Reloading $prog:"
Killproc $nginx-HUP
RETVAL=$?
Echo
}
Force_reload () {
Restart
}
Configtest () {
$nginx-t-c $NGINX_CONF_FILE
}
Rh_status () {
Status $prog
}
Rh_status_q () {
Rh_status > / dev/null 2 > & 1
}
Case "$1" in
Start)
Rh_status_q & & exit 0
, 1
Stop)
Rh_status_q | | exit 0
, 1
Restart | configtest)
, 1
Reload)
Rh_status_q | | exit 7
, 1
Force-reload)
Force_reload
Status)
Rh_status
Condrestart | try-restart)
Rh_status_q | | exit 0
*)
Echo $"Usage: $0 {start | stop | status | restart | condrestart | try-restart | reload | force-reload | configtest}"
Exit 2
Esac
4. Then give the script execution permission:
# chmod + x / etc/rc.d/init.d/nginx
5. Add it to the service management list and let it boot automatically:
# chkconfig-add nginx
# chkconfig nginx on
6. Then you can start the service and test:
# service nginx start
Install MySQL (here I install MySQL-5.6.33 (Universal binary format) by compiling)
1. Unpack the downloaded package to / usr/local and enter this directory
# tar xf mysql-5.6.33-linux-glibc2.5-i686.tar.gz-C / usr/local/
# cd / usr/local/
2. Create a link for the unzipped directory and enter it
# ln-sv mysql-5.6.33-linux-glibc2.5-i686 mysql
# cd mysql
3. Create MySQL users (to make them system users) and MySQL groups
# groupadd-r-g 306 mysql
# useradd-g 306-r-u 306 mysql
4. Make all files under mysql belong to mysql users and mysql groups
# chown-R mysql.mysql / usr/local/mysql/*
5. Create a data directory and make it belong to mysql user and mysql group. Others do not have permission.
# mkdir-p / mydata/data
# chown-R mysql:mysql / mydata/data/
# chmod o-rw / mydata/data/
6. When you are ready, start the installation
# scripts/mysql_install_db-user=mysql-datadir=/mydata/data
7. For the sake of security after installation, change the permissions of all files under / usr/local/mysql
# chown-R root.
8. Prepare the startup script and make it boot automatically
# cp support-files/mysql.server / etc/init.d/mysqld
# chkconfig-add mysqld
# chkconfig-list mysqld
9. Edit the database configuration file
# cp support-files/my-default.cnf / etc/my.cnf
# vim / etc/my.cnf, modify and add the following:
Datadir = / mydata/data
Innodb_file_per_table = ON
Log-bin = master-bin
10. Provide the environment variables needed to execute the relevant commands
# vim / etc/profile.d/mysql.sh
Add the following:
Export PATH=$PATH:/usr/local/mysql/bin
11. At this point, the MySQL service configuration is complete, and you can start the test
# systemctl start mysqld
12. Export the library file (because you want to compile for mysql)
# vim / etc/ld.so.conf.d/mysql.conf
Add the following:
/ usr/local/mysql/lib
# ldconfig-v
13. Output header file
# ln-sv / usr/local/mysql/include / usr/include/mysql
3. Compile and install php-5.5.38: (related packages can be downloaded from http://www.php.net/)
1. Prepare before installation:
If a configure:error:xml2-config not found error occurs:
# yum-y install libxml2-devel
If: configure: error: Please reinstall the BZip2 distribution appears
# yum-y install bzip2-devel
If: configure: error: Please reinstall the libcurl distribution-easy.h should be in / include/curl/ appears
# yum-y install curl-devel
2. Download the source package locally and start the installation
# tar xf php-5.5.38.tar.bz2
# cd php-5.5.38
#. / configure-prefix=/usr/local/php-with-mysql=/usr/local/mysql
-with-openssl-- enable-fpm-- enable-sockets-- enable-sysvshm
-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-with-config-file-path=/etc
-with-config-file-scan-dir=/etc/php.d-with-bz2-with-curl
(interpretation:
-- prefix=/usr/local/php specifies the php installation directory
-- with-mysql=/usr/local/mysqlmysql installation directory, support for mysql
-- with-openssl adds support for openssl
-- enable-fpm enables php-fpm
-- enable-sockets opens socket branch
-- with-mysqli=/usr/local/mysql/bin/mysql_configmysqlin extension technology, not only adjustable
Use MySQL stored procedures to deal with MySQL transactions, and can make access to the database stable.
Support for enable-mbstring multibyte strings
-- with-freetype-dir opens support for freetype font library
-- with-jpeg-dir support for pictures in jpeg format
-- with-png-dir opens support for png images
-- with-zlib opens support for zlib libraries
-- with-libxml-dir=/usr opens support for libxml2 libraries
-- enable-xml opens support for xml
-- with-config-file-path=/etc specifies the php.ini (configuration file) location
-- with-config-file-scan-dir=/etc/php.d
Is to search the following ini file php.ini to use together
-- with-bz2 opens support for bz2 files
)
# make
# make install
3. Provide configuration files for php:
# cp php.ini-production / etc/php.ini
4. Provide configuration files for php-fpm:
# cp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.conf
5. Edit the configuration file of php-fpm:
# vim / usr/local/php/etc/php-fpm.conf
Configure the relevant options for fpm to the values you need, and enable the pid file (the last line below):
Pm.max_children = 150
Pm.start_servers = 8
Pm.min_spare_servers = 5
Pm.max_spare_servers = 10
# pid = / usr/local/php/var/run/php-fpm.pid
# cd php-5.5.38
# cp sapi/fpm/init.d.php-fpm / etc/rc.d/init.d/php-fpm
# chmod + x / etc/rc.d/init.d/php-fpm
# chkconfig-add php-fpm
# chkconfig php-fpm on
7. Then you can start php-fpm:
# service php-fpm start
Use the following command to verify (if there are several php-fpm processes in the output of this command, the startup is successful):
# ps aux | grep php-fpm
Fourth, integrate nginx and php
Location ~\ .php$ {
Root html
Fastcgi_pass 127.0.0.1:9000
Fastcgi_index index.php
Fastcgi_param SCRIPT_FILENAME / scripts$fastcgi_script_name
Include fastcgi_params
}
Location / {
Root html
Index index.php index.html index.htm
}
2. Edit / etc/nginx/fastcgi_params and change its content to the following:
Fastcgi_param GATEWAY_INTERFACE CGI/1.1
Fastcgi_param SERVER_SOFTWARE nginx
Fastcgi_param QUERY_STRING $query_string
Fastcgi_param REQUEST_METHOD $request_method
Fastcgi_param CONTENT_TYPE $content_type
Fastcgi_param CONTENT_LENGTH $content_length
Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name
Fastcgi_param SCRIPT_NAME $fastcgi_script_name
Fastcgi_param REQUEST_URI $request_uri
Fastcgi_param DOCUMENT_URI $document_uri
Fastcgi_param DOCUMENT_ROOT $document_root
Fastcgi_param SERVER_PROTOCOL $server_protocol
Fastcgi_param REMOTE_ADDR $remote_addr
Fastcgi_param REMOTE_PORT $remote_port
Fastcgi_param SERVER_ADDR $server_addr
Fastcgi_param SERVER_PORT $server_port
Fastcgi_param SERVER_NAME $server_name
3. Create a test page of index.php in / usr/html to test whether the php is working properly:
Fsy nginx
4. Then reload the configuration file of nginx:
# service nginx reload
Then you can access the test page through the browser!
5. Install xcache to accelerate php:
Xcache: use the same opcode (build) for multiple processes or multiple different processors on the same AppServer
1. Installation
# tar xf xcache-3.1.2.tar.bz2
# cd xcache-3.1.2
# / usr/local/php/bin/phpize
#. / configure-enable-xcache-with-php-config=/usr/local/php/bin/php-config
# make & & make install
At the end of the installation, something like the following line appears:
Installing shared extensions: / usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
2. Edit php.ini and integrate php and xcache:
1) Import the sample configuration provided by xcache into php.ini
# mkdir / etc/php.d
# cp xcache.ini / etc/php.d/
Extension = / usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xcache.so
3. Restart php-fpm to conduct access testing
# service php-fpm restart
At this point, LEMP is installed!
The above is all the contents of the article "how to build the LEMP platform". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.