Linux下搭建php运行环境【转】

需要安装的软件:
1.	安装mysql
1.1安装编译器gcc
最小化安装,没有安装编译器
yum install gcc
yum install gcc-c++
如果不安装,在编译mysql的时候会出现【exec: g++: not found】错误

1.2安装ncurses-5.6.tar.gz,
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6 
./configure --prefix=/usr --with-shared --without-debug
make
make install 

1.3安装mysql 
tar -zxvf mysql-5.0.51a.tar.gz 
cd mysql-5.0.51a
./configure --with-mysqld-user=mysql --prefix=/usr/local/mysql5 --with-charset=gbk --with-extra-charsets=all --without-isam --exec-prefix=/usr/local/mysql5
echo $?
Make clean
make && make install

1.4 初始化数据库:
groupadd mysql
useradd -g mysql mysql
scripts/mysql_install_db
cp /usr/local/mysql5/share/mysql/my-medium.cnf /usr/local/mysql5/var/my.cnf 
cp /usr/local/mysql5/share/mysql/mysql.server /etc/init.d/mysqld 
编辑my.cnf 把skip -federated注释掉
chkconfig --add mysqld 
chkconfig --level 2345 mysqld on
chown mysql:mysql -R /usr/local/mysql5/
chmod +w /usr/local/mysql5/
service mysqld start
ln -s /usr/local/mysql5/bin/mysql /sbin/mysql 
ln -s /usr/local/mysql5/bin/mysqladmin /sbin/mysqladmin

1.5 设定mysql密码
mysqladmin -uroot password "1111111"

1.6让系统找到mysql(如果必要的话): 
PATH=$PATH:/usr/local/mysql5/bin 
export PATH 
echo "/usr/local/mysql5/lib/mysql" >> /etc/ld.so.conf 
ldconfig

1.7测试 
netstat -nplt | grep mysql
ps aux|grep mysql

1.8 授权用户权限
切记:@%代表在远程的权限,@localhost实际上只有在本机的权限
进入mysql
grant all on *.* to root@”%” identified by “111111” with grant option;
其他用户也可以这样设置权限

2.	安装apache
2.1编译安装
tar zxvf httpd-2.2.8.tar.gz 
cd httpd-2.2.8
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
echo $?
make && make install
/usr/local/apache2/bin/apachectl configtest
/usr/local/apache2/bin/apachectl start
/usr/local/apache/bin/apachectl stop

2.2修改默认启动页
vi /usr/local/apache2/conf/httpd.conf
DirectoryIndex index.html 改为
DirectoryIndex index.html index.htm default.htm default.html index.php index.php3 index.jsp
#ServerName http://www.7966.org/ 改为
ServerName http://www.7966.org/

2.3 apache 开机启动的办法
#echo "/usr/local/apache/bin/apachectl start" >>/etc/rc.local(系统启动时服务自动启动)
测试:
在浏览器上输入127.0.0.1进入Apache test页面

编辑/etc/init.d/httpd
修改:
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
prog=httpd
pidfile=/usr/local/apache2/logs/httpd.pid
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

5.安装PHP
5.1安装zlib
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install

5.2安装png
tar zxvf libpng-1.2.14.tar.gz
cd libpng-1.2.14
cp scripts/makefile.linux ./makefile
./configure –prefix=/usr/local/libpng
make
make install

5.3安装freetype
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure
make
make install

5.4安装jpeg
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1}
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
make
make install

5.5 安装GD
tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --with-png --with-freetype --with-jpeg=/usr/local/jpeg/
make
make install

5.6安装LIBXML2
tar zxvf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
./configure --prefix=/usr/local/libxml2
make
make install
cp xml2-config /usr/bin

5.7安装PHP5.2.5
tar zxvf php-5.2.5.tar.gz 
cd php-5.2.5
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql5 --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/include/freetype2 --with-zlib --with-png-dir=/usr/local/libpng12 --with-libxml-dir=/usr/local/libxml2 --with-gd --enable-ftp --enable-sockets
make
make test
make install

5.8配置
cp php.ini-dict /usr/local/php5/lib/php.ini
编辑/usr/local/apache2/conf/httpd.conf
加载php模块,去掉注释,有的版本是缺省就启用的。
LoadModule php5_module        modules/libphp5.so
加上下面两行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
编辑/usr/local/php5/lib/php.ini
设置php的session直接读取方式
register_globals=off 改成 on
设置php支持cookie
output_buffering = Off 改成 on

7.3 在apache网站的根目录下(/usr/local/apache2/htdocs/)新建index.php
<? php
  $ip=$HTTP_HOST;
  echo $ip;
?>
测试通过,OK

文章来源于网络或者作者投稿,若有侵权请联系删除,作者:老钟,如若转载,请注明出处:https://www.laoz.net/87.html

(1)
上一篇 2011 年 08 月 16 日
下一篇 2011 年 08 月 17 日

相关推荐

  • 管理VPS ,常用的Linux命令

    系统 # uname -a # 查看内核/操作系统/CPU信息 # head -n 1 /etc/issue # 查看操作系统版本 # cat /proc/cpuinfo # 查看CPU信息 # hostname # 查看计算机名 # lspci -tv # 列出所有PCI设备 # lsusb -tv # 列出所...

    vps教程 2011 年 09 月 19 日
  • linux 下安装jdk1.5,亲自测试

    前提是有个虚拟机安装好了linux了,然后下载1.5的jdk        jdk-1_5_0_07-distro-linux-i586.bin,这里有个地址下载 http://download.chinaunix.net/down.php?id=28642&ResourceID=12304&site=1 然后用f...

    vps教程 2011 年 11 月 25 日
  • 关于Almalinux9使用的一些心得

    鉴于Centos后期不维护的缘故,把一些系统改为Almalinux9,这个属于Centos8的一个社区升级版,很多命令是跟Centos8相似的; 下面讲一下在设置中出现的一个命令错误提示: 使用yum查找提供此功能的的软件包:yum pro...

    vps教程 2023 年 04 月 13 日
  • centos7 vps服务器的安全设置

    大家都知道centOS7以上的跟centOS6在命令是有很大变化的,未来也是趋势 老钟博客之前服务器安全的分析均是在CentOS6基础上进行,因为习惯了,一般不喜欢去更换系统 但是CentOS7以上基础安全性和运行效果是更加好 ...

    vps教程 2020 年 07 月 03 日
  • 解决VMware安装Centos在安装VMware Tools就停止的情况

    在Vmware上面安装Centos 6.5来测试,发现总是在安装VMware Tools停止安装了,当然,也在网上找了很多解决办法,下面可以提供给大家参考 我的解决:在刚开始创建虚拟机的时候,不需要添加iso文件进行安装,这样就...

    2017 年 06 月 20 日
  • linux下统计文件夹文件数量

    linux下统计文件夹数量 egrep "7966.org"  file|wc -l 最近bluehost主机上,发现文件限制为50,000个文件。于是想看一下,主机文件夹里的文件数量,由于主机是linux的,所以找了一下。大致有两种: 一种是: ls  ...

    vps教程 2011 年 11 月 23 日
  • centOS6安装lnmp1.7提示memcached not found错误的解决

    不管怎么测试,centos6安装lnmp1.7总是会提示memcached报错,建议有报错的兄弟更换到lnmp16,这样省事! 报错信息如下: configure.ac:3: error: Autoconf version 2.68 or higher is required 这个意思是需要安...

    vps教程 2020 年 08 月 29 日
  • lnmp 运行一段时间后出现nginx 502 Bad Gateway的解决方法

    导致这个问题的原因很多解决:设置一下参数,重启php服务设置参数可以参考:http://www.henry24264.com/?p=1040/home/lnmp/ restart如果重启出现这个问题:Stoping LNMP... Nginx program is...

    vps教程 2012 年 11 月 02 日
  • VPS安全设置 增强VPS安全性防止被攻破

    安全是一个VPS最基本的必备条件,若您的VPS三天两头被人攻破,那么对于网站来说也没什么意义了,所以,在创建了Web服务器之后,您首先要做的事情就是将您的VPS加固,至少让普通黑客没有办法能够攻破您的网站。 用...

    vps教程 2018 年 01 月 17 日
  • couldn't flush system prefs

    运行程序时,发现报此错误:警告: Couldn't flush system prefs: java.util.prefs.BackingStoreException: java.io.FileNotFoundException: /etc/.java/.systemPrefs/pre...

    vps教程 2012 年 08 月 13 日