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

Using Enterprise LNMP Environment to implement Wordpress Chinese site

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Operating system: CentOS release 6.8 (Final)

Web server software: Nginx-1.6.3.tar.gz

Database system: MySQL 5.5.52

PHP version: php 5.3.3

Site program: wordpress-4.7.4-zh_CN.tar.gz

Task: use a single server and two servers to implement the LNMP architecture.

Attachment: all configurations are provided.

Check the lib libraries required to install Nginx

[root@Cacti~] # rpm-qa pcre pcre-devel

[root@Cacti~] # yum install pcre pcre-devel-y

[root@Cacti~] # yum install openssl openssl-devel-y

Start installing Nginx

[root@Cactitools] # wget http://nginx.org/download/nginx-1.6.3.tar.gz

[root@Cactitools] # ls-l nginx-1.6.3.tar.gz

[root@Cactitools] # useradd nginx-s / sbin/nologin-M

[root@Cactitools] # tar xf nginx-1.6.3.tar.gz

[root@Cactitools] # cd nginx-1.6.3

[root@Cactinginx-1.6.3] #. / configure\

-- user=nginx\

-- group=nignx\

-- prefix=/application/nginx\

-- with-http_stub_status_module\

-- with-http_ssl_module

[root@Cactinginx-1.6.3] # make

[root@Cactinginx-1.6.3] # make install

Start and check the installation results:

Check the configuration file syntax before startup:

[root@Cactinginx-1.6.3] # / application/nginx/sbin/nginx-t

Nginx: theconfiguration file / application/nginx/conf/nginx.conf syntax is ok

Nginx: [emerg] getgrnam ("nignx") failed

Nginx:configuration file / application/nginx/conf/nginx.conf test failed

[root@Cactilogs] # cat error.log

2017Accord07According to 1216 nignx 15VR 07 [emerg] 17992mm 0: getgrnam ("nignx") failed

[root@Cacticonf] # vi nginx.conf

# user nobody; # remove the first # to solve the startup error

Nginx: option "- s" requires parameter

[root@Cacticonf] # / application/nginx/sbin/nginx-t # check syntax

Nginx: theconfiguration file / application/nginx/conf/nginx.conf syntax is ok

Nginx:configuration file / application/nginx/conf/nginx.conf test is successful

[root@Cacticonf] # / application/nginx/sbin/nginx # start the Nginx service

Nginx: [emerg] bind () to 0.0.0.0 to 80 failed (98: Address already in use) # Port conflict exists

# the reason is that both Apache and Nginx are port 80 by default

The port corresponding to the [root@Cacticonf] # lsof-iRanger 80 # Nginx service conflicts

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

Httpd 1451 root 4U IPv6 10731 0t0 TCP *: http (LISTEN)

Httpd 1496 apache 4U IPv6 10731 0t0 TCP *: http (LISTEN)

Httpd 1497 apache 4U IPv6 10731 0t0 TCP *: http (LISTEN)

Httpd 1498 apache 4U IPv6 10731 0t0 TCP *: http (LISTEN)

Httpd 1499 apache 4U IPv6 10731 0t0 TCP *: http (LISTEN)

Httpd 1500 apache 4U IPv6 10731 0t0 TCP *: http (LISTEN)

Httpd 1501 apache 4U IPv6 10731 0t0 TCP *: http (LISTEN)

Httpd 1502 apache 4U IPv6 10731 0t0 TCP *: http (LISTEN)

Httpd 1503 apache 4U IPv6 10731 0t0 TCP *: http (LISTEN)

# modify the default port of nginx to port 8080

Server {

Listen 8080

Server_name localhost

# charset koi8-r

# access_log logs/host.access.log main

Location / {

Root html

Index index.html index.htm

}

[root@Cacticonf] # pkill nginx # kill the process to restart the Nginx service

[root@Cacticonf] # / application/nginx/sbin/nginx

[root@Cacticonf] # lsof-iRanger 8080 # Nginx service port started successfully

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

Nginx 17530 root 6u IPv4 3271777 0t0 TCP *: webcache (LISTEN)

Nginx 17531nobody 6u IPv4 3271777 0t0 TCP *: webcache (LISTEN)

[root@Cacticonf] # netstat-lnt | grep 80

Tcp 0 0 0.0.0.0 8080 0.0.0.015 * LISTEN

Tcp 0 0: 36780: * LISTEN

Tcp 0 0: 80: * LISTEN

[root@Cacticonf] # ps-ef | grep nginx

Root 3000 15790 0 16:22 pts/0 00:00:00 / application/nginx/sbin/nginx

Root 6336 15790 0 16:36 pts/0 00:00:00 grep nginx

Root 17530 1 0 16:28? 00:00:00 nginx: master process/application/nginx/sbin/nginx

Nobody 17531 17530 0 16:28? 00:00:00 nginx:worker process

Root 31232 15790 0 16:20 pts/0 00:00:00 / application/nginx/sbin/nginx

Check the actual effect of Nginx startup:

[root@Cacticonf] # wget 127.0.0.1 index.html 8080 # View the local index.html file

[root@Cacticonf] # curl 127.0.0.1 8080 # output effects directly on the screen

Welcometo nginx!

Body {

Width: 35em

Margin: 0 auto

Font-family: Tahoma, Verdana, Arial,sans-serif

}

Welcometo nginx!

Ifyou see this page, the nginx web server is successfully installed and

Working.Further configuration is required.

Foronline documentation and support please refer to

Nginx.org.

Commercialsupport is available at

Nginx.com.

Thankyou for using nginx.

[root@Cacticonf] #.. / sbin/nginx-V

Nginxversion: nginx/1.6.3

Built by gcc4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)

Check the lib libraries required to install php

# yum instal zlib-devel libxml2-devel libjped-devel libjpeg-turbo-devel libiconv-devel-y

# yum instal lfreetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel-y

# yum install libmcrypt-devel

# yum install mhash

# yum install mcrypt-y

[root@Cactitools] # wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

[root@Cactitools] # tar zxf libiconv-1.14.tar.gz

[root@Cactilibiconv-1.14] #. / configure-prefix=/usr/local/libiconv

[root@Cactilibiconv-1.14] # make & & make install

Start installing php

[root@Cacti~] # mkdir / home/tools-p

[root@Cactitools] # wget http://mirrors.sohu.com/php/php-5.3.27.tar.gz

[root@Cacti tools] # tar zxf php-5.3.27.tar.gz

[root@Cactitools] # cd php-5.3.27

[root@Cactiphp-5.3.27] #. / configure\

-- prefix=/application/php5.3.27\

-- with-mysql=/application/mysql\

-- with-iconv-dir=/usr/local/libiconv\

-- with-freetype-dir\

-- with-jpeg-dir\

-- with-png-dir\

-- with-zlib\

-- with-libxml-dir=/usr\

-- enable-xml\

-- disable-rpath\

-- enable-fpm\

-- with-fpm-user=nginx\

-- with-fpm-group=nginx\

-- enable-bcmath\

-- enable-shmop\

-- enable-sysvsem\

-- enable-inline-optimization\

-- with-curl\

-- with-curlwrappers\

-- enable-mbregex\

-- with-mcrypt\

-- with-gd\

-- enable-gd-native-ttf\

-- with-openssl\

-- with-mhash\

-- enable-pcntl\

-- enable-sockets\

-- with-xmlrpc\

-- enable-zip\

-- enable-soap\

-- enable-short-tags\

-- enable-zend-multibyte\

-- enable-static\

-- with-xsl\

-- enable-safe-mode\

-- enable-ftp

……

Checking forCygwin environment... No

Checking formingw32 environment... No

Checking foregrep... Grep-E

Checking fora sed that does not truncate output... / bin/sed

Checking hostsystem type... Config.sub: missing argument

Try`config.sub-help' for more information.

Checkingtarget system type... Config.sub: missing argument

Try`config.sub-help' for more information.

Checking forgcc... No

Checking forcc... No

Configure:error: no acceptable cc found in $PATH

To solve the above problems:

# yum install-y gcc-c++

[root@Cactiphp-5.3.27] #. / configure\ # recompile

-- prefix=/application/php5.3.27\

-- with-mysql=/application/mysql\

-- with-iconv-dir=/usr/local/libiconv\

-- with-freetype-dir\

-- with-jpeg-dir\

-- with-png-dir\

-- with-zlib\

-- with-libxml-dir=/usr\

-- enable-xml\

-- disable-rpath\

-- enable-fpm\

-- with-fpm-user=nginx\

-- with-fpm-group=nginx\

-- enable-bcmath\

-- enable-shmop\

-- enable-sysvsem\

-- enable-inline-optimization\

-- with-curl\

-- with-curlwrappers\

-- enable-mbregex\

-with-mcryp t\

-- with-gd\

-- enable-gd-native-ttf\

-- with-openssl\

-- with-mhash\

-- enable-pcntl\

-- enable-sockets\

-- with-xmlrpc\

-- enable-zip\

-- enable-soap\

-- enable-short-tags\

-- enable-zend-multibyte\

-- enable-static\

-- with-xsl\

-- enable-safe-mode\

-- enable-ftp

# problems after reconfiguration:

Configure:error: Cannot find MySQL header files under / application/mysql.

Note that theMySQL client library is not bundled anymore!

# No matter how to change the path of the database, it is still compiled and passed

The solution is:

# mkdir / usr/lib/msyql-p

# cp / usr/lib64/mysql/* / usr/lib/mysql/

Then proceed to. / configure. If the server does not have a / usr/lib/mysql/ directory, create a mysql directory under the / usr/lib/ directory.

+-- +

| | License: |

| | Thissoftware is subject to the PHP License, available in this |

| distribution in the file LICENSE. Bycontinuing this installation |

| process,you are bound by the terms of this license agreement. | |

| | If you donot agree with the terms of this license, you must abort |

| theinstallation process at this point. | |

+-- +

Thank you forusing PHP.

[root@Cactiphp-5.3.27] # make # compilation

[root@Cactiphp-5.3.27] # make install # installation

/ home/tools/php-5.3.27/build/shtoolinstall-c ext/phar/phar.phar / application/php5.3.27/bin

Ln-s-f/application/php5.3.27/bin/phar.phar / application/php5.3.27/bin/phar

InstallingPDO headers: / application/php5.3.27/include/php/ext/pdo/

[root@Cactiphp-5.3.27] # ln-s/application/php5.3.27/ / application/php # set soft link

[root@Cactiphp-5.3.27] # ls-l / application/php

Lrwxrwxrwx 1root root 23 Jul 12 17:14 / application/php-> / application/php5.3.27/

[root@Cactiphp-5.3.27] # cp php.ini-production / application/php/lib/php.ini # copy the configuration file of php to the PHP default directory

When compiling and installing PHP on linux, why is the file php-fpm.conf.default not found in the php/etc/ directory?

Answer: the reason is that some of the code was not executed when the copy configuration file was executed.

Note: no error is reported when a large block of code is executed, but configuration statements that are not executed will be redisplayed.

[root@Cactiphp-5.3.27] # cd / application/php/etc/ # configuration file php-fpm.confs

[root@Cactietc] # ll

Total 28

-rw-r--r-- 1root root 1232 Jul 12 17:41 pear.conf

-rw-r--r-- 1root root 21683 Jul 12 17:41 php-fpm.conf.default

[root@Cactietc] # cp php-fpm.conf.default php-fpm.conf

Start the PHP service php-fpm:

[root@Cactietc] # / application/php/sbin/php-fpm

Check the process of the php service php-fpm and the startup port:

[root@Cactietc] # ps-ef | grep php-fpm

Root 23321 1 0 17:43? 00:00:00 php-fpm: master process (/ application/php5.3.27/etc/php-fpm.conf)

Nginx 23322 23321 0 17:43? 00:00:00 php-fpm:pool www

Nginx 23323 23321 0 17:43? 00:00:00 php-fpm:pool www

Root 23325 15790 0 17:43 pts/0 00:00:00 grep php-fpm

[root@Cactietc] # lsof-I: 9000

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

Php-fpm23321 root 7u IPv4 3871264 0t0 TCP localhost:cslistener (LISTEN)

Php-fpm 23322nginx 0u IPv4 3871264 0t0 TCP localhost:cslistener (LISTEN)

Php-fpm 23323nginx 0u IPv4 3871264 0t0 TCP localhost:cslistener (LISTEN)

Configure Nginx to support PHP program request access

# vi nginx.conf # modify configuration file

Location~.*. (php | php5)? ${

Root html

Fastcgi_pass 127.0.0.1:9000

Fastcgi_index index.php

Include fastcgi.conf

}

# check and start Nginx

[root@Cacticonf] #.. / sbin/nginx-t

Nginx: theconfiguration file / application/nginx/conf/nginx.conf syntax is ok

Nginx:configuration file / application/nginx/conf/nginx.conf test is successful

[root@Cacticonf] #.. / sbin/nginx-s reload

To test if the LNMP environment is in effect:

[root@Cactihtml] # echo "" > test_info.php

[root@Cactihtml] # cat test_info.php

Test how PHP connects to MySQL:

[root@Cactihtml] # vi test_mysql.php

Deploy a wordpress program service below:

1. First create a dedicated database WordPress

[root@Cactihtml] # mysql-uroot-p

Mysql > create database wordpress

Query OK, 1row affected (0.00 sec)

Mysql > show databases like 'wordpress'

+-+

| | Database (wordpress) |

+-+

| | wordpress |

+-+

1 row in set (0.00 sec)

Nginx and PHP environment configuration preparation:

Location / {

Root html

Index index.php index.html index.htm

}

Location. *\. (php | php5)? ${

Root html

Fastcgi_pass 127.0.0.1:9000

Fastcgi_index index.php

Include fastcgi.conf

}

[root@Cactihtml] # wget https://tw.wordpress.org/wordpress-4.8-zh_TW.tar.gz

[root@Cactihtml] # tar xf wordpress-4.8-zh_TW.tar.gz

[root@Cactihtml] # mkdir blog

[root@Cactihtml] # mv wordpress blog/

[root@Cactihtml] # chown-R nginx.nginx blog

Test situation: the browser displays Filenot found.

Answer: the reason is that the program can not be parsed, and the construction can be placed directly under the html directory to avoid the problem of not finding the program.

[root@Cactiwordpress] # cp wp-config-sample.php wp-config.php

[root@Cactiwordpress] # vi wp-config.php # configure database name, user name and password

Configuration was successful.

The above is through a server architecture LNMP

It is also very simple to set up LNMP through two servers:

.8 server: do the Nginx server, put the wordpress in the html directory of nginx, and configure the wp-config.php file.

/ * * name of WordPress database * /

Define ('DB_NAME',' wordpress')

/ * * MySQL database user name * /

Define ('DB_USER',' * *)

/ * * MySQL database password * /

Define ('DB_PASSWORD',' *')

/ * * MySQL host * /

Define ('DB_HOST',' .9 server IP')

.9 server: do Mysql server and create wordpress database.

Tip: nginx and php-fpm services are required to start automatically every time the server is restarted.

# vi / etc/rc.local # add two commands to the silent tail

/ application/nginx/sbin/nginx

/ application/php/sbin/php-fpm

Running result: http://117.40.239.8:8080/wordpress

Attachment: http://down.51cto.com/data/2366842

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

Servers

Wechat

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

12
Report