摘要:安装包: httpd-2.2.15.tar.gz mysql-5.5.20.tar.gz php-5.5.20.tar.gz 一.httpd安装: 安装依赖包 yum install -y gcc gcc-c++ make ncurses-devel bison openssl-devel zlib-devel cmake 1.tar zxvf httpd-2.2.15.tar.gz
安装包: httpd-2.2.15.tar.gz
mysql-5.5.20.tar.gz
php-5.5.20.tar.gz
一.httpd安装:
安装依赖包
yum install -y gcc gcc-c++ make ncurses-devel bison openssl-devel zlib-devel cmake
1.tar zxvf httpd-2.2.15.tar.gz
2.cd httpd-2.2.15
3. .configure --prefix=/usr/local/mysql/ --sysconfdir=/etc --localstatedir=/var/lib/mysql/
将mysql安装到/usr/local/mysql 指定主配置文件目录到/etc目录 指定工作目录是/var/lib/mysql
4.make & make install
二.mysql安装:
1.tar zxf mysql-5.5.20.tar.gz
2.cd mysql-5.5.20
3.编译mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_SSL=yes
make & make install
如果要重新编译,需要清除掉旧的对象文件和缓存信息
make clean
rm -f CmakeCache.txt
4.useradd -M -s /sbin/nologin mysql
5.cd /usr/local/mysql
cp support-files/my-large.cnf /etc/my.cnf #根据你的主机内存复制 mysql 配置文件
chown -R mysql.mysql .
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql
--datadir=/usr/local/mysql/data
chown -R root .
chown -R mysql data
cp support-files/mysql.server /etc/init.d/mysqld
6.设置开机启动
service mysqld start
chkconfig mysqld on
7.配置环境变量
vi ~/.bash_profile
PATH=$PATH:/usr/local/mysql/bin
source ~/.bash_profile
#使之生效
mysql_secure_installation #按提示完成 mysql 安全设置,生产环境推荐使用
ln -s /usr/local/mysql/lib /usr/local/mysql/lib64 #不然 php 编译的时候找不到 mysql 的库文件
8. ./mysqladmin -u root -p password centrald
给mysql设密码,初始密码为空
三.php编译
1.cd php-5.5.20
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --enable-sockets --with-mysqli --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql/ --with-jpeg-dir=/usr/lib64/ --with-curl --enable-mbstring=all --with-config-file-path=/usr/local/php5/etc/ --enable-soap --with-gd --with-gettext
make & make install
2.
cd /usr/local/src/php-5.5.20
cp php.ini-development /usr/local/php5/php.ini
3.vim /usr/local/apache/conf/httpd.conf
修改apache的配置文件
在有AddType附近添加AddType application/x-httpd-php .php
4.重启apache程序
cd /usr/local/apache/bin/
./apachectl restart
5.测试支持PHP
cd /usr/local/apache/htdocs/
vi test.php
添加 <? php phpinfo(); ?>
四.虚拟主机的设置
1.vim conf/httpd.conf 修改httpd.conf配置文件
(1)<Directory/>
OptionsFollowSymLinks
AllowOverrideNone
Orderdeny,allow //
Denyfromall
</Directory>
将之修改为
<Directory/>
OptionsIndexesFollowSymLinks
AllowOverrideNone
</Directory></span>
(2)Include /etc/httpd24/extra/httpd-vhosts.conf 打开虚拟主机功能,去掉前面的#注释
2.vim conf/extra/httpd-vhosts.conf
(1)搭建基于端口的虚拟主机
Listen 12345 新加一个12345端口
<VirtualHost 192.168.1.11:80>
DocumentRoot "/usr/local/apache/htdocs"
ServerName pal.example.com
</VirtualHost>
<VirtualHost 192.168.1.11:12345>
DocumentRoot "/openfire"
ServerName openfire.example.com
</VirtualHost>
(2)搭建基于域名的虚拟主机
#在httpd2.2版本定义基于域名的虚拟主机时,需要加入如下,在2.4则不再需要,直接定义即可
<VirtualHost 192.168.1.11:80>
<VirtualHost 192.168.1.11:80>
DocumentRoot "/usr/local/apache/htdocs"
ServerName pal.example.com
</VirtualHost>
<VirtualHost 192.168.1.11:80>
DocumentRoot "/openfire"
ServerName openfire.example.com
</VirtualHost>
相关文章推荐
虚拟主机的专业参数,分别都是什么意思?2022-09-09
中非域名注册规则是怎样的?注册域名有什么用处? 2022-01-10
HostEase新年活动促销 美国/香港主机全场低至五折2021-12-28
HostGator下载完整备份教程分享2021-12-28
Flink中有界数据与无界数据的示例分析2021-12-28