Ubuntu14.04 LAMP环境安装搭建

安装相关文件

#安装apache
wyj@wyj-virtual-machine:~$ dpkg -l|grep apache
wyj@wyj-virtual-machine:~$ sudo apt-get install apache2
wyj@wyj-virtual-machine:~$ dpkg -l|grep apache
ii  apache2                                               2.4.7-1ubuntu4.20                                   amd64        Apache HTTP Server
ii  apache2-bin                                           2.4.7-1ubuntu4.20                                   amd64        Apache HTTP Server (binary files and modules)
ii  apache2-data                                          2.4.7-1ubuntu4.20                                   all          Apache HTTP Server (common files)

#安装php5
wyj@wyj-virtual-machine:~$ dpkg -l|grep php5
ii  php5-common                                           5.5.9+dfsg-1ubuntu4.25                              amd64        Common files for packages built from the php5 source
ii  php5-fpm                                              5.5.9+dfsg-1ubuntu4.25                              amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php5-json                                             1.3.2-2build1                                       amd64        JSON module for php5
ii  php5-mysql                                            5.5.9+dfsg-1ubuntu4.25                              amd64        MySQL module for php5
wyj@wyj-virtual-machine:~$ sudo apt-get install php5

#安装Mysql
wyj@wyj-virtual-machine:~$ dpkg -l|grep mysql-server
ii  mysql-server                                          5.5.60-0ubuntu0.14.04.1                             all          MySQL database server (metapackage depending on the latest version)
ii  mysql-server-5.5                                      5.5.60-0ubuntu0.14.04.1                             amd64        MySQL database server binaries and system database setup
ii  mysql-server-core-5.5                                 5.5.60-0ubuntu0.14.04.1                             amd64        MySQL database server binaries
#sudo apt-get install mysql-server

wyj@wyj-virtual-machine:~$ sudo apt-get install libapache2-mod-php5
#出现如下错误
* Restarting web server apache2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
   ...fail!

#出来尝试重启

wyj@wyj-virtual-machine:~$ sudo service apache2 restart 
 * Restarting web server apache2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
   ...fail!
 * The apache2 instance did not start within 20 seconds. Please read the log files to discover problems

wyj@wyj-virtual-machine:~$ sudo service nginx stop

#想起前几天搭的nginx可能占用着端口

wyj@wyj-virtual-machine:~$ sudo service apache2 restart 
 * Restarting web server apache2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
   ...done.

wyj@wyj-virtual-machine:~$ sudo vim /etc/apache2/apache2.conf 
#在最后加上ServerName localhost:80
wyj@wyj-virtual-machine:~$ sudo service apache2 restart 
 * Restarting web server apache2
   ...done.

#其他模块安装
wyj@wyj-virtual-machine:~$ sudo apt-get install libapache2-mod-php5
wyj@wyj-virtual-machine:~$ sudo apt-get install libapache2-mod-auth-mysql
wyj@wyj-virtual-machine:~$ sudo apt-get install php5-mysql
wyj@wyj-virtual-machine:~$ sudo apt-get install php5-gd

  • 前两个很容易明白,要想apache能够解析PHP,就需要借助这两个模块来找到php engine。
  • 第三个在php操作mysql数据库时用到
  • 第四个GD库。

 

测试


安装完apache2,根目录在/var/www/html下,可以通过http://localhost/测试一下是否好用。

当然也可以在该目录下新建一个文件test.html来试一试http://localhost/test.html。
wyj@wyj-virtual-machine:/var/www/html$ sudo vim /var/www/html/test.html
<html>
<title>Test!</title>
<body> Hello Apache.</body>
<html>
<title>Test!</title>
<body> Hello Apache.</body>
</html>

参考博客:https://blog.csdn.net/u010571844/article/details/50748268

猜你喜欢

转载自blog.csdn.net/caijiwyj/article/details/81604747