linux 中搭建php开发环境笔记:
一、安装apache服务器
1. 下载httpd-2.4.安装包
2. 新建目录/usr/local/softwares/php-dev-softwares/apache/apache-httpd,在此目录>下解压httpd-2.4.
3. 执行命令
sudo ./configure --prefix=/usr/local/softwares/php-dev-softwares/apache/apache-httpd
报错:
checking no
configure: error: APR not found.  Please read the documentation.
需要安装apache-apr和apache-apr-util
1)下载apr-1.5.和apr-util-1.5.
2)解压,执行如下命令
tar -zxvf apr-1.5.
cd apr-1.5.0
./configure
makemysql下载下来没安装包
make install
apr安装完成。
tar -zxvf apr-util-1.5.
cd apr-util-1.5.3
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
apr-util 安装完成
3)执行安装httpd命令
sudo ./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --prefix=/usr/local/softwares/php-dev-softwares/apache/apache-httpd
报错:
configure: error: pcre-config for libpcre not found. PCRE is required and available
4)安装PCRE,下载pcre-8.34.tar.bz2执行如下命令
sudo tar -vxjf pcre-8.34.tar.bz2
cd pcre-8.34/
sudo ./configure --prefix=/usr/local/pcre
报错:
configure: error: You need a C++ compiler for C++ support.
执行命令:sudo apt-get install build-essential
Ubuntu并没有提供C/C++的编译环境,因此还需要手动安装。
如果想在Ubuntu中编译c/c++程序,只需要安装该软件包就可以了
重新执行命令
cd pcre-8.34/
sudo ./configure --prefix=/usr/local/pcre
sudo make
sudo make install
pcre安装完成。
5)执行安装httpd命令
cd /usr/local/softwares/php-dev-softwares/apache/apache-httpd/httpd-2.4.7
sudo ./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --prefix=/usr/local/softwares/php-dev-softwares/apache/apache-httpd
sudo make
sudo make install
httpd服务安装完成
进入httpd服务器的安in目录启动服务
./apachectl -k start
报错:
AH00558: httpd: 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
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
解决方法:
修改配置文件f
到行
#ample:80
修改为:
ServerName localhost:80
报错:
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
解决方法:
启动的时候加上sudo ./apachectl -k start 
停止服务sudo ./apachectl -k stop
启动成功后在浏览器的地址栏输入127.0.0.1或者localhost
浏览器显示出It works.表示apache服务器安装成功
二、安装mysql
1. 建立用户组mysql,命令如下:
groupadd mysql
2. 添加mysql用户,命令如下:
mkdir /home/mysql
useradd -g mysql -d /home/mysql mysql
设置mysql用户的密码为mysql
sudo passwd mysql
注: 这里使用添加的用户的方法会导致用户主目录没有任何文件,这里创建新用户的方法最好用
adduser username
这个命令会直接生成用户户信息
3. 配置mysql服务其的安装目录
mkdir /usr/local/softwares/php-dev-softwares
cd /usr/local/softwares/php-dev-softwares
拷贝安装包mysql-5.6.13-linux-glibc2.5-x86_到该目录。
解压该安装包
sudo tar -xzvf mysql-5.6.13-linux-glibc2.5-x86_
重命名解压后的压缩包
sudo mv mysql-5.6.13-linux-glibc2.5-x86_64 mysql
改变mysql的所属用户及用户组
cd /usr/local/softwares/php-dev-softwares/mysql
sudo chown -R mysql .
sudo chgrp -R mysql .
4. 安装mysql服务器
执行安装命令: sudo scripts/mysql_install_db --user=mysql
报错:Installing MySQL /bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决方案:报该错误的原因是缺少名为libaio的依赖库
安装依赖库:sudo apt-get install libaio-dev
安装完成后再次执行安装mysql服务器的命令。
安装时显示出的日志:
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
  /usr/local/softwares/php-dev-softwares/mysql/bin/mysqladmin -u root password 'new-pas
sword'
  /usr/local/softwares/php-dev-softwares/mysql/bin/mysqladmin -u root -h ubuntu password 'new-password'
Alternatively you can run:
  /usr/local/softwares/php-dev-softwares/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
  cd . ; /usr/local/softwares/php-dev-softwares/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
  cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available on the web at

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。