fdgg888 发表于 2015-9-6 09:21:05

LAMP第一部分-环境搭建

手动安装
准备工作
关闭 selinux
清空iptables
1. 安装mysql   
cd /usr/local/src/   
wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.72-linux-x86_64-glibc23.tar.gz   
tar zxvfmysql-5.1.72-linux-x86_64-glibc23.tar.gz   
mv   mysql-5.1.72-linux-x86_64-glibc23/usr/local/mysql   
useradd -s /sbin/nologin mysql   
cd /usr/local/mysql   
mkdir -p /data/mysql   
chown -R mysql:mysql /data/mysql
cd/usr/local/mysql   
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
(pwd:/usr/local/mysql)
报错:http://www.plob.org/2011/03/10/78.html安装 epel-release libmcrypt-devellibaio pcre-devel perl libxml2-devel openssl-devel bzip2-devel freetype-devel libjpeg-devel libpng-devel compat-libstdc*
[root@wuhan-242 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
WARNING: The host 'wuhan-242' could not be looked up with resolveip.   
This probably means that your libc libraries are not 100 % compatible   
with this binary MySQL version. The MySQL daemon, mysqld, should work   
normally with the exception that host name resolving will not work.   
This means that you should use IP addresses instead of hostnames   
when specifying MySQL privileges !   
Installing MySQL system tables...   
OK   
Filling help tables...   
OK
[root@centos-03 httpd-2.2.29]# echo$?   
0   
cp support-files/my-large.cnf /etc/my.cnf   
cp support-files/mysql.server /etc/init.d/mysqld   
chmod 755 /etc/init.d/mysqld   
vim /etc/init.d/mysqld   
#修改
basedir=/usr/local/mysql
datadir=/data/mysql
chkconfig --add mysqld   
chkconfig mysqld on   
/etc/init.d/mysqld start
Starting MySQL ERROR! Couldn't find MySQL manager (/usr/local/mysql/bin/mysqlmanager) or server (/usr/local/mysql/bin/mysqld_safe)   
mv时文件移动不对   
检查mysqlmanager所在的pwd   
测试   
netstat-lnp |grep3306   
2. 安装apache   
pwd:/usr/local/src/
wget   http://archive.apache.org/dist/httpd/httpd-2.2.16.tar.gz   
tar zvxf httpd-2.2.16.tar.gz   
cd httpd-2.2.29   
./configure --prefix=/usr/local/apache2--enable-mods-shared=most--enable-so
[root@centos-03 httpd-2.2.29]# echo$?   
0
configure:error: in `/usr/local/src/httpd-2.2.21/srclib/apr':
configure:error: no acceptable C compiler found in $PATH
See `config.log'for more details.
执行./configure时,可能会遇到以上错误,这个主要是gcc包没有安装。对于这个问题,使用 yuminstall gcc就可以了。
make && make install
servicehttpdstart
[root@localhost httpd-2.2.29]# servicehttpdstart   
httpd: 未被识别的服务
/usr/local/apache2/bin/apachectl start
http://blog.sina.com.cn/s/blog_5093fd500101bzk4.html
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

http://www.cnblogs.com/52linux/archive/2012/03/24/2415637.html
   /etc/httpd/conf/httpd.conf
/usr/local/apache2/conf/httpd.conf
将里面的 #ServerName localhost:80 注释去掉即可。
[root@sun httpd-2.2.29]# servicehttpdrestart   
Stopping httpd:    
Starting httpd:
测试   浏览器 输入111.47.123.72


psaux |grephttpd
netstat-lnp |grep80   
3.安装php
pwd:/usr/local/src/
wget http://mirrors.sohu.com/php/php-5.3.29.tar.gz   
tar zxf php-5.3.29.tar.gz   
cd php-5.3.28   
./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6   
echo$?
1
configure: error: xml2-config not found. Please check your libxml2 installation.
configure: error: Cannot find OpenSSL's <evp.h>
configure: error: Please reinstall the BZip2 distribution
configure: error: jpeglib.h not found.
[root@sun php-5.3.28]# yuminstall   -y   libxml2*
[root@sun php-5.3.28]# yum install -ybzip2*
[root@sun php-5.3.28]# yum install -yopenssl-dev*
[root@sun php-5.3.28]# yum install -ylibmcrypt*
(yum install libxml2-devellibjpeg-*libpng-devel freetype-devel gd-devel libmcrypt-devel openssl-develbzip2*)
解决
yum install -y gcc gcc-c++make zlib zlib-devel pcre pcre-devellibjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
http://blog.iyunv.com/default7/article/details/32312061   
echo$?   
make && make install
/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** 错误 1   
http://blog.sina.com.cn/s/blog_65d94e4c010195ys.html   
Thank you for using PHP.   
4. 配置apache结合php   
vim /usr/local/apache2/conf/httpd.conf   
找到:   
AddType application/x-gzip .gz .tgz   
在该行下面添加:   
AddType application/x-httpd-php .php   
找到:   
<IfModule dir_module>   
    DirectoryIndex index.html   
</IfModule>   
将该行改为:   
<IfModule dir_module>   
    DirectoryIndex index.html index.htm index.php   
</IfModule>   
找到:   
#ServerName www.example.com:80   
修改为:   
ServerName localhost:80
[root@localhost htdocs]# /usr/local/apache2/bin/apachectl -t   
Syntax OK   
5. 测试解析php   
vim /usr/local/apache2/htdocs/1.php   
写入:   
<?php   
    echo "php解析正常";   
?>   
保存后,继续测试:   
curl localhost/1.php

[root@sun htdocs]# /usr/local/apache2/bin/apachectl restart   
httpd not running, trying to start   
(98)Address already in use: make_sock: could not bind to address [::]:80   
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80   
no listening sockets available, shutting down   
Unable to open logs   
http://blog.sina.com.cn/s/blog_637e04c901011bmm.html
vi /etc/services   查看 端口号   


页: [1]
查看完整版本: LAMP第一部分-环境搭建