CentOS 7配置LNMP開發(fā)環(huán)境及配置文件管理詳解
安裝并配置MySQL 5.6
從CentOS從7.x開始默認使用MariaDB。MariaDB完全兼容MySQL,包括API和命令行。但是很多時候我們還是會想要安裝MySQL,所以不能直接通過yum命令安裝。
下載源安裝文件
wget http://repo.mysql.com//mysql57-community-release-el7-8.noarch.rpm
本地安裝rpm包(配置MySQL安裝源)
yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
查看所有MySQL安裝源(默認MySQL安裝版本5.7)
yum repolist all | grep mysql
關閉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項為1表示開啟,為0表示關閉
安裝MySQL
yum -y install mysql-devel mysql-community-server
啟動MySQL
systemctl start mysqld.service
安全配置MySQL
mysql_secure_installation
安裝并配置PHP 5.6
CentOS 7.1版本中,默認安裝PHP為PHP5.4版本,其中php-mysqlnd是PHP源碼提供的MYSQL驅動數(shù)據(jù)庫。
很多時候會對PHP環(huán)境要求校新的版本,例如PHP5.6環(huán)境,記錄一種通過yum工具安裝最新PHP版本的方法。首先,需要在系統(tǒng)上安裝一個擴展yum源,即epel源??蓮?a rel="nofollow" >http://fedoraproject.org/wiki/EPEL網(wǎng)站下載并安裝。(注意:如果文章時間久,就可能需要去重新找新的下載鏈接。)
下載源安裝文件
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
本地安裝(和上面MySQL安裝源命令類似)
rpm -ivh epel-release-7-8.noarch.rpm
接著,還需要一個REMI源,這個yum源提供了最新的PHP版本的下載和安裝,它的官網(wǎng)http://rpms.famillecollet.com/。安裝REMI源的過程如下。
導入gpg校驗文件
rpm --import http://rpms.remirepo.net/RPM-GPG-KEY-remi
下載源安裝文件
wget https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm
本地安裝
rpm -Uvh remi-release-7.rpm
默認情況下,REMI是禁用的,防止多個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
導入gpg校驗文件
rpm --import http://rpms.remirepo.net/RPM-GPG-KEY-remi
下載源安裝文件(配置Nginx安裝源)。可從http://nginx.org/packages/centos/網(wǎng)站下載安裝源。(注意:如果文章時間久,就可能需要去重新找新的下載鏈接。)
wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.10.0-1.el7.ngx.x86_64.rpm
本地安裝
rpm -Uvh nginx-1.10.0-1.el7.ngx.x86_64.rpm
安裝Nginx
yum install nginx
開啟Nginx
systemctl start nginx
Nginx主機配置(設置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; #} }
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
Linux云服務器安裝JDK和Tomcat的詳細步驟(推薦)
這篇文章主要介紹了Linux云服務器安裝JDK和Tomcat的詳細步驟,本文分步驟給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-12-12Linux系統(tǒng)中CPU占用率較高問題排查思路與解決方法
這篇文章主要給大家介紹了關于Linux系統(tǒng)中CPU占用率較高問題排查思路與解決方法,文中通過示例代碼介紹的非常詳細,對大家學習或者使用Linux具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-07-07