1、安裝yum yum update 2、安裝nginx源: yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm yum repolis ...
1、安裝yum
yum update
2、安裝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
systemctl start nginx
設置開機自啟動
systemctl enable nginx.service
3、檢查開機自啟動是否設置成功
systemctl list-dependencies | grep nginx
4、瀏覽器中輸入公網ip,檢測是否安裝成功
出現如下則成功
5、安裝mysql
安裝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
systemctl mysqld start
檢查mysql啟動是否正常
sytemctl 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;
使用新密碼登錄
6、安裝php
安裝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
安裝php擴展源(這是php7.1的安裝其他版本直接把7.1直接改成7.2)
yum repolist enabled | grep "webtatic*"
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 -m
驗證php是否安裝成功
php -v 會出現php的班本信息
7、配置nginx文件
新建.conf尾碼的文件文件目錄在/etc/nginx/conf.d/下麵 複製下麵內容放進去
server {
listen 80;
server_name danshufenxiang.com;
root /home/www; #自定義站點位置這是你的站點根目錄
index index.php index.html index.htm;
location / {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}