Ubuntu 12.04 Build Web server (mysql+php+apache) tutorial
1. Switch Administrator status
You need to use root in Ubuntu, so make sure to log in as root with the following command:
sudo su
2. Start the SSH installation
(Install Ssh-server: (with Xshell operation more convenient, first get SSH service support)
sudo apt-get update
sudo apt-get install openssh-server openssh-client
Start Ssh-server
Sudo/etc/init.d/ssh start
)
3. Start the installation of MYSQL5
sudo apt-get install mysql-server mysql-client
You will be asked to provide a password for the root user of MySQL and we need to set the password in the red zone.
New password for the MySQL root user:repeat password for the MySQL root user:
4. Installing Apache2
Apache2 is a software package for Ubuntu, so we can install it directly with the following command:
sudo apt-get install apache2
Now, your browser to http://localhost, you should see the APACHE2 test page:
If it goes well, it will appear:
It worke!
The default document root directory for Apache is the/var/www directory on Ubuntu, and the configuration file is/etc/apache2/apache2.conf. Configure the subdirectories stored in the/etc/apache2 directory.
Modify the default open index file type) nano/etc/apache2/mods-enabled/dir.conf Modify DocumentRoot (modify site root directory)
Nano/etc/apache2/sites-enabled/000-default.conf
Such as:
Documentroot/media/sda3/wwwroot
Restart Apache2
Sudo/etc/init.d/apache2 restart
5. Installing PHP5
We can install the PHP5 and Apache PHP5 modules directly, as follows:
sudo apt-get install php5 libapache2-mod-php5
Restart required after installation
Sudo/etc/init.d/apache2 restart
6. Test the PHP5 and get details of the PHP5 installation
The default Web site's file root directory is under/var/www. Now we will create a small php file (info.php) in the directory to invoke it in the browser. The file will display a lot about our PHP installation, such as the installed PHP version and some useful details.
nano/var/www/info.php
Here is the explanation, if the command line operation is not possible (of course, since you should be accustomed to using Linux to learn to use the command line). Can be set up manually, that is, in the system file/var/www/under the establishment of the file info.php, written inside
Here is the following: It is also my problem, I started to install the Ubuntu 12.04, I found here I do not have permission to operate, although the root authority has been obtained, here to tell you,
How should we set the read and write permissions for the file and file directories?
Everyone knows, we use the virtual host know set 777 what, in fact, here is the same, there are many ways to use, I will tell one of them.
Here we use chmod, for example we want to set up our WWW directory read and write, is chmod 777/var/www/. Specifically, we can refer to the use of the Baidu Encyclopedia command
Http://baike.baidu.com/view/1229012.htm.
Now we can use a browser to access such as http://localhost/info.php
As you can see, php5 works properly, it passes the Apache 2.0 handler in the Server API line. If you continue scrolling down, you will see all the modules that have been enabled in PHP5. MySQL is not listed, which means we do not support MySQL in PHP5.
7.PHP5 to get MySQL support
Let PHP get support in MySQL, we can install the Php-mysql package. It is a good idea to install some other PHP5 modules, as well as the applications you may need:
sudo apt-cache search php5
Also installs the required installation
sudo apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5- Ming Php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
Now restart the apache2:
Sudo/etc/init.d/apache2 restart
Now, reload the http://localhost/info.php in your browser and scroll down to the module section again. Now you should find many new modules, including the MySQL module:
8. Installing phpMyAdmin
phpMyAdmin is a network interface through which you can manage your MySQL database.
sudo apt-get install phpMyAdmin
At this time I have to correct the shortcomings of the predecessor, he did not speak clearly here. This should be: it will be installed automatically under/usr/share/phpmyadmin, then copy the phpMyAdmin to the/var/www directory or create a link: sudo ln-s/usr/share/phpmyadmin/var/www, You can run http://localhost/phpmyadmin/index.html
Note that the above user name is root, password is everyone in front of the database password set!
Today Google a bit, originally is PHP5 not enable MCrypt module.
1 2 |
sudo php5enmod mcrypt sudo service apache2 restart |
Execute the above command and then log back in. There is no error in the above. The original post also need to do a soft connection, but I test not to do a soft connection, it can also be effective.
Ubuntu 12.04 Build Web server (Mysql+php+apache) tutorial (turn + Pro test)