一、換源
備份原來的源
sudo cp /etc/apt/sources.list /etc/apt/sources_init.list
更換源
sudo gedit /etc/apt/sources.list
阿里源 (Ubuntu 18.04)
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
更新
sudo apt-get update
復損壞的軟體包,嘗試卸載出錯的包,重新安裝正確版本的,
sudo apt-get -f install
更新軟體
sudo apt-get upgrade
二、安裝PHP
洗掉php的相關包及配置
sudo apt-get autoremove php7*
可以通過 apt list | grep php7 命令查看是否有php7.2的包,ubuntu16.04默認是有7.0的,
當然,一如既往,首先更新Ubuntu:
apt-get update && apt-get upgrade
添加PHP存盤庫
sudo apt-get install software-properties-common
接下來,從Ond?ej添加PHP存盤庫:
add-apt-repository ppa:ondrej/php
最后,更新安裝包:
sudo apt-get update
安裝PHP 7.2
sudo apt-get install php7.2
nginx使用php需要安裝php7.2-fpm, 和一些php插件
sudo apt-get install php7.2-mysql php7.2-fpm php7.2-curl php7.2-xml php7.2-gd php7.2-bcmath php7.2-mbstring php-memcached php7.2-zip
php -v

上述安裝php命令會自動安裝apache2服務,可以通過 service apache2 status 查看
sudo service apache2 stop
sudo apt remove apache2*
sudo apt autoremove
開啟php報錯
找到php.ini
locate php.ini
添加
display_errors=On
三、安裝Nginx
apt install nginx
service nginx status #查看狀態

配置php-fpm
有時候安裝完成后不知道安裝到什么地方啦可以使用下面命令查找下
whereis php-fpm
我的在這里
php-fpm: /usr/sbin/php-fpm7.2
修改nginx配置/etc/nginx/sites-available/default (這個地方是默認的組態檔,也可以加在其他地方)
sudo vi /etc/nginx/sites-available/default
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
最終組態檔:
在這里插入代碼片
配置nginx
修改站點根目錄訪問權限
sudo chmod -R 777 /var/www/html/

四、安裝msyql(win資料庫服務器)
卸載原有mysql :
net stop msyql
mysqld -remove

下載:
https://dev.mysql.com/downloads/mysql/
ps:如果裝之前裝過資料庫檔案洗掉mysql目錄下的data檔案夾
1、初始化資料庫:
mysqld --initialize --console
得到初始密碼

2、將mysql安裝為windows的服務:
mysqld -install
3、啟動mysql服務
輸入net start mysql或sc start mysql
net start mysql
4、登錄資料庫
Mysql -uroot -p
5、修改資料庫口令
alter user 'root'@'localhost' identified by “123456789”;
6、配置遠程登錄
update user set Host='%' where User='root';
重繪權限
flush privileges;
五、安裝應用(我這里裝了個metinfo)
直接扔到web目錄
/var/www/html


-------------------------------------------
個性簽名:獨學而無友,則孤陋而寡聞,做一個靈魂有趣的人!知識源于分享!
如果覺得這篇文章對你有小小的幫助的話,記得在右下角點個“推薦”哦,博主在此感謝!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/538621.html
標籤:其他
