I. Apache installation as a powerful Web program is naturally the first choice for building a Web server. now, we will install Apache. Enter the following command in the terminal: After the sudoapt-getinstallapache2 is installed, start Apache sudo/etc/init. d/apache2restart in the browser input h
1. install Apache
Apache, as a powerful Web program, is naturally the first choice for building Web servers. now, we will install Apache. Enter the following command on the terminal:
Sudo apt-get install apache2
After the installation is complete, start Apache.
Sudo/etc/init. d/apache2 restart
Enter http: // localhost or http: // 127.0.0.1 in the browser. if "It works!" is displayed! ", It means that Apache is successfully installed. by default, Apache will create a directory named www under/var, which is the Web directory, all Web files that can be accessed through a browser must be placed in this directory.
II. PHP installation
Installing software in Ubuntu is a very simple task. you only need one command. execute the following command on the terminal:
Sudo apt-get install libapache2-mod-php5 php5
After installation, restart Apache to load the PHP module:
Sudo/etc/init. d/apache2 restart
Next, we will create a PHP file under the Web directory to test whether PHP can run normally. command:
Sudo gedit/var/www/phpinfo. php
Compile a php file, for example
</P> <p> my first PHP page </p> <p>
Hi word
III. (1) installationMysqlServer here we only need to installMysqlServer is OK
Sudo apt-get install mysql-server
At the end of the installation, it will ask for the root password. Note that the root password here is not the Ubuntu root password. it is the root password you want to set for MySQL. of course, if you are happy, you can set it to the same way. Because it is mainly used for local testing, MySQL is installed here. if it is used as a server, you may need to refer to other settings.
(2) install the client
Apt-get install mysql-client
(3) install the C language development interface for mysql
Apt-get install libmysqlclient15-dev
1). mysql installation layout in ubuntu:
/Usr/bin client program and mysql_install_db
/Db database and log files
/Var/run mysqld server
/Etc/mysql configuration file my. cnf
/Usr/share/mysql character set, baseline program and error message
/Etc/init. d/mysql start mysql server
2). set the mysql server to automatically start and close with the on/off server:
System> System Management> service
After entering the "service settings" window, activate the mysql database service.
3) modify the storage directory of mysql database files:
Assume that the specified database file directory is/db.
1. create a directory/db and change its owner and group to mysql: mysql. Command: chown mysql: mysql db
2. disable mysql database service: mysqladmin-u root-p shutdown
3. modify mysql configuration file my. cnf: change datadir =/var/lib/mysql to datadir =/db
4. reinitialize the data file: execute mysql_install_db
5. start mysql database service: sudo/etc/init. d/mysql start
6. set the mysql database root password: mysqladmin-u root password 'new-password'
At this time, we will find mysql-related files in the/db directory. If we create a new database, its database files will also appear in the db directory. Indicates that the file storage directory of the mysql database we modified is correct.
4) configure the INNODB storage engine of the mysql database:
1. view the mysql Storage Engine: log on to the mysql database and run the showengines command at the mysql> prompt. Conclusion: InnoDB | YES indicates that the mysql database server supports the InnoDB engine.
2. set InnoDB as the default engine: add default-storage-engine = INNODB under [mysqld] in the configuration file my. cnf and save the statement.
3. restart the mysql server: mysqladmin-u root-p shutdown (press enter), sudo/etc/init. d/mysql start (press enter ).
4. log on to the mysql database and run the show engines command at the mysql> prompt. If InnoDB | DEFAULT is displayed, InnoDB is successfully set as the DEFAULT engine.
Ps: Here I use the restart command sudo/etc/init. d/mysql restart, and an error message is displayed, so I used the stupid method of closing and starting the service (step 3) above.
It is said that the following command can be used once:
Sudo apt-get install apache2 mysql-server php5 php5-mysql php5-gdPhpmyadmin
Remember the MySql password in this step.
In addition, you can install MySQL on the graphic management interface:
Sudo apt-get install mysql-admin *
If the mysql_connect () connection error occurs after the installation is successful, run the following command:
Sudo apt-get install php5-mysql
4. download the Discuz installation package
$ Cd ~
$ MkdirDiscuz
$ Cd discuz
$ Wgethttp: // download.comsenz.com/Discuz/7.2/Discuz_7.2_FULL_ SC _GBK.zip
4. decompress the package
$ Sudo apt-get install unzip
$ Unzip Discuz_7.0.0_FULL_ SC _GBK.zip
5. create a bbs directory under/var/www and copy all the files under the previously decompressed upload directory to the bbs directory.
$ Cd/var/www/
$ Sudo mkdir bbs
$ Cd ~
$ Cd discuz/
$ Sudo cp-a upload/*/var/www/bbs/
6. set the www folder 777 attribute in var.
$ Sudo chmod-R 777/var/www
7. open the browser and enter:
Http: // server IP address/bbs/install/index. php
Note: If the page cannot be opened, restart apache.
$ Sudo/etc/init. d/apache2 restart
Build a php development environment in ubuntu
In fact, I don't know anything about php, but when I recently browsed others' blogs, I accidentally found a blog platform-wordpress. at the beginning, I don't know what this is. I later learned about it after google, so I also want to try it, but wordpress is developed in php, my computer does not have such an environment, and I have never learned php, but this cannot prevent my enthusiasm. so I found some materials and set up the environment, at the beginning, I still had some detours, but it was finally set up. In fact, the method is also very simple. below is my step:
Install apache2
Enter
Sudo apt-get install apache2
Then, wait until the installation is complete. after the installation is successful, the apache service is enabled.
Sudo service apache2 [start | stop | restart]
To start, shut down, and restart the service.
In this case, you can enter localhost/in the browser. if the installation is successful, It works
2. install php
Enter
Sudo apt-get install php5libapache2-mod-php5
Now apache can parse php. you can test whether it is successful and run
Sudo gedit/var/www/testphp. php
Write in , And then open http: // localhost/testphp. php in the browser. if it can be parsed, there will be output results.
I have always encountered problems here. instead of using testphp. php, I downloaded the file directly. if you encounter this problem, try
Sudo a2enmod php5
The next step is to clear the browser cache and restart the apache service (I didn't restart it). I solve this problem through this method.
3. install mysql
Enter
Sudo apt-get installmysql-server mysql-client # you will be asked to enter the root user password once in the middle
Sudo apt-get install php5-mysql # installation php5-mysql is to connect php and mysql
Sudo apt-get installlibapache2-mod-auth-mysql
The installation is successful.
The following command is used to enable and disable mysql:
Sudo start mysql # start it manually
Sudo stop mysql # manually stop
Pgrep mysqld # check whether mysql is enabled
Conclusion: the above steps allow you to successfully build a php development environment. At first, I set it up in windows and thought it was quite troublesome. so I thought I was using ubuntu. Why did I install it in ubuntu? so I tried it, and succeeded. Needless to say, building on ubuntu is indeed much easier than building on windows. Of course, this is just to build the environment. it is easy to configure apache and set service security.