CentOS 7 利用yum安裝lnmp的教程(Linux+Nginx+PHP7.1+Mysql5.7)
關於centos7利用yum安裝lnmp(linux+nginx+php7.1+mysql5.7)的相關資料
步驟如下:
yum的安裝
yum update
yum安裝nginx
安裝nginx最新源
yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum repolist enabled | grep "nginx*"
安裝nginx
yum -y install nginx
啟動nginx
service nginx start
設定nginx伺服器開機自啟動
systemctl enable nginx.service
檢查開機自動是否設定成功
systemctl list-dependencies | grep nginx
瀏覽器中輸入公網ip,檢測是否安裝成功
http://00.00.00.00/
使用yum安裝mysql5.7
安裝mysql源
yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
安裝mysql
yum -y install mysql-community-server install mysql-community-devel
啟動mysql
service mysqld start
檢查mysql啟動是否正常
service mysqld status 或者 ps -ef | grep mysql
設定mysqld服務開機自啟動
systemctl enable mysqld.service
檢查mysqld開機自啟動是否設定成功
systemctl list-dependencies | grep mysqld
mysql5.7以後的爭強了安全機制, 所以使用yum安裝,啟動會系統會自動生成一個隨機的密碼,修改mysql密碼
檢視mysql的隨機密碼
grep 'temporary password' /var/log/mysqld.log
使用查詢得到的隨機密碼在終端登入
mysql -u root -p 更改密碼(mysql文件規定,密碼必須包括大小寫字母數字加特殊符號>8位)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Yourpassword';
退出mysql客戶端,用剛才修改的密碼登入確保密碼修改成功
exit;
mysql -u root -p
安裝php7.1
安裝php源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
檢查源是否安裝成功
yum repolist enabled | grep "webtatic*"
安裝php擴充套件源
yum -y install php71w php71w-fpm
yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt
yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel
yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache
驗證php7.1.x和擴充套件是否安裝成功
驗證php是否安裝成功
php -v
驗證對應的擴充套件是否安裝成功
php -m
設定php-fpm並檢測php-fpm的執行狀態
啟動php-fpm
service php-fpm star
檢查啟動是否成功
service php-fpm status
設定開機自啟動
systemctl enable php-fpm.service
檢查開機自啟動是否設定成功
systemctl list-dependencies | grep php-fpm
ps -ef | grep php-fpm
nginx配置如下:
server{
listen 80;
server_name youserver;
index index.html index.php;
root /home/public;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
}
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 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 /home/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/public$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;
}
}
相關文章
- 基於centos7進行yum安裝lnmp linux+nginx+php7.1+mysql5.7CentOSLNMPLinuxNginxPHPMySql
- centos7使用yum安裝lnmp環境CentOSLNMP
- CentOS 7 安裝 lnmpCentOSLNMP
- CentOS6yum方式安裝lnmpCentOSLNMP
- centos6.2LNMP環境安裝(yum)CentOSLNMP
- CentOS 7 yum 安裝 MySQLCentOSMySql
- CentOS 7 yum 安裝 NGINXCentOSNginx
- Centos 7 yum 安裝nginxCentOSNginx
- centos 7中 yum安裝jdkCentOSJDK
- CentOS 7 用yum安裝 MySQLCentOSMySql
- Centos7 yum安裝 DockerCentOSDocker
- CentOS 7 yum 安裝 PHP7.3CentOSPHP
- CentOS 7 yum 安裝與配置 JDKCentOSJDK
- CentOS 7 yum 安裝與配置 RedisCentOSRedis
- centos7 yum 安裝mariadbCentOS
- centos7下編譯安裝lnmpCentOS編譯LNMP
- CentOS7 安裝 Mysql 8:0 的yum安裝方式CentOSMySql
- CentOS 7 yum安裝與配置 TomcatCentOSTomcat
- centos7通過yum安裝nginxCentOSNginx
- CentOS7下yum安裝MySQL 5.7CentOSMySql
- CentOS7 yum安裝MySQL5.7CentOSMySql
- centos7中使用yum安裝NGINX安裝CentOSNginx
- CentOS7 快速高效,簡單安裝 lnmpCentOSLNMP
- centos7 解除安裝和重新安裝yumCentOS
- centos7安裝mysql5.7 使用yumCentOSMySql
- Linux – CentOS 7 yum方式快速安裝MongoDBLinuxCentOSMongoDB
- 在CentOS7中,使用yum安裝NginxCentOSNginx
- centos7中使用yum安裝OpenJDKCentOSJDK
- centos7搭建lnmp編譯安裝php【一】CentOSLNMP編譯PHP
- centos7搭建lnmp編譯安裝nginx【二】CentOSLNMP編譯Nginx
- CentOS安裝配置yumCentOS
- CentOS yum安裝mcryptCentOS
- CentOS 7安裝 hping教程CentOS
- centos7 docker 安裝教程CentOSDocker
- CentOS 7 安裝 Elasticsearch 6.4.2 教程CentOSElasticsearch
- Centos 安裝yum,安裝ansibleCentOS
- centos7透過yum安裝JDK1.8CentOSJDK
- CentOS7 透過YUM安裝MySQL5.7CentOSMySql