Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

LNMP compilation and installation (stable release)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

LNMP represents the web server architecture of Nginx+MySQL+PHP under the Linux system.

Linux is a kind of Unix computer operating system, which is the most popular free operating system at present. Representative versions are: debian, centos, ubuntu, fedora, gentoo and so on.

Nginx is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP proxy server.

Mysql is a small relational database management system.

PHP is a scripting language that embeds HTML documents executed on the server side.

These four kinds of software are all free and open source software, which are combined into a free, efficient and scalable website service system. [1]

System environment:

Suitable for centos6.x x86slave 64-bit operating system

Advantages of source code compilation and installation: 1, customize software functions 2, optimize compilation parameters, improve performance 3, solve unnecessary inter-software dependencies

Download the decompressed source package

Download and extract the 1.mysql compiler-free binary package (5.1.72)

Download and extract the 2.php source package (5.3.27)

Download and extract the 3.nginx source package (1.4.4)

[root@coderblog ~] # wget-cP / usr/local/src http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.72-linux-x86_64-glibc23.tar.gz[root@coderblog ~] # cd / usr/local/src/ & & tar-xzvf mysql-5.1.72-linux-x86_64-glibc23.tar.gz # download and extract the mysql compiler-free binary package [root@coderblog src] # wget-c Http://mirrors.sohu.com/php/php-5.3.27.tar.gz [root@coderblog src] # tar-xzvf php-5.3.27.tar.gz # download and extract the php source package [root@coderblog src] # wget-c [root@coderblog src] # tar-xzvf nginx-1.4.4.tar.gz# download and extract the nginx source package

II. Installation

Installation order mysql > php > nginx

1) mysql installation

[root@coderblog src] # mv mysql-5.1.72-linux-x86_64-glibc23 / usr/local/mysql# move and rename to / usr/local/mysql [root@coderblog src] # useradd-s / sbin/nologin mysql# to establish a mysql account [root@coderblog src] # cd / usr/local/mysql [root@coderblog mysql] # mkdir-p / data/mysql Chown-R mysql:mysql / data/mysql [root@coderblog mysql] #. / scripts/mysql_install_db-- user=mysql-- datadir=/data/mysql# initializes the database

-- user defines the master of the database.-- datadir defines where the database is installed. It is recommended to put it on a partition with large space. This directory needs to be created on its own. This step is critical, if you see two "OK" instructions to execute correctly.

[root@coderblog mysql] # cp support-files/my-large.cnf / etc/my.cnf# copy configuration file [root@coderblog mysql] # cp support-files/mysql.server / etc/init.d/mysqld [root@coderblog mysql] # chmod 755 / etc/init.d/mysqld# copy startup file and grant permission [root@coderblog mysql] # vim / etc/init.d/mysqld# to modify startup configuration file is "datadir=/" Data/mysql "(the directory defined earlier when initializing the database) basedir=/usr/local/mysql [root@coderblog mysql] # chkconfig-- add mysqld # add the startup script to the system service item [root@coderblog mysql] # chkconfig mysqld on # set boot [root@coderblog mysql] # service mysqld start # launch mysql

2) php installation

[root@coderblog ~] # cd / usr/local/src/php-5.3.27 # cut to the directory after decompressing php [root@coderblog php-5.3.27] # useradd-s / sbin/nologin php-fpm # create relevant user [root@coderblog php-5.3.27] # yum install-y epel-release # install epel extension source [root@coderblog php-5.3.27] # yum-y install pcre pcre-devel apr apr-devel zlib-devel Environment for libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libmcrypt-devel gcc libcurl-devel libtool-ltdl-devel libjpeg libjpeg-devel libpng libpng-devel # installation [root@coderblog php-5.3.27] #. / configure\-- prefix=/usr/local/php\-- with-config-file-path=/usr/local/php/etc\-- enable-fpm\-- with-fpm-user=php-fpm\-- with-fpm-group=php-fpm\-- with -mysql=/usr/local/mysql\-- with-mysql-sock=/tmp/mysql.sock\-- with-libxml-dir\-- with-gd\-- with-jpeg-dir\-- with-png-dir\-- with-freetype-dir\-- with-iconv-dir\-- with-zlib-dir\-- with-mcrypt\-- enable-soap\-- enable-gd-native-ttf\-- enable-ftp\-enable-mbstring\-- enable-exif\-- disable -ipv6\-- with-pear\-- with-curl\-- with-openssl\-- enable-sockets# configuration compilation parameters if there is an error message, you can use Baidu's error information. There is usually an answer. [root@coderblog php-5.3.27] # echo $? "check whether the execution is successful or not. [root@coderblog php-5.3.27] # make & & make install [root@coderblog php-5.3.27] # cp php.ini-production / usr/local/php/etc/php.ini [root@coderblog php-5.3.27] # vim / usr/local/php/etc/php-fpm.conf# modify the configuration file # such as Write php- fpm.confu [global] pid = / usr/local/php/var/run/php-fpm.piderror_log = / usr/local/php/var/log/php-fpm.log [www] listen.user=php-fpm listen.group=php-fpmlisten.mode=0666listen = / tmp/php-fcgi.sockuser = php-fpmgroup = php-fpmpm = dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024

After saving the configuration file, the way to verify that the configuration is correct is:

[root@coderblog php-5.3.27] # / usr/local/php/sbin/php-fpm-t

Start php-fpm

[root@coderblog php-5.3.27] # cp / usr/local/src/php-5.3.27/sapi/fpm/init.d.php-fpm / etc/init.d/php-fpm # copy startup file [root@coderblog php-5.3.27] # chmod 755 / etc/init.d/php-fpm # Grant permission [root@coderblog php-5.3.27] # service php-fpm start # start php service

If you want it to boot, execute:

[root@coderblog php-5.3.27] # chkconfig php-fpm on

3) nginx installation

[root@coderblog ~] # cd / usr/local/src/nginx-1.4.4/ # cut to the directory [root@coderblog nginx-1.4.4] # useradd-s / sbin/nologin www # just after decompressing nginx to create relevant users

[root@coderblog nginx-1.4.4] #. / configure\-- prefix=/usr/local/nginx\-- with-http_realip_module\-- with-http_sub_module\-- with-http_gzip_static_module\-- with-http_stub_status_module\-- with-pcre# configuration compilation parameters [root@coderblog nginx-1.4.4] # make & & make install # install [root@coderblog nginx-1.4.4] # vim / etc/init.d/nginx # Custom nginx startup script copies the following to a file and saves #! / bin/bash# chkconfig:-30 2 description: http service.# Source Function Library. / etc/init.d/functions# Nginx SettingsNGINX_SBIN= "/ usr/local/nginx/sbin/nginx" NGINX_CONF= "/ usr/local/nginx/conf/nginx.conf" NGINX_PID= "/ usr/local/nginx/logs/nginx.pid" RETVAL=0prog= "Nginx" start () {echo-n $"Starting $prog:" mkdir-p / dev/shm/nginx_temp daemon $NGINX_SBIN-c $NGINX_CONF RETVAL=$? Echo return $RETVAL} stop () {echo-n $"Stopping $prog:" killproc-p $NGINX_PID $NGINX_SBIN-TERM rm-rf / dev/shm/nginx_temp RETVAL=$? Echo return $RETVAL} reload () {echo-n $"Reloading $prog:" killproc-p $NGINX_PID $NGINX_SBIN-HUP RETVAL=$? Echo return $RETVAL} restart () {stop start} configtest () {$NGINX_SBIN-c $NGINX_CONF-t return 0} case "$1" in start) start;; stop) stop;; reload) reload;; restart) restart;; configtest) configtest *) echo $"Usage: $0 {start | stop | reload | restart | configtest}" RETVAL=1esacexit $RETVAL [root@coderblog nginx-1.4.4] # chmod 755 / etc/init.d/nginx # Grant startup file permission [root@coderblog nginx-1.4.4] # chkconfig-- add nginx # add boot startup item [root@coderblog nginx-1.4.4] # chkconfig nginx on # set boot automatically [root@coderblog nginx-1.4.4] # > / usr/local/nginx/conf/nginx.conf# empty the configuration file [root@coderblog nginx-1.4.4] # vim / usr/local/nginx/conf/nginx.conf# edit the nginx configuration file and copy the following to the file user www www Worker_processes 2 http errorists log / usr/local/nginx/logs/nginx_error.log crit;pid / usr/local/nginx/logs/nginx.pid;worker_rlimit_nofile 51200 leading events {include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 6000;} http {include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 3526; server_names_hash_max_size 4096 Log_format combined_realip'$remote_addr $http_x_forwarded_for [$time_local]'$host "$request_uri" $status''"$http_referer"$http_user_agent"; sendfile on; tcp_nopush on; keepalive_timeout 30; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 8 4k Request_pool_size 4k; output_buffers 4 32k; postpone_output 1460; client_max_body_size 10m; client_body_buffer_size 256k; client_body_temp_path / usr/local/nginx/client_body_temp; proxy_temp_path / usr/local/nginx/proxy_temp; fastcgi_temp_path / usr/local/nginx/fastcgi_temp; fastcgi_intercept_errors on; tcp_nodelay on; gzip on Gzip_min_length 1k; gzip_buffers 48k; gzip_comp_level 5; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/htm application/xml;server {listen 80; server_name localhost; index index.html index.htm index.php; root / usr/local/nginx/html; location ~\. Php$ {include fastcgi_params Fastcgi_pass unix:/tmp/php-fcgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME / usr/local/nginx/html$fastcgi_script_name } [root@coderblog ~] # / usr/local/nginx/sbin/nginx-t nginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful# if shown above, the configuration file is correct [root@coderblog ~] # service nginx start # launch nginx

At this point, the installation of the LNMP environment is complete, and the nginx virtual host is located at: / usr/local/nginx/html/

You can write a phpinfo.php to test php parsing.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report