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
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
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>
Another article of mine is about php installation records:
http://www.cnblogs.com/wenwei-blog/p/6261637.html
Recommended Posts