小弟我自己的PHP环境安装配置
我自己的PHP环境安装配置
最近可能会用到PHP。第一步当然想到要安装开发环境。
网上有很多一键安装的,因为我机器上已经安装有了mysql所以不想重复在安装一个mysql。
就决定使用单独的配置安装。一开始在网上找了很多教程呀什么的。遇到了很多的问题。
记录一下我的安装过程,留作备忘。
第一步:
下载Apache HTTP Server (httpd) 2.2.21
Win32 Binary without crypto (no mod_ssl) (MSI Installer): httpd-2.2.21-win32-x86-no_ssl.msi
下载PHP 5.2 (5.2.17)下载VC6 x86 Thread Safe的zip版本
VC6和VC9的区别:
VC6版本是使用Visual Studio 6编译器编译的,如果你的PHP是用Apache来架设的,那你就选择VC6版本。
VC9版本是使用Visual Studio 2008编译器编译的,如果你的PHP是用IIS来架设的,那你就选择VC9版本。
Thread Safe和Non Thread Safe因为我一开始使用了Non Thread Safe的启动Apache的时候报错,报错信息就是因为这个非线程安全的原因。所以就使用Thread Safe的版本
第二布:
安装Apache HTTP Server一路默认安装。把安装路径更改为E:\PHP_Work\Apache2.2
把php的zip包内容解压到E:\PHP_Work\php5
第三步:
配置环境,打开apache的httpd.conf文件编辑如下内同:
1.有些网上的教程说在文件的最底端添加LoadModule,我添加到了一大串LoadModule的下面,添加:LoadModule php5_module "E:/PHP_Work/php5/php5apache2_2.dll"
2.找到DocumentRoot改变:DocumentRoot "E:/PHP_Work/Root"
3.找到
4.这步我觉得是我一直配置不正确的地方,网上的教程也是把这句添加到文件的最低端,但我加到了
phpinidir "E:/PHP_Work/php5/"
将php5目录下的php.ini-dist重命名为php.ini.
打开php.ini编辑如下内容:
1.找到extension_dir改变为:extension_dir = "E:\PHP_Work\php5\ext"
2.把extension=php_gd2.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo.dll extension=php_pdo_mysql.dll extension=php_xmlrpc.dll前面的分号(;)去掉
3.找到default_charset去掉前面的分号,并改为default_charset = "utf-8"
4.找到register_globals改变register_globals = On
最后将php5目录下的libmysql.dll复制到c:/windows中
重新启动apache服务,测试是否成功。
新建test_mysql.php写入:
$link=mysql_connect( 'localhost', 'root', '');
if(!$link) echo "失败! ";
else echo "成功! ";
mysql_close();
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

To set up a CGI directory in Apache, you need to perform the following steps: Create a CGI directory such as "cgi-bin", and grant Apache write permissions. Add the "ScriptAlias" directive block in the Apache configuration file to map the CGI directory to the "/cgi-bin" URL. Restart Apache.

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

There are 3 ways to view the version on the Apache server: via the command line (apachectl -v or apache2ctl -v), check the server status page (http://<server IP or domain name>/server-status), or view the Apache configuration file (ServerVersion: Apache/<version number>).

To delete an extra ServerName directive from Apache, you can take the following steps: Identify and delete the extra ServerName directive. Restart Apache to make the changes take effect. Check the configuration file to verify changes. Test the server to make sure the problem is resolved.

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.

Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.
