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

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

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

相关推荐

  • CentOS7修改SSH端口

    一、修改ssh配置文件sshd_config [root@bogon ~]# vi /etc/ssh/sshd_config 二、防火墙放行 [root@bogon ~]# firewall-cmd --zone=public --add-port=22345/tcp --permanent [root@bogon ~]# firewall-cmd --relo...

    2020 年 05 月 16 日
  • BURST倒闭了,把网站都迁移到Linode

      前几天收到邮件,burst说7月25停止所有服务,我还以为是我的服务器到期了,看了其他一些VPS大牛的文章,才知道原来burst倒闭了,其实VPS还是可以继续使用的,因为他的VPS卖给了hostwinds ,我的vps是7.25...

    2014 年 06 月 28 日
  • 新建VPS服务器的安全防护设置

    0x00 起因 最近我自己的 vps 越来越不稳定,开始还以为是因为我自己在路由器里面添加了透明代理使用的流量大造成的,后来越来越发觉不正常,毕竟我也是用了几年 vps 的老手了,总觉的不正常。后来 iftop 发现我的...

    vps教程 2020 年 05 月 04 日
  • CentOS7以上系统修改SSH端口号的方法

    CentOS目前发展到8了,以前一直使用CentOS6,是因为从centOS7开始,操作的命令就已经有很大的变化,一直以来都懒得换系统,但是按照目前发展的趋势,必须得迈出这一步了。 需要使用新版的系统,那么首先第一步肯...

    vps教程 2020 年 08 月 22 日
  • 2016-9-28 搬瓦工套餐继续更新,原来11.99刀的已经卖完

    搬瓦工vps,这个是继之前84vps,老钟极力给大家推荐的一个性价比高的vps 上次给大家推荐的一个11.99刀,机房在凤凰城,国内访问的速度一般般,但是配置不错,可惜已经卖光了 今天,发现LA的机房又推出几款套餐,...

    2016 年 09 月 28 日
  • CentOS7 网站开启ssl证书后,网站无法访问,提示ERR_CONNECTION_REFUSED

    CentOS7服务器,安装lnmp, 原本网站正常运行,添加SSL证书后,发现网站拒绝访问,提示: 无法显示此网页 网站暂时无法连接,错误代码 ERR_CONNECTION_REFUSED 解决方法如下: 1, 检查系统防火墙firewall是否添加...

    vps教程 2021 年 02 月 26 日
  • Nginx服务器安装SSL后全站http跳转https

     网上很多教程关于如何做全站的http转https,我这里只讲述nginx服务器的跳转方法之前提到过阿里云申请的SSL如何部署到服务器:lnmp安装阿里云免费SSL,出现welcome to nginx页面,提示403错误解决办法这里主要讲...

    vps教程 2018 年 04 月 13 日
  • Linux中 常用命令 和 进程管理

    Vim: 文本编辑器 vim   文件名 vim  + n(行号)  如  vim  + 3  /etc/passwd 光标在第三行; + /word       光标在有word的行首; Vim主要有三种模式: 命令,输入,末行这三种模式 命令模式 —>  输入模式 1...

    vps教程 2011 年 08 月 11 日
  • linux 查找目录下的所有文件中是否含有某个字符串

    查找目录下的所有文件中是否含有某个字符串  find .|xargs grep -ri "IBM"  查找目录下的所有文件中是否含有某个字符串,并且只打印出文件名  find .|xargs grep -ri "IBM" -l  1.正则表达式    (1)正则表达式一...

    vps教程 2014 年 07 月 01 日
  • vmware下centos找不到网卡eth0 没有ip

    vmware安装完成centos之后,使用ifconfig命令,发现没有eth0出现 那么,可以用ifconfig -a 试试,如果还是没看到,则使用命令ifconfig eth0 up开启网卡 如果发现显示出来的信息没有显示ip地址,这个时候vi /etc/s...

    vps教程 2017 年 03 月 28 日