(轉(zhuǎn))Lamp搭建

1.配置網(wǎng)絡(luò)環(huán)境

管理員給分配了一個(gè)靜態(tài)IP,所以還需要進(jìn)一步配置網(wǎng)絡(luò)環(huán)境

配置DNS:右上角網(wǎng)絡(luò)連接->編輯鏈接->有線連接1->IPv4設(shè)置->DNS服務(wù)器:202.112.80.106->保存

登陸網(wǎng)關(guān):對(duì)于校園網(wǎng)用戶來(lái)說(shuō),登陸網(wǎng)關(guān)才能訪問(wèn)外網(wǎng)

測(cè)試:ping www.baidu.com

2.設(shè)置root密碼

sudo passwd

切換到root用戶:su或su -或su root

切換到普通用戶:su 用戶名或logout

3.更新源

sudo apt-get update

源保存的文件為:/etc/apt/sources.list

安裝常用軟件

1.SSH

sudo apt-get install openssh-server

查看狀態(tài):service ssh status/start/stop/restart

或:/etc/init.d/ssh status/start/stop/retsrt

實(shí)際上,service命令就是執(zhí)行/etc/init.d腳本,二者功能是一樣的

2.Vim

sudo apt-get install vim

3.Tree

sudo apt-get install tree

4.Git

sudo apt-get install git

搭建LAMP

1.安裝Apache

sudo apt-get install apache2

測(cè)試: 瀏覽器訪問(wèn)http://Ubuntu的IP,出現(xiàn)It Works!網(wǎng)頁(yè)。

查看狀態(tài):service apache2 status/start/stop/restart

Web目錄:/var/www

安裝目錄:/etc/apache2/

全局配置:/etc/apache2/apache2.conf

監(jiān)聽端口:/etc/apache2/ports.conf

虛擬主機(jī):/etc/apache2/sites-enabled/000-default.conf

2.安裝MySQL

sudo apt-get install mysql-server mysql-client

測(cè)試:mysql -u root -p

查看狀態(tài):service mysql status/start/stop/retart

查看監(jiān)聽端口的情況:netstat -tunpl或netstat -tap

3.安裝PHP

sudo apt-get install php7.0

測(cè)試:php7.0 -v

4.安裝其他模塊

sudo apt-get install libapache2-mod-php7.0

sudo apt-get install php7.0-mysql

重啟服務(wù)

service apache2 restart

service mysql restart

測(cè)試Apache能否解析PHP

vim /var/www/html/phpinfo.php

文件中寫:

瀏覽器訪問(wèn):http://ubuntu地址/phpinfo.php,出現(xiàn)PHP Version網(wǎng)頁(yè)

5.修改權(quán)限

sudo chmod 777 /var/www

6.安裝phpMyAdmin

sudo apt-get install phpmyadmin

安裝:選擇apache2,點(diǎn)擊確定。下一步選擇是要配置數(shù)據(jù)庫(kù),并輸入密碼。

創(chuàng)建phpMyAdmin快捷方式:sudo ln -s /usr/share/phpmyadmin /var/www/html

啟用Apachemod_rewrite模塊:sudo a2enmod rewrite

重啟服務(wù)

service php7.0-fpm restart

service apache2 restart

測(cè)試:瀏覽器訪問(wèn):http://ubuntu地址/phpmyadmin

7.配置Apache

vim /etc/apache2/apache2.conf

添加

AddType application/x-httpd-php .php .htm .html

AddDefaultCharset UTF-8

重啟Apache服務(wù)

安裝python包

1.pip

sudo apt-get install python-pip

2.Django

pip install django

測(cè)試:import django

##3.MySQL-python

pip install MySQL-python

測(cè)試:import MySQLdb

常見問(wèn)題

1.Secure SSH Client連接出錯(cuò)

錯(cuò)誤:algorithm negotiation failed

解決

修改sshd的配置文件:vim /etc/ssh/sshd_config

在配置文件中添加:

Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc

MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96

KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org

重啟sshd服務(wù):service ssh restart

2.Xshell或Xftp中文亂碼

Xshell:文件->屬性->終端->編碼->UTF-8>

Xftp:文件->屬性->選項(xiàng)->選中使用UTF-8編碼

3.安裝MySQL出錯(cuò)

錯(cuò)誤

下列軟件包有未滿足的依賴關(guān)系:

mysql-client : 依賴: mysql-client-5.5 但是它將不會(huì)被安裝

mysql-server : 依賴: mysql-server-5.5 但是它將不會(huì)被安裝

E: 無(wú)法修正錯(cuò)誤,因?yàn)槟竽承┸浖3脂F(xiàn)狀,就是它們破壞了軟件包間的依賴關(guān)系。

解決:兩種解決方法

使用Ubuntu自帶的下載源,不要使用其他源(如網(wǎng)易)

手動(dòng)安裝

下載MySQL:http://dev.mysql.com/downloads/mysql/

使用FTP工具上傳到Ubuntu

解壓:tar -xvf mysql-server_5.7.13-1ubuntu16.04_i386.deb-bundle.tar

安裝:

sudo dpkg -i libmysqlclient20_5.7.15-1ubuntu16.04_amd64.deb libmysqlclient-dev_5.7.15-1ubuntu16.04_amd64.deb libmysqld-dev_5.7.15-1ubuntu16.04_amd64.deb mysql-common_5.7.15-1ubuntu16.04_amd64.deb mysql-community-source_5.7.15-1ubuntu16.04_amd64.deb mysql-community-client_5.7.15-1ubuntu16.04_amd64.deb mysql-client_5.7.15-1ubuntu16.04_amd64.deb mysql-community-server_5.7.15-1ubuntu16.04_amd64.deb mysql-server_5.7.15-1ubuntu16.04_amd64.deb

4.安裝pip出錯(cuò)

解決:可改用如下命令:

sudo apt-get install python-pip python-dev build-essential

sudo pip install --upgrade pip

sudo pip install --upgrade virtualenv

5.安裝Django超時(shí)報(bào)錯(cuò)

解決

設(shè)置超時(shí)時(shí)間:sudo pip install django --default-timeout 100

或者使用其他下載源:pip install web.py -i

6.安裝MySQL-python報(bào)錯(cuò)

錯(cuò)誤:EnvironmentError: mysql_config not found

解決

sudo apt-get install libmysqld-dev

安裝MySQL-python:pip install MySQL-python

7.更新Python庫(kù)

pip install --upgrade 庫(kù)名

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容