Nginx install the required environment
Nginx is a C language development, it is recommended to run on Linux, of course, you can also install the Windows version herein, this is used as CentOS 7 installation environment.
A GCC - GNU Compiler Collection (GCC can use the default package manager warehouse (repositories) to install, select the package manager is dependent on the Linux distribution you use, the package manager has different implementations: yum is based on Red Hat releases; apt for Debian and Ubuntu; yast for SuSE Linux, etc.).
yum install gcc
Two. PCRE pcre-devel installed
PCRE (Perl Compatible Regular Expressions) is a Perl library, including perl-compatible regular expression library. The module uses nginx http pcre regular expressions to parse, so it is necessary to install pcre library on linux, pcre-devel pcre developed using a secondary development library. nginx also need this library. command:
yum install -y pcre pcre-devel
Three. Zlib install
zlib library provides a variety of compression and decompression of the way, nginx using zlib the contents of the package are http gzip, so you need to install on Centos zlib library.
yum install -y zlib zlib-devel
Four. OpenSSL installed
OpenSSL is a powerful Secure Sockets Layer cryptographic libraries include major cryptographic algorithms commonly used key and certificate management and SSL protocol encapsulation, and provides a wealth of applications for testing or other purposes.
nginx not only supports the http protocol, also supports https (http over ssl ie transmission protocol), so you need to install the OpenSSL library in Centos.
yum install -y openssl openssl-devel
Official website to download
1. Direct download .tar.gz installation package, address: HTTPS: // HTTP: //nginx.org/en/download.html
2. Use wget command to download (recommended).
wget -c https://nginx.org/download/nginx-1.16.0.tar.gz
I downloaded version is nginx-1.16.0.tar.gz
Decompression
It is still the direct command:
It recommended to download to / usr / local / src Road King, the compiler source code
tar -zxvf nginx-1.15.0.tar.gz
cd nginx-1.15.0
Configuration
Use the default configuration - translation parameters
./configure
Compile and install
make
make install
Finding the installation path:
whereis nginx
Start, stop nginx
cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload
./nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。
./nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
Nginx query process:
ps aux|grep nginx
重启 nginx
Nginx configuration file comments:
[root@localhost conf]# vim nginx.conf
worker_processes 1; #worker进程的数量
events { #事件块的开始
worker_connections 1024; #每个worker进程支持的最大连接数
} #事件块的结束
http { #HTTP区块的开始
include mime.types; #Nginx支持媒体类型库文件
default_type application/octet-stream; #默认的媒体类型
sendfile on; #开启高速传输模式
keepalive_timeout 65; #连接超时
server { #第一个server区块的开始
listen 80; #提供服务的端口,默认为80
server_name www.nautilus.org ; #提供服务的域名主机
location / { #第一个location区块的开始
root html/www; #站点的根目录,相当于Nginx的安装目录
index index.html index.htm; #默认的首页文件,多个使用空格隔开
} #第一个location区块的结束
error_page 500 502 503 504 /50x.html; #出现对应的http状态码是,使用50x.html回应客户
location = /50x.html { #location区块的开始,访问50x.html
root html; #指定对应的站点目录为html
}
}
} #HTTP区块的结束
Steps
[root@localhost nginx]# ls
client_body_temp fastcgi_temp logs sbin uwsgi_temp
conf html proxy_temp scgi_temp
[root@localhost nginx]# cd html
[root@localhost html]#
[root@localhost html]# mkdir www
[root@localhost html]#
[root@localhost html]# cd www
[root@localhost www]# ls
index.html
[root@localhost www]# vim index.html
hello localhost
[root@localhost nginx]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.31.1.32 www.nautilus.org
1. First stop and start (recommended):
for nginx restart the equivalent of stop and then start, which is to execute a stop command and then execute the command to start. as follows:
./nginx -s quit
./nginx
2. reload the configuration file:
After modifying the configuration file nginx.conf ngin x, to want a profile take effect need to restart nginx, use -s reload without first stopping ngin x nginx restart to take effect in nginx configuration information, the as follows:
./nginx -s reload
After a successful start, the browser can see this page:
mysql
msyql is an open source relational database system, very fast, reliable, scalable and easy to use.
Installation:
1. Source Installation
2. Binary files are installed
3.yum installation or custom installation rpm
download link:
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz
Installation required
yum -y install cmake bison git ncurses-devel gcc gcc-c++
groupadd mysql
useradd -g mysql mysql
Decompression
tar zxvf mysql-5.6.38.tar.gz
mkdir /usr/local/mysql
mkdir /usr/local/mysql/data
cd mysql-5.6.22/
Configuring the Compile Options
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DENABLE_DOWNLOADS=1
Compile and install
make
make install
Modify the directory owner permissions
chown -R mysql:mysql /usr/local/mysql/data/
chown -R mysql:mysql /usr/local/mysql/
Database initialization
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/mysql --pid-file=/usr/local/mysql/data/mysql/mysql.pid --tmpdir=/tmp
chown -R mysql:mysql my.cnf
vim my.cnf
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = .....
server_id = .....
socket = /usr/local/mysql/mysql.sock
log-error= /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
cd /usr/local/mysql/support-files
mysql start
./mysql.server start
cd /usr/local/mysql/bin
./mysql -u root -p
php installation
Download PHP source package
wget http://cn2.php.net/distributions/php-5.6.0.tar.xz
Decompression
xz -d php-5.6.0.tar.xz
tar xf php-5.6.0.tar -C /usr/local/src/
Installation required
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel
yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel bz2-devel
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install libmcrypt-devel mhash mcrypt
创建 www 用户
groupadd www
useradd -g www -s /sbin/nologin -M www
Compile and install
cd /usr/local/src/php-5.6.0/
./configure \
--prefix=/usr/local/php56 \
--with-config-file-path=/usr/local/php56/etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-readline\
--with-gd
make
make install
cd /usr/local/src/php-5.6源码包
Profiles:
cp php.ini-development /usr/local/php56/etc/php.ini
php-fpm Service
cp /usr/local/php56/etc/php-fpm.conf.default /usr/local/php56/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm56 (php-fpm的可执行文件)
chmod +x /etc/init.d/php-fpm56
Start php-fpm (nginx and php communication)
service php-fpm56 start
Starting php-fpm done
php-fpm 可用参数 start|stop|force-quit|restart|reload|status
PHP commands to add environment variables
to edit / etc / profile, will:
PATH=$PATH:$HOME/bin
Read:
PATH=$PATH:$HOME/bin:/usr/local/php56/bin
The PHP environment variables to take effect:
source /etc/profile
Check to see PHP version
php -v
PHP 5.6.0(cli)(built:Sep23201403:44:18)Copyright(c)1997-2014The PHP GroupZendEngine v2.6.0,Copyright(c)1998-2014ZendTechnologies