Prepare an article
1. Configure the firewall, open 80 ports, 3306 ports
1 vim/etc/sysconfig/iptables
2-a input-m State--state new-m tcp-p TCP--dport 80-j ACCEPT #允许80端口通过防火墙
3-a input-m State--state new-m tcp-p TCP--dport 3306-j ACCEPT #允许3306端口通过防火墙
service iptables restart
#重启防火墙 to make the configuration effective
2. Turn off the SELinux(this is related to server security and shut down first.) Related introduction: Https://wiki.centos.org/zh/HowTos/SELinux)
Vim/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
selinux=disabled #增加
: Wq #保存退出
shutdown-r now #重启系统
3. Install third party source
1) Installation of Epel Warehouse
yum install -y epel-release
If the above command does not work:
Centos/rhel 7
RPM-UVH http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
Centos/rhel 6
RPM-UVH http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
2) Installation of IUS warehouse
CentOS 6
RPM-UVH https://centos6.iuscommunity.org/ius-release.rpm
CentOS 7
RPM-UVH https://centos7.iuscommunity.org/ius-release.rpm
Error handling:
1. Error installing IUS warehouse: Curl: (km) SSL connect error. This problem should be present in RHEL 6.1-> RHEL 6.4, because Curl uses the rest API. Solve:
yum update nss
2. As a result, question 1 was not resolved, and another problem: Error:cannot retrieve Metalink for Repository:epel. Please verify its path and try again. Solve:
vim /etc/yum.repos.d/CentOS-Base.repo
Comment out all the mirrorlist, baseurl the annotations, then proceed to step 1, then install the IUS warehouse. Modified as follows:
[Epel] Name=extra Packages for Enterprise Linux 6-$basearch baseurl=http://download.fedoraproject.org/pub/epel/6/$ Basearch #mirrorlist =https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch= $basearch failovermethod= Priority enabled=1 Gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-epel-6 [epel-debuginfo] Name=Extra Packages For Enterprise Linux 6-$basearch-debug baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug # Mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch= $basearch failovermethod= Priority Enabled=0 gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-epel-6 gpgcheck=1 [Epel-source] Name=Extra Packages for Enterprise Linux 6-$basearch-source Baseurl=http://download.fedoraproject.org/pub/epel/6/srpms #mirrorlist =https:/
/mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch= $basearch failovermethod=priority enabled=0
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-epel-6 gpgcheck=1
Check the warehouse list to see if the installation was successful:
yum repolist
IUS | 2.3 kb 00:00
ius/primary_db | 183 kb 00:00
repo id repo name status
base CentOS-6-Base 5,062
epel Extra Packages for Enterprise Linux 6-i386 9,992 CentOS-6-Extras
ius ius Community Packages for Enterprise Linux 6-i386 329
Updates CentOS-6-Updates 382
repolist:15,804
The installation warehouse was successful. Next install nginx,mysql,php.
Installation article
To view the version of the software you are about to install:
yum list nginx mysql php
Results:
[Root@localhost ~]# yum list nginx mysql php
Loaded plugins:fastestmirror, security Loading mirror speeds from
CA Ched Hostfile *
base:mirrors.163.com *
extras:mirrors.163.com *
ius:hkg.mirror.rackspace.com
* updates:mirrors.163.com
Available Packages
mysql.i686 5.1.73-7.el6 base
nginx.i686 1.10.1-1.el6 epel< c12/>php.i686 5.3.3-48.el6_8 Updates
MySQL and PHP versions are old, and they all come from the source of mirrors.163.com. The software versions of Epel and IUS sources are generally relatively new.
Use the following command to list all versions of MySQL and PHP:
yum list mysql* php*
This will list a whole bunch of results like this, so just select the software version you want to install:
Software name software version #软件所在仓库
php56u.i686 5.6.26-1.ius.centos6 ius
mysql55.i686 5.5.52-1.ius.centos6 ius
installation Nginx
Yum Remove httpd* php* #删除系统自带的软件包
yum install nginx #安装nginx installed according to the prompts Chkconfig nginx on
#设置nginx开 Machine Boot
service nginx start #启动nginx
install MySQL
yum remove mysql* #删除系统已经安装的mysql
Yum list mysql*< c16/> #列出mysql所有版本, find the name of the version you want to install
yum install mysql57u* #我安装的是mysql5.7.15. Enter Y to install automatically until the installation completes
service mysqld start #启动MySQL
chkconfig mysqld on #设为开机启动
Installing PHP
Yum install php56u-fpm php56u-mbstring php56u-bcmath php56u-mcrypt php56u-xmlrpc php56u-pdo php56u-xml php56u-xmlrpc Php56u-mysqlnd php56u-gd Php56u-opcache #安装php5.6 and extended
chkconfig php-fpm on #设置php-fpm boot
Service PHP-FPM Start #启动php-fpm
Configuration Chapter
The Nginx configuration file is the nginx.conf under/etc/nginx. On the last line of the nginx.conf file you can see: include/etc/nginx/conf.d/*.conf; It contains all the files in the/ETC/NGINX/CONF.D directory suffix. conf, so just configure a. conf file in the/etc/nginx/conf.d/directory. Here's my configuration:
# The
default server
#
server {
listen ;
server_name n.com;
Root /usr/share/nginx/html;
Index index.php index.html;
# Load configuration files for the ' default server block.
Location/{
try_files $uri $uri//index.php $args;
}
Location ~. *\. (PHP)? $ {
expires-1s;
Try_files $uri =404;
Fastcgi_split_path_info ^ (. +\.php) (/.+) $;
Include Fastcgi_params;
Fastcgi_param path_info $fastcgi _path_info;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_pass 127.0.0.1:9000;
}
Error_page 404/404.html;
Location =/40x.html {
}
error_page 502 503 504/50x.html;
Location =/50x.html {
}
}
Reboot Nginx:
service nginx restart
Create a new index.php in the/usr/share/nginx/html/directory
cd/usr/share/nginx/html #进入html目录
vim index.php #新建index. php, plus phpinfo ();
Browser access: CentOS IP address/index.php. Complete!