Centos-6.5 installation and deployment of LNMP environment

Before installation and deployment, make sure that gcc and gcc-c++ are installed

system message:

[ root@zww ~]# cat /etc/redhat-release
CentOS release 6.5(Final)[root@zww ~]# uname -r
2.6.32- 573.22.1. el6.x86_64

**1. Install nginx: **

Install dependent libraries: yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

Download the source package wget from the official website http://nginx.org/download/nginx-1.9.10.tar.gz

Unzip: tar xf nginx-1.9.10.tar.gz

Compile and install, here only install to /usr/local/nginx-1.9, other options can be executed in the source package directory. /configure --help view

. /configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-pcre && make && make install

Error: ./configure: error: SSL modules require the OpenSSL library.
Obviously lack of openssl-devel installation: yum install -y openssl-devel

Add running user and user group:

[ root@zww ~]# useradd -M -s /sbin/nologin www

Modify the nginx configuration file:

[ root@zww ~]# vim /usr/local/nginx/conf/nginx.conf
user www;
worker_processes 2;
error_log /usr/local/nginx/logs/error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;}
 
http {
include mime.types;
default_type application/octet-stream;
# charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
# fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
log_format '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';
log_format access '- $remote_addr - - $time_local "$request" "$http_referer" "$http_user_agent" $body_bytes_sent $http_x_forwarded_for $request_length $status $request_time';
include /usr/local/nginx/conf/vhosts/*.conf;
}

Check the nginx configuration for errors before starting:

[ root@localhost nginx]# /usr/local/nginx/sbin/nginx -t
. /sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

Error: Solution: Add soft link:
ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1  
This problem can be solved on general Linux.
Note: On some operating systems, after installing pcre, the installation location is /usr/local/lib/pcre
There is such a situation on redhat 64-bit machines.
On a redhat 64-bit machine, the pcre file that nginx may read is the /lib64/libpcre.so.1 file.
So add a soft link for 64-bit machines:
 ln -s /usr/local/lib/libpcre.so.1 /lib64/
Check again:

[ root@localhost nginx]# ./sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

Start nginx:
/usr/local/nginx/sbin/nginx -s reload

Error: nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"

solve:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf //nginx -c specifies the location of the configuration file

Set to automatically start nginx at boot:
echo /usr/local/nginx/sbin/nginx >> /etc/rc.d/rc.local
[ root@zhiwenwei nginx]# netstat -tlunp|grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      26752/nginx

**2. Install **mysql

The software cmake is needed to compile and install mysql version 5.5 or higher. The cmake feature is independent of source code compilation. The compilation can be performed in another directory instead of the source code directory. The advantage is that the source code directory is not affected by any one compilation. It is estimated that future versions will also adopt this method, so the installation steps and process are specially recorded for reference

Install dependent software libraries: yum -y install cmake bison ncurses-devel

Create users and user groups and assign data storage directory permissions
useradd -M -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql

Unzip the mysql source package and enter the source package directory to compile and install:

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17.tar.gz

Unzip to compile and install: tar xf mysql-5.7.17.tar.gz
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DMYSQL_DATADIR=/usr/local/mysql/data && make && make install

Error: CMake Error at cmake/boost.cmake:81 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=
Solution: Download the boost library:

Boost library official website: http://www.boost.org

Download the boost library and unzip

wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
tar xf boost_1_59_0.tar.gz

Clear the cache and add -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/opt/boost_1_59_0 to recompile and install:

[ root@zww mysql-5.7.17]#make clean
[ root@zww mysql-5.7.17]#rm -rf CMakeCache.txt
[ root@zww mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1-DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306-DMYSQL_DATADIR=/usr/local/mysql/data -DDOWNLOAD_BOOST=1-DWITH_BOOST=/opt/boost_1_59_0 && make && make install

If an error is reported, please use the above command in addition to the cache
make clean
rm -rf CMakeCache.txt
When starting the MySQL service, it will search for my.cnf in a certain order, first in the /etc directory, and search for "$basedir/my.cnf if it cannot be found. Copy the configuration files under the source package to the etc directory and Renamed to my.conf
cp support-files/my-medium.cnf /etc/my.cnf

Or compile the configuration file yourself:

vim /etc/my.cnf
[ client]
port            =3306
socket          =/tmp/mysql.sock
[ mysqld]
port            =3306
socket          =/tmp/mysql.sock
log-error=/data/log/mysql/error.log
datadir=/data/mysql_data/[safe_mysqld]
err-log =/var/log/mysqld.log
pid-file =/var/lib/mysql/mysqld.pid
[ mysqldump]
quick
max_allowed_packet = 16M

Initialize the database

Initial configuration must be done after installation. Use the mysql_install_db script for initialization.The mysql_install_db of the version before mysql5.7 is under mysql_basedir/script, and the mysql5.7 version is in the bin directory under the mysql installation directory.

initialization:

[ root@zww mysql-5.7.17]# /usr/local/mysql/bin/mysql_install_db --user=mysql  --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

Configure the mysql service script:

cp support-files/mysql.server /etc/init.d/mysql
chmod 755/etc/init.d/mysql
chkconfig mysql on

Or: echo /usr/local/mysql/support-files/mysql.server start >> /etc/rc.d/rc.local
Start the database:
service mysql start
Set the mysql environment variable:

export PATH=$PATH:/usr/local/mysql/bin

Initial password

mysql5.7 will generate an initialization password, and in the previous version, login is not required for the first time.

[ root@zww mysql]# cat /root/.mysql_secret

Password set for user 'root@localhost' at 2017-02-07 16:17:37

set password

[ root@zww mysql]#mysqladmin -h localhost -uroot password '123456'-p'+Bcr6_+TMv?w'
mysqladmin:[Warning] Using a password on the command line interfacecan be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

Login to mysql

[ root@zww ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 5.7.17 Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

  1. php installation

Another article of mine is about php installation records:

http://www.cnblogs.com/wenwei-blog/p/6261637.html

Recommended Posts

Centos-6.5 installation and deployment of LNMP environment
Centos7 installation and deployment of gitlab server
Centos7 installation and deployment of Airflow detailed
CentOS environment installation of Docker
CentOS7 installation and maintenance of Gitlab
CentOs7 installation and deployment Zabbix3.4 original
Erlang 20.2 installation and deployment under CentOS 7
Centos8 minimal deployment and installation of OpenStack Ussuri detailed tutorial
ubuntu Docker installation and deployment of Rancher
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Installation and configuration of redis under centos7
Installation and deployment of Nginx in Ubuntu
Zabbix installation and deployment and localization under CentOS
Jenkins installation and deployment tutorial under CentOS 7
Python and scrapy deployment in centos environment
CentOS6.7 build LNMP environment
Centos7.6 build LNMP environment
lamp (centos7) installation lamp environment
Graphical installation of CentOS8
CentOS 7 build LNMP environment
Installation and configuration of JDK in CentOS 7 system
Centos7 installation of PHP and Nginx tutorial detailed
Installation and configuration of rsync server under CentOS 6.5
Installation and configuration of CentOS 7 in VMware Workstation
Centos6.5 compile and install LNMP architecture web environment
MySQL 8.0 installation and deployment under CentOS, super detailed!
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Installation and use of SSH in Ubuntu environment
Python introduction and environment installation
Installation and cracking of confluence6.3 operation records under Centos
Centos mysql installation and configuration
Installation and cracking of Jira7 operation records under Centos
CentOS 7 installation and configuration PPTP
Deployment of graphite on centos7
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
centos7 kvm installation and use
Installation and simple practice of MySQL in ubuntu environment (1)
Centos7 silent installation of Oracle11g
CentOS7 postgresql installation and use
Environment configuration of JDK, mysql and tomcat under Centos7
Centos7.4 environment installation lamp-php7.0 tutorial
Rapid deployment of Kubernetes (k8s) cluster in CentOS7 environment
Centos7 elk7.1.1 installation and use
Detailed explanation of Spark installation and configuration tutorial under centOS7
CentOS7 installation and maintenance of nginx from entry to master
Deployment of vulnerability scanning and analysis software Nessus under CentOS
Introduction to CentOS7 installation process of openjdk, tomcat and mysql
Analysis of Hyper-V installation CentOS 8 problem
Centos7 installation of Dameng database tutorial
CentOS 8 installation of MariaDB detailed tutorial
Installation under centos6.9 of jenkins learning
Centos7 hadoop cluster installation and configuration
CentOS7 compile and install L(A|N)MP environment
CentOS 7.X system installation and optimization
Java-JDK installation and configuration under CentOS
CentOS 7 Tomcat service installation and configuration
001. Installation of enterprise-level CentOS7.6 operating system
Configure python3 environment on centos7 and
Ubuntu 19.1 installation and configuration Chinese environment