CentOS 6.3 installation configuration nginx+php+mysql
- 2020-05-10 23:21:46
- OfStack
Ready to post
1. Configure firewall and open ports 80 and 3306
1 vim /etc/sysconfig/iptables
2 -A INPUT-m state --state NEW-m tcp-p tcp --dport 80-j ACCEPT # allows port 80 to pass through the firewall
3-A INPUT-m state --state NEW m tcp tcp --dport 3306-j ACCEPT # allows port 3306 to pass through the firewall
service iptables restart
# restart the firewall for the configuration to take effect
2. Close SELINUX (this is related to server security, so close it first. Related introduction: https: / / wiki centos. org/zh/HowTos/SELinux)
vim /etc/selinux/config
#SELINUX=enforcing # Comment out the
#SELINUXTYPE=targeted # Comment out the
SELINUX=disabled # increase
:wq # Save the exit
shutdown -r now # Restart the system
3. Install the third source
1) install 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) install 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: (35) SSL connect error This problem is found in RHEL 6.1 - > RHEL 6.4 should be present, because curl USES REST API. Solution:
yum update nss
2. Results problem 1 was not solved, but another problem arose: Error: Cannot retrieve for repository: epel Please verify path try again again Solution:
vim /etc/yum.repos.d/CentOS-Base.repo
Comment out all mirrorlist and all baseurl, then proceed to step 1 and install the IUS repository. The changes are 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
extras CentOS-6 - Extras 39
ius IUS Community Packages for Enterprise Linux 6 - i386 329
updates CentOS-6 - Updates 382
repolist: 15,804
The warehouse was installed successfully. Next install nginx,mysql,php.
Install the article
View the version of the software you want to install:
yum list nginx mysql php
Results:
[root@localhost ~]# yum list nginx mysql php
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached 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
php.i686 5.3.3-48.el6_8 updates
The versions of mysql and php are both older, and they both come from the source mirrors.163.com. Versions 1 of the epel and ius sources are relatively new.
List all versions of mysql and php using the following command:
yum list mysql* php*
This will list a bunch of results like this, and then just select the version of the software you want to install:
Software name software version # Software warehouse
php56u.i686 5.6.26-1.ius.centos6 ius
mysql55.i686 5.5.52-1.ius.centos6 ius
The installation nginx
yum remove httpd* php* # Delete the software package that comes with the system
yum install nginx # The installation nginx Enter as prompted y To install
chkconfig nginx on # Set up the nginx Powered up
service nginx start # Start the nginx
The installation MySQL
yum remove mysql* # Delete the system already installed mysql
yum list mysql* # list mysql For all versions, find the name of the version to install
yum install mysql57u* # I installed the mysql5.7.15 . The input Y Automatic installation , Until the installation is complete
service mysqld start # Start the MySQL
chkconfig mysqld on # Set to boot
Install 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 # The installation php5.6 And extension
chkconfig php-fpm on # Set up the php-fpm Powered up
service php-fpm start # Start the php-fpm
Configuration article
The configuration file for nginx is nginx.conf under /etc/nginx. In nginx. conf file at the end of the line 1 can see: include etc/nginx/conf d / *. conf; It/etc nginx/conf d suffix for directory. conf files are included, so as long as in/etc nginx/conf d / 1. The configuration directory conf file. Here is my configuration:
#
# The default server
#
server {
listen 80;
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 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Restart nginx:
service nginx restart
In/usr share/nginx / 1 index html/the new directory. The php
cd /usr/share/nginx/html # Enter the html directory
vim index.php # new index.php , plus phpinfo();
Browser access: centos ip address/index.php. Done!