In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
LAMP platform should be the most widely used web server architecture at present, but with the increasing use of Nginx in enterprises, LNMP (or LEMP) architecture is favored by more and more Linux system engineers, in which "E" comes from the pronunciation of Nginx [engine x].
Build LNMP website platform
The construction of LNMP platform requires Linux server, Nginx server, MySQL database and PHP parsing environment. The specific method is similar to that of LAMP. The construction method of Nginx server has been introduced in the previous blog. Here, build the LNMP platform based on the installed Nginx server.
1. Install the MySQL database
The installation method of MySQL database has been discussed before, but the configuration command will not be explained.
[root@localhost] # yum-y install ncurses-devel [root@localhost] # tar zxf cmake-2.8.12.tar.gz [root@localhost] # cd cmake-2.8.12 [root@localhost cmake-2.8.12] #. / configure & & gmake & & gmake install [root@localhost cmake-2.8.12] # cd ~ [root@localhost ~] # tar zxf mysql-5.5.38.tar.gz [root@localhost ~] # cd mysql-5. 5.38 [root@localhost mysql-5.5.38] # cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all-DSYSCONFDIR=/etc/ [root@localhost mysql-5.5.38] # make & & make install [root@localhost mysql-5.5.38] # cp support-files/my-medium.cnf / etc/my.cnf cp: is "/ etc/my.cnf" overwritten? Y [root@localhost mysql-5.5.38] # cp support-files/mysql.server / etc/init.d/mysqld [root@localhost mysql-5.5.38] # chmod + x / etc/init.d/mysqld [root@localhost mysql-5.5.38] # chkconfig-- add mysqld [root@localhost mysql-5.5.38] # echo "PATH=$PATH:/usr/local/mysql/bin" > > / etc/profile [root@localhost mysql-5.5.38] # / etc/profile [root@localhost mysql-5.5.38] # groupadd mysql [root@localhost mysql-5.5.38] # useradd-M-s / sbin/nologin mysql- g mysql [root@localhost mysql-5.5.38] # chown-R mysql:mysql / usr/local/mysql [root@localhost mysql-5.5.38] # / usr/local/mysql/scripts/mysql_install_db-- basedir=/usr/local/mysql/-- datadir=/usr/local/mysql/data /-- user=mysql [root@localhost mysql-5.5.38] # service mysqld startStarting MySQL.. [OK] [root@localhost mysql-5.5.38] # mysqladmin-u root password 123456
two。 Install the PHP parsing environment
Add FPM module to manage PHP parsing instances and optimize parsing efficiency
[root@localhost ~] # yum-y install gd libxml2-devel libjpeg-devel libpng-devel [root@localhost ~] # tar zxf php-5.3.28.tar.gz [root@localhost ~] # cd php-5.3.28/ [root@localhost php-5.3.28] #. / configure-prefix=/usr/local/php5-with-gd-with-zlib-with-mysql=/usr/local/mysql-with-config-file-path=/usr/local/php5- -enable-mbstring-enable-fpm-with-jpeg-dir=/usr/lib [root@localhost php-5.3.28] # make & & make install [root@localhost php-5.3.28] # cp php.ini-development / usr/local/php5/php.ini [root@localhost php-5.3.28] # ln-s / usr/local/php5/bin/* / usr/local/bin/ [root@localhost php-5.3.28] # ln-s / usr/ Local/php5/sbin/* / usr/local/sbin/ [root@localhost ~] # tar zxf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz [root@localhost ~] # cd ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ [root@localhost php-5.3.x] # cp ZendGuardLoader.so / usr/local/php5/lib/php/ [root@localhost php-5.3.x] # vim / usr/ Local/php5/php.ini zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.sozend_loader.enable=1
3. Configure Nginx to support PHP environment
There are two ways to enable Nginx to parse PHP web pages:
Method 1: act as an intermediary and transfer the Web requests for accessing PHP pages to other servers (LAMP), so as to achieve the separation of static pages by Nginx and dynamic pages by LAMP.
Method 2: call the native PHP environment by using the FPM module of PHP
1. For the first method, you need to configure Nginx
[root@localhost] # vim / usr/local/nginx/conf/nginx.confserver {. Location ~\ .php$ {proxy_pass http://192.168.1.100; / / Apache server listening address}}
Second, this blog adopts the second way, and the configuration method is as follows:
(1) enable the php-fpm process
[root@localhost ~] # cd / usr/local/php5/etc/ [root@localhost etc] # cp php-fpm.conf.default php-fpm.conf [root@localhost etc] # useradd-M-s / sbin/nologin php [root@localhost etc] # vim php-fpm.confpid = run/php-fpm.pid / / confirm the pid file location user = php group = phppm.start_servers = 20 / / number of processes started at startup pm.min_spare_servers = 5 / / minimum number of idle processes pm.max_spare_servers = 35pm.max_children = 50 / / maximum number of idle processes [root@localhost etc] # / usr/local/sbin/php-fpm / / start the php-fpm process [root@localhost etc] # netstat-anpt | grep php-fpmtcp 0 127.0 .0.1 etc/init.d/nginx 9000 0.0.0.0 vim * LISTEN 123330/php-fpm [root@localhost etc] # vim / add the following So that the php-fpm program starts or closes PROG_FPM= "/ usr/local/sbin/php-fpm" PIDF_FPM= "/ usr/local/php5/var/run/php-fpm.pid" case "$1" instart) netstat-anpt with the control of Nginx | grep "php-fpm" & > dev/null & & pgrep "php-fpm" & > / dev/nullif [$?-eq 0] Thenecho "php-fpm is running" else$PROG_FPMfi;;stop) netstat-anpt | grep "php-fpm" & > dev/null & & pgrep "php-fpm" & > / dev/nullif [$?-eq 0]; thenkillall-s QUIT php-fpmecho "php-fpm is down" fi;;esac
(2) configure Nginx to support PHP resolution
[root@localhost ~] # vim / usr/local/nginx/conf/nginx.confserver {/ / find the following file and remove #. Location ~\ .php$ {root / var/www/ysf; / / PHP webpage document root directory fastcgi_pass 127.0.0.1 var/www/ysf; 9000; / / the listening address fastcgi_index index.php; / / PHP homepage file include fastcgi_params of php-fpm / / including fastcgi_params sample configuration}} [root@localhost ~] # service nginx restart / / restart the service to take effect
(3) PHP page access test
[root@localhost ~] # vim / var/www/ysf/test.php / / create a test web page
First create a test file and access it in the browser to test whether the PHP is parsed properly and whether you can access the MySQL database
Deploy Web applications in LNMP platform
The LNMP platform is very similar to the LAMP platform, but the main difference lies in the use of Web services software, which has little to do with Web applications developed using PHP. The following takes "Sky Network Movie system" as an example to introduce the deployment process on the LNMP platform.
Sky online Movie system (SKYUC) is a PHP video-on-demand system, which supports a variety of P2P streaming software and has a wide range of applications. Its official website address is http://www.skyuc.com/.
1. Download and adjust the program code
[root@localhost ~] # yum-y install unzip [root@localhost ~] # unzip SKYUC.v3.4.2.SOURCE.zip / / extract the downloaded SKYUC file [root@localhost ~] # mv SKYUC.v3.4.2.SOURCE/wwwroot / var/www/ysf/skyuc/ / move wwwroot to the root directory of the website [root@localhost ~] # cd / var/www/ysf/skyuc/ / / adjust relevant permissions [root@localhost skyuc] # chown-R php:php admincp/ data/ templates/ upload/ [root@localhost skyuc] # mysql-u root-p Enter password:... / / create a new skyuc dedicated database and authorized users to reduce the risk of the database mysql > create database skyucdb; Query OK, 1 row affected (0.00 sec) mysql > grant all on skyucdb.* to ysf@localhost identified by "123456"; Query OK, 0 rows affected (0.00 sec)
two。 Install the Web application
3. Access to Web application system
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.