Ubuntu 14.04 environment to build LAMP (Linux/Apache/MySQL/PHP) website building environment

888u

Last update at :2024-07-14,Edit by888u

LAMP, a website construction environment based on Linux/Apache/MySQL/PHP architecture, is sufficient for general websites. If our website has a large amount of visits or data processing, we can choose to use an NGINX architecture environment such as LNMP. . However, it is sufficient for most websites to use APACHE, and it is relatively simple to use.

Some articles about LAMP or one-click installation packages have been shared with Snail on the Internet before, such as \\"Complete Configuration CentOS6 Installation LAMP (Apache/MySQL/PHP) Environment Building Tutorial\\" and \\"Complete Debian7 Configuring the LAMP (Apache/MySQL/PHP) environment and building a website\\" Yesterday, a netizen asked to write a LAMP article about the Ubuntu environment. Because I don't often use Ubuntu, I found an article from overseas and translated it. Organize, check the completeness of the tutorial and share it.

First, reinstall the VPS hosting environment and upgrade components

Here, I installed Ubuntu 14.04 by default, and then upgraded the components.

apt-get update; apt-get dist-upgrade -y –force-yes

Second, install the Apache WEB server environment

apt-get install apache2 apache2-bin apache2-data apache2-doc apache2-mpm-prefork apache2-utils

Modify the default homepage (/etc/apache2/mods-enabled/dir.conf)

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

Modify to

DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

Then restart service apache2 restart

We can open the default IP address or the bound domain name. If you can see such a page/interface, it means that APACHE has been installed.

Third, start the pseudo-static mod_rewrite component

a2enmod rewriteservice apache2 restart

Fourth, create user management and set up multiple websites

If we only need to create a website, it is simple. We only need to create files in the /var/www/html directory. If we need to create multiple websites, we need to create a website directory and set up a separate user to manage them, which is safer.

adduser laozuo

Then we need to enter the password twice according to the prompts

Adding user `laozuo\\' …Adding new group `laozuo\\' (1000) …Adding new user `laozuo\\' (1000) with group `laozuo\\' …Creating home directory `/home/laozuo \\' …Copying files from `/etc/skel\\' …Enter new UNIX password:Retype new UNIX password:passwd: password updated successfullyChanging the user information for laozuoEnter the new value, or press ENTER for the defaultFull Name []: Room Number []:Work Phone []:Home Phone []:Other []:Is the information correct? [Y/n]

We need to create the public_html folder to store website files and logs.

cd /home/laozuomkdir public_html logs

After creation, we need to set the permissions of the directory, otherwise we will not be able to upload files and edit them.

chown www-data /home/laozuo/public_html /home/laozuo/logschmod 755 /home/laozuo

Don’t forget to change the directory corresponding to your own, because I used laozuo to create all the files in it. We need to use the files corresponding to our own site, so that it is easy to check.

Configure virtual host name

By default Ubuntu14.04 will come with 000-default.conf for HTTP and default ssl.conf for HTTPS. For regular use, we will modify and use 000-default.conf available in the /etc/site directory. Before using it, we must disable the 000-default.conf configuration.

a2dissite 000-default.confservice apache2 reload

Change the 000-default.conf (/etc/apache2/sites-available) file name to our domain name (replace laozuo.org with your domain name)

mv 000-default.conf laozuo.org.conf

Clear content

> laozuo.org.conf

Then we add the following content to the laozuo.org.conf file

ServerName laozuo.orgServerAlias ​​laozuo.orgServerAdmin [email protected]DocumentRoot /var/www/htmlErrorLog ${APACHE_LOG_DIR}/error.logCustomLog ${APACHE_LOG_DIR}/access.log combinedOptions Indexes ExecCGI Includes FollowSymLinks MultiViewsAllowOverride AllOrder Deny,AllowAllow from all< /p>

After saving the file, we start a2ensite laozuo.org.conf

If it cannot start, we can check the log. The log file is in /var/log/apache2/error.log.

Fifth, install and set up the MySQL database

apt-get install mysql-server mysql-client

If there is an error like \\"E: Unable to locate package mysql-server\\", we need to check whether apt-get update has been executed to update the data source before this tutorial.

During the installation of the MYSQL database, you need to enter the MYSQL database ROOT password twice, and they need to be consistent both times. Then wait for the installation to complete.

Sixth, install and set up the PHP environment

apt-get install php5 php-pear php5-mysql php5-dev libapache2-mod-php5 php5-dev php5-curl php5-gd php5-imagick php5-mcrypt

After we complete the installation, we can also add a PHP document to the /var/www/html/info.php file and then check whether it takes effect.

Seventh, install PHPMyAdmin

To facilitate the management of MYSQL database, we still need to install PHPMyAdmin for WEB management of the database.

apt-get install phpmyadmin

When installing, we are asked to select version support.

We select APACHE2 and press Enter to continue. An interface will also appear later to continue. Then a popup will appear asking for the MYSQL ROOT user password. We have set it before. Just enter it twice.

In summary, through the above steps, we can complete the installation of the LAMP website construction environment in the Ubuntu 14.04 environment. Compared with the one-click package, manual installation is still more troublesome. Nowadays, VPS hosts have relatively abundant memory. Novice webmasters still choose one-click packages or panel applications. Manual installation is just a toss-up and wastes more than an hour for me.

Recommended site search: international domain name, Hong Kong vps host, domain name price, registered domain name purchase, io domain name registration, foreign domain name, top ten server brand rankings, host server rental, how to rent a foreign server, Hong Kong high-defense server, < /p>

Ubuntu 14.04 environment to build LAMP (Linux/Apache/MySQL/PHP) website building environment

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码