安裝并配置MySQL 5.6
從CentOS從7.x開始默認(rèn)使用MariaDB。MariaDB完全兼容MySQL,包括API和命令行。但是很多時(shí)候我們還是會(huì)想要安裝MySQL,所以不能直接通過yum命令安裝。
下載源安裝文件
wget http://repo.//mysql57-community-release-el7-8.noarch.rpm
本地安裝rpm包(配置MySQL安裝源)
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
查看所有MySQL安裝源(默認(rèn)MySQL安裝版本5.7)
yum repolist all | grep mysql
關(guān)閉MySQL 5.7安裝源
sudo yum-config-manager --disable mysql57-community
開啟MySQL 5.6安裝源
sudo yum-config-manager --enable mysql56-community
沒有yum-config-manager 命令可以安裝yum install yum-utils.noarch 工具
或者編輯/etc/yum.repos.d/mysql-community.repo 文件enable項(xiàng)為1表示開啟,為0表示關(guān)閉
安裝MySQL
yum -y install mysql-devel mysql-community-server
啟動(dòng)MySQL
systemctl start mysqld.service
安全配置MySQL
mysql_secure_installation
安裝并配置PHP 5.6
CentOS 7.1版本中,默認(rèn)安裝PHP為PHP5.4版本,其中php-mysqlnd是PHP源碼提供的MYSQL驅(qū)動(dòng)數(shù)據(jù)庫。
很多時(shí)候會(huì)對PHP環(huán)境要求校新的版本,例如PHP5.6環(huán)境,記錄一種通過yum工具安裝最新PHP版本的方法。首先,需要在系統(tǒng)上安裝一個(gè)擴(kuò)展yum源,即epel源。可從http:///wiki/EPEL 網(wǎng)站下載并安裝。(注意:如果文章時(shí)間久,就可能需要去重新找新的下載鏈接。)
下載源安裝文件
wget https://dl./pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
本地安裝(和上面MySQL安裝源命令類似)
rpm -ivh epel-release-7-8.noarch.rpm
接著,還需要一個(gè)REMI源,這個(gè)yum源提供了最新的PHP版本的下載和安裝,它的官網(wǎng)http://rpms./ 。安裝REMI源的過程如下。
導(dǎo)入gpg校驗(yàn)文件
rpm --import http://rpms./RPM-GPG-KEY-remi
下載源安裝文件
wget https://mirrors.tuna./remi/enterprise/remi-release-7.rpm
本地安裝
rpm -Uvh remi-release-7.rpm
默認(rèn)情況下,REMI是禁用的,防止多個(gè)yum源發(fā)生沖突。可以通過命令查看REMI源是否成功安裝
yum repolist disabled | grep remi
通過REMI源安裝需要的PHP版本,安裝PHP5.6版本。
yum --enablerepo=remi-php56 install php
安裝php-fpm
yum --enablerepo=remi-php56 install php-fpm
開啟php-fpm
systemctl start php-fpm
安裝并配置Nginx
導(dǎo)入gpg校驗(yàn)文件
rpm --import http://rpms./RPM-GPG-KEY-remi
下載源安裝文件(配置Nginx安裝源)。可從http:///packages/centos/ 網(wǎng)站下載安裝源。(注意:如果文章時(shí)間久,就可能需要去重新找新的下載鏈接。)
wget http:///packages/centos/7/x86_64/RPMS/nginx-1.10.0-1.el7.ngx.x86_64.rpm.或者h(yuǎn)ttp://www.
本地安裝
rpm -Uvh nginx-1.10.0-1.el7.ngx.x86_64.rpm
安裝Nginx
yum install nginx
開啟Nginx
systemctl start nginx
Nginx主機(jī)配置(設(shè)置php-fpm)
編輯/etc/nginx/conf.d/default.conf 配置文件,并重啟。
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
root /usr/share/nginx/html;
index index.html index.htm index.php;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
|