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

Discuz Forum based on lnmp

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

Share

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

-LNMP + Discuz-

System environment: RHEL6 x32 selinux and iptables disabled

Host role: 172.25.46.1 nginx+mysql+php+Discuz

Mysql installation

Package dependencies:

Yum install-y gcc gcc-c++make ncurses-devel bison openssl-devel zlib-devel cmake

Decompress:

Tar zxf mysql-5.5.12.tar.gz

Cd mysql-5.5.12

Compile:

Cmake-DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql\ # installation directory

-DMYSQL_DATADIR=/usr/local/lnmp/mysql/data\ # Database storage directory

-DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock\ # Unix socket file path

-DWITH_MYISAM_STORAGE_ENGINE=1\ # install the Myisam storage engine

-DWITH_INNOBASE_STORAGE_ENGINE=1\ # install the Innodb storage engine

-DDEFAULT_CHARSET=utf8\ # use Utf8 characters

-DDEFAULT_COLLATION=utf8_general_ci\ # check character

-DEXTRA_CHARSETS=all # install all extended character sets

Installation:

Make & & makeinstall

Note: if there is an error in this step, clear the old object files and cache information, and recompile (first make clean, then rm-f CmakeCache.txt, and then start compilation)

Go to / root/, to add environment variables:

Vi .bash _ profile

PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin

To make the changes effective:

Source .bash _ profile

Look at the environment variable you just added:

Which mysql

/ usr/local/lnmp/mysql/bin/mysql

To create a mysql user:

Groupadd-g 27 mysql

Useradd-u 27-g 27-s/sbin/nologin-d / usr/local/lnmp/mysql/-M mysql

Initialize the database:

Cd / usr/local/lnmp/mysql/

Scripts/mysql_install_db--user=mysql-basedir=/usr/local/lnmp/mysql

-- datadir=/usr/local/lnmp/mysql/data

Displaying 2 ok indicates that the installation is successful

Change permissions:

Chown root. -R

Chgrp mysql. -R

Chown mysql data/-R

Copy the configuration file and startup script to the specified location:

Cpsupport-files/my-medium.cnf / etc/my.cnf

Cpsupport-files/mysql.server / etc/init.d/mysqld

Start the mysql service:

/ etc/init.d/mysqld start

Install mysql:

Mysql_secure_installation

Enter current password for root (enter for none):

Change the root password? [YPIO] n # enter the password of the current root if it has a database, but do not press enter

... Skipping.

Remove anonymous users? [YPop] y # remove anonymous users

... Success!

Disallow root login remotely? [YPop] y # does not allow root to log in remotely

... Success!

Remove test database and access to it? [YPop] y # remove test database

Reload privilege tables now? [Yzone] y # reload database permissions

... Success!

Log in to mysql to verify:

Mysql

Welcome to the MySQL monitor. Commands end with; or\ g.

.

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

| | test |

+-+

5 rows in set (0.04 sec)

Nginx installation

Install the development package:

Yum install-y pcre-devel openssl-devel

Extract the source package and edit the file to hide the nginx version:

Tar zxvf nginx-1.8.0.tar.gz

Cd nginx-1.8.0

Vim auto/cc/gcc

# CFLAGS= "$CFLAGS-g" # comment out this line, get rid of debug mode compilation, the program only has a few hundred k after compilation

Vim src/core/nginx.h

# define NGINX_VERSION "1.8.0"

# defineNGINX_VER "nginx" # modify this line to remove the following "NGINX_VERSION". For security, the version number of nginx cannot be obtained after compilation.

Compile and install:

. / configure-- prefix=/usr/local/lnmp/nginx-- with-http_ssl_module-- with-http_stub_status_module

Make & & makeinstall

Links are easy to call and modify:

Cd/usr/local/lnmp/nginx/sbin

Ln-s/usr/local/lnmp/nginx/sbin/nginx / usr/local/sbin

Check syntax, open nginx service, and load configuration file:

Nginx-t

Nginx

Nginx-s reload

Check to see if port 80 is open and detect (make sure the httpd service is turned off at this point):

Netstat-antlp

Tcp 0 0 0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0 of the LISTEN 7060/nginx.

Curl-I localhost

HTTP/1.1 200 OK

Server: nginx/1.8.0

Date: Wed, 13 Jan 2016 08:42:21 GMT

Content-Type: text/html

Content-Length: 612

Last-Modified: Wed, 13 Jan 2016 08:31:20 GMT

Connection: keep-alive

ETag: "56960b58-264"

Accept-Ranges: bytes

At this point, you can access it using a browser. What I visited in the experiment is: 172.25.46.1, which shows the following page:

Change the number of users and processes:

Cd / usr/local/lnmp/nginx/conf/

Vi nginx.conf

# user nginx; # change user to nginx

Worker_processes 2; # the number of processes changed to 2

Reload the file and view the port:

Nginx-s reload

Netstat-antlp

Tcp 0 0 0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0 of the LISTEN 7060/nginx.

Two processes have been started:

Ps-ax

7104? S 0:00 nginx: worker process

7105? S 0:00 nginx: worker process

Generate key:

Cd / etc/pki/tls/certs/

Make nginx.pem

Country Name (2 letter code) [XX]: CN # country, uppercase

State or Province Name (full name) []: Shanxi # province

Locality Name (eg, city) [Default City]: xi'an # city

Organization Name (eg, company) [Default CompanyLtd]: westos # Organization name

Organizational Unit Name (eg, section) []: Linux # organizational Unit

Common Name (eg, your name or your server's hostname) []: server1.example.com # hostname

Email Address []: 742019722@qq.com # mailbox

Add key to the profile:

Mv nginx.pem/usr/local/lnmp/nginx/conf/

Cd/usr/local/lnmp/nginx/conf/

Vim nginx.conf

Http {

.

# HTTPS server

#

Server {

Listen 443 ssl

Server_name localhost

Ssl_certificate nginx.pem; # change here

Ssl_certificate_key nginx.pem; # change here

Ssl_session_cache shared:SSL:1m

Ssl_session_timeout 5m

Ssl_ciphers HIGH:!aNULL:!MD5

Ssl_prefer_server_ciphers on

Location/ {

Root html

Index index.html index.htm

}

}

}

Reload file view port:

Nginx-s reload

Netstat-antlp

Tcp 0 0 0.0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 14. 0. 0. 0. 0. 0. 0. 0

At this point, you can access it using a browser. In the experiment, I visited: the https://172.25.46.1, display page is as follows

Select I Understand the Risks and go to the following page:

Php installation

Installation package dependencies:

Yum install-y pcre-devel openssl-devel libxml2-devel curl-devel libjpeg-turbo-devel.x86_64 libpng-devel gpm.h mcrypt.hnet-snmp-devel freetype-devel gmp-devel-* libjpeg-*

Extract the source package and compile and install:

Tar jxf php-5.4.36.tar.bz2

Cd php-5.4.36

. / configure-- prefix=/usr/local/lnmp/php--with-config-file-path=/usr/local/lnmp/php/etc--with-mysql=/usr/local/lnmp/mysql/--with-mysqli=/usr/local/lnmp/mysql/bin/mysql_config-- with-openssl-- with-snmp-- with-gd--with-zlib-- with-curl-- with-libxml-dir-- with-png-dir-- with-jpeg-dir-- with-freetype-dir- -without-pear--with-gettext-with-gmp-- enable-inline-optimization-- enable-soap--enable-ftp-- enable-sockets-- enable-mbstring-- enable-fpm-with-fpm-user=nginx--with-fpm-group=nginx-- with-mhash

Make & & make install

Copy the configuration file and startup script to the specified location:

Cpphp.ini-production / usr/local/lnmp/php/etc/php.ini

Cd sapi/fpm

Cp init.d.php-fpm / etc/init.d/fpm

Chmod + x / etc/init.d/fpm

Edit the php-fpm.conf file to open php and run pid

Cd / usr/local/lnmp/php/etc/

Cp php-fpm.conf.default php-fpm.conf

Vim php-fpm.conf

.

[global]

; Pid file

; Note: the default prefix is/usr/local/lnmp/php/var

; Default Value: none

Pid = run/php-fpm.pid # Open php and run pid

.

Change the time zone to Asia, Shanghai:

Vim php.ini

.

[Date]

; Defines the default timezone used by thedate functions

; http://php.net/date.timezone

; date.timezone=Asia/Shanghai

There may be an error when you start the php service:

/ etc/init.d/fpm start

Starting php-fpm [14-Jan-2016 15:52:53] ERROR: [pool www] cannot get uid for user 'nginx'

[14-Jan-2016 15:52:53] ERROR: FPMinitialization failed

Delete users and groups with an id of 48 (because the default id for apache is also 48, so there will be conflicts), and create a new nginx user:

Groupadd-g 48 nginx

Useradd-u 48murg 48-s / sbin/nologin-d / usr/local/lnmp/nginx/-M nginx

Id nginx

Uid=48 (nginx) gid=48 (nginx) groups=48 (nginx)

Start the php service again and you can succeed:

/ etc/init.d/fpm start

Starting php-fpm done

/ etc/init.d/fpmreload

Reload service php-fpm done

Write a php test page:

Cd / usr/local/lnmp/nginx/html

Vim index.php

Detect syntax and overload:

Nginx-t

Nginx-s reload

Add cgi support php:

The vim / usr/local/lnmp/nginx/conf/nginx.conf # line number is roughly as follows, not necessarily exactly the same as yours

48 location / {

49 root html

50 index index.php index.htmlindex.htm; # add index.php as the home page

51}

.

70 location ~\ .php$ {

71 root html

72 fastcgi_pass 127.0.0.1:9000

73 fastcgi_index index.php

74 # fastcgi_param SCRIPT_FILENAME / scripts$fastcgi_script_name; # comment this line

75 include fastcgi.conf; # change the file suffix to .conf

76}

Check Syntax View Port:

Nginx-t

Nginx-s reload

Netstat-antlp

Tcp 0 0 0.0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 14. 0. 0. 0. 0. 0. 0. 0

Tcp 0 0 0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0 of the LISTEN 1354/nginx.

At this point, you can access it using a browser. What I visited in the experiment is 172.25.46.1, and the page is shown as follows:

Discuz Forum based on lnmp

Unzip the package to the release directory of nginx:

Yum install-y unzip

Unzip Discuz_X2.5_SC_UTF8.zip-d / usr/local/lnmp/nginx/html/

Rename the upload directory to bbs for easy access:

Mv / usr/local/lnmp/nginx/html/upload / usr/local/lnmp/nginx/html/bbs

At this point, you can access it using a browser. In the experiment, I visited 172.25.46.1/bbs, and the display page is as follows:

Select I agree to go to the next step, set up the running environment:

You need to change the directory and file permissions when you see that the current status of the directory file is unwritable:

Cd / usr/local/lnmp/nginx/html/bbs

Chmod 777 config/-R

Chmod 777 data/-R

Chmod 777 data/ uc_server/-R

Chmod 777 data/ uc_client/-R

At this time, the update is displayed as writable, and you can go to the next step to create the database:

Set the root user password and create a database discuz before filling in the information

Mysql_secure_installation

Enter current password for root (enter fornone): # enter, because I didn't set the root password at the beginning

OK, successfully used password, movingon...

Set root password? [Y/n] y

New password: # enter password

Re-enter new password: # confirm password

Password updated successfully!

Remove anonymous users? [Y/n] y

... Success!

Disallow root login remotely? [Y/n] y

... Success!

Remove test database and access to it? [Y/n] y

-Dropping test database...

Reload privilege tables now? [Y/n] y

... Success!

Mysql-p + password

Mysql > create database discuz

Query OK, 1 row affected (0.00 sec)

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | discuz |

| | mysql |

| | performance_schema |

| | test |

+-+

5 rows in set (0.00 sec)

After you have set the above information, you can create a database. The page is as follows:

After filling in the information, go to the next step, and the forum interface is as follows:

So far, we have completed the construction of the Discuz forum based on lnmp!

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

Wechat

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

12
Report